Skip to content
54 changes: 54 additions & 0 deletions src/components/layout/RegisterLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useNavigate } from 'react-router-dom';
import Button from '../common/Button';

const TEXT_MAP = {
profile: {
header: '내 프로필',
content: '내 프로필을 등록하고 원하는 가게에 지원해 보세요.',
buttonText: '내 프로필 등록하기',
link: '/profile/edit',
},
store: {
header: '내 가게',
content: '내 가게를 소개하고 공고도 등록해 보세요.',
buttonText: '가게 등록하기',
link: '/owner/store/edit',
},
application: {
header: '신청 내역',
content: '아직 신청 내역이 없어요.',
buttonText: '공고 보러가기',
link: '/',
},
notice: {
header: '등록한 공고',
content: '공고를 등록해 보세요.',
buttonText: '공고 등록하기',
link: '/owner/post',
},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 type에 따라 구분하는 방식이 아니라 prop으로 넘겨주는 방식이면 더 좋을 것 같습니다~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 이미 다 정해져있는 텍스트들이고, prop으로 넘겨주는 방식이면 사용할때 괜히 더 길어지는 것 같아 이 방식을 채택했습니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일반적으로 컴포넌트는 확장성/범용성을 위해서 만든다고 생각해서.. 개인적으로 좋은 방식은? 아닌 거 같습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말씀대로 확장성을 고려한다면 주영님 말씀이 맞지만, 지금 저희가 구현하는 페이지 내에서 사용되는 부분은 4개뿐이고, 사용처가 추가되거나 내용이 변할 가능성이 없다고 느끼기 때문에 현재는 이 방식이 좀 더 적합하다고 생각합니다.
추후에 확장 가능성이 있다면 prop으로 넘기는 방식도 괜찮을 것 같습니다.


export default function RegisterLayout({
type,
}: {
type: 'profile' | 'store' | 'application' | 'notice';
}) {
const navigate = useNavigate();
const { header, content, buttonText, link } = TEXT_MAP[type];

return (
<div className="mx-12 flex flex-col gap-16 pt-40 pb-80 md:mx-32 md:gap-24 md:pt-60 md:pb-120 lg:mx-auto lg:w-964">
<h1 className="text-h3 font-bold md:text-h1">{header}</h1>
<div className="flex flex-col items-center gap-16 rounded-[12px] border border-gray-20 px-24 py-60 md:gap-24">
<p className="text-body2/22 md:text-body1/26">{content}</p>
<Button
size="medium"
className="px-20 py-10 md:h-48 md:w-344 md:text-body1 md:font-bold"
onClick={() => navigate(link)}
>
{buttonText}
</Button>
</div>
</div>
);
}