Skip to content

Commit

Permalink
fix: change role prop value
Browse files Browse the repository at this point in the history
  • Loading branch information
kang-kibong committed Oct 23, 2024
1 parent 8fe1bd7 commit 5c59902
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/features/auth/SignUp/components/RoleSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function RoleSelection() {
return (
<Flex justifyContent="center" alignItems="center" gap={FLEX_GAP_CONFIG}>
<RoleSelector role="employer" />
<RoleSelector role="worker" />
<RoleSelector role="employee" />
</Flex>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { responsiveStyle } from '@utils/responsive';
import { Icon } from '@components/common';
import ROUTE_PATH from '@/routes/path';

export const roleConfig = {
employer: {
Expand All @@ -20,8 +21,9 @@ export const roleConfig = {
이λ ₯μ„œ 정보λ₯Ό λ“±λ‘ν•˜λŸ¬ κ°€μ‹€κΉŒμš”?
</>
),
toNavigate: ROUTE_PATH.HOME, // 이λ ₯μ„œ 등둝 νŽ˜μ΄μ§€λ‘œ λ³€κ²½
},
worker: {
employee: {
icon: (
<Icon.Role.Worker
css={responsiveStyle({
Expand All @@ -39,5 +41,6 @@ export const roleConfig = {
사업주 정보λ₯Ό λ“±λ‘ν•˜λŸ¬ κ°€μ‹€κΉŒμš”?
</>
),
toNavigate: ROUTE_PATH.HOME, // νšŒμ‚¬ 등둝 νŽ˜μ΄μ§€λ‘œ λ³€κ²½
},
};
26 changes: 21 additions & 5 deletions src/features/auth/SignUp/components/common/RoleSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { bounceAnimation } from '@assets/styles/animations';
import { responsiveStyle } from '@utils/responsive';
import useModals from '@components/common/Modal/hooks/useModals';
import { modals } from '@/components/common/Modal/Modals';
import { useRegister } from '@/apis/auth/mutations/useRegister';
import { useNavigate } from 'react-router-dom';
import ROUTE_PATH from '@/routes/path';

const cardStyle = responsiveStyle({
default: { padding: '60px 120px', cursor: 'pointer' },
Expand All @@ -18,21 +21,34 @@ const iconStyle = responsiveStyle({
});

type Props = {
role: 'employer' | 'worker';
role: 'employer' | 'employee';
};

export default function RoleSelector({ role }: Props) {
const navigate = useNavigate();
const { openModal } = useModals();
const { mutate } = useRegister();

const handleClick = () => {
const handleRegister = () => {
mutate(
{ type: role },
{
onSuccess: () => {
handleOpenModal();
},
},
);
};

const handleOpenModal = () =>
openModal(modals.roleModal, {
content: roleConfig[role].modalContent,
onSubmit: () => console.log('이λ ₯μ„œ 등둝 νŽ˜μ΄μ§€λ‘œ 이동'),
onSubmit: () => navigate(roleConfig[role].toNavigate),
onClose: () => navigate(ROUTE_PATH.HOME),
});
};

return (
<Card borderColor="blue" borderRadius="12px" css={[bounceAnimation, cardStyle]} onClick={handleClick}>
<Card borderColor="blue" borderRadius="12px" css={[bounceAnimation, cardStyle]} onClick={handleRegister}>
<Flex direction="column" alignItems="center">
<div css={iconStyle}>{roleConfig[role].icon}</div>
<Typo element="h2" color="blue" size="18px" bold>
Expand Down

0 comments on commit 5c59902

Please sign in to comment.