Skip to content

Commit

Permalink
Merge pull request #1354 from 42organization/feat/1353-feat-임시-결과-등록-…
Browse files Browse the repository at this point in the history
…모달-추가

[Feat] 임시 결과 등록 모달 추가
  • Loading branch information
yoouyeon authored Apr 6, 2024
2 parents f1d3dc1 + 956151c commit f874e83
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,39 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
});
};

const handleApplicationResultModal = (
recruitId: number,
applicationId: number,
status: 'PROGRESS_INTERVIEW' | 'FAIL',
interviewDate: Date | null
) => {
setModal({
modalName: 'ADMIN-RECRUIT_RESULT',
recruitResult: {
recruitId,
applicationId,
status,
interviewDate,
},
});
};

const handleInterviewResultModal = (
recruitId: number,
applicationId: number,
status: 'PASS' | 'FAIL'
) => {
setModal({
modalName: 'ADMIN-RECRUIT_RESULT',
recruitResult: {
recruitId,
applicationId,
status,
interviewDate: null,
},
});
};

const handleAlignment = (
event: React.MouseEvent<HTMLElement>,
newAlignment: string | null,
Expand Down Expand Up @@ -105,7 +138,11 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
);
}

const renderTableCell = (recruit: Inotication, columnName: string) => {
const renderTableCell = (
recruitId: number,
recruit: Inotication,
columnName: string
) => {
if (columnName === 'interview') {
return (
<div className={styles.interview}>
Expand All @@ -114,7 +151,33 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
onChange={(date) => setStartDate(date)}
/>
&nbsp;
<Button variant='outlined'>면접</Button>
<Button
variant='outlined'
onClick={() => {
handleApplicationResultModal(
recruitId,
recruit.applicationId,
'PROGRESS_INTERVIEW',
startDate
);
}}
>
면접
</Button>
<Button
variant='outlined'
onClick={() => {
handleApplicationResultModal(
recruitId,
recruit.applicationId,
'FAIL',
startDate
);
}}
>
불합
</Button>
{/* 임시 버튼 */}
</div>
);
}
Expand All @@ -140,7 +203,11 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
<Button
variant='outlined'
onClick={() => {
/* resultHandler(recruit.id, alignment[recruit.id], 'result'); */
handleInterviewResultModal(
recruitId,
recruit.applicationId,
alignment[recruit.applicationId] === '합격' ? 'PASS' : 'FAIL'
);
}}
>
결과
Expand All @@ -162,7 +229,7 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
{tableFormat['notificationList'].columns.map(
(columnName: string, index: number) => (
<TableCell className={styles.tableBodyItem} key={index}>
{renderTableCell(recruit, columnName)}
{renderTableCell(recruitId, recruit, columnName)}
</TableCell>
)
)}
Expand Down
83 changes: 83 additions & 0 deletions components/modal/admin/AdminRecruitResultModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { useSetRecoilState } from 'recoil';
import { instanceInManage } from 'utils/axios';
import { toastState } from 'utils/recoil/toast';
import styles from 'styles/admin/modal/AdminRecruitMessageTemplateModal.module.scss';

function AdminRecruitResultModal({
recruitId,
applicationId,
status,
interviewDate,
}: {
recruitId: number;
applicationId: number;
status: 'PROGRESS_INTERVIEW' | 'FAIL' | 'PASS';
interviewDate: Date | null;
}) {
const setSnackbar = useSetRecoilState(toastState);
const sendInterviewResult = async () => {
try {
// send interview result to server
await instanceInManage.post(
`/admin/recruitments/${recruitId}/interview?application=${applicationId}`,
{
status,
interviewDate,
}
);
setSnackbar({
toastName: 'interviewResult',
severity: 'success',
message: '면접 결과가 성공적으로 등록되었습니다.',
clicked: true,
});
} catch (e) {
setSnackbar({
toastName: 'interviewResult',
severity: 'error',
message: '면접 결과 등록에 실패했습니다.',
clicked: true,
});
}
};

const sendFinalResult = async () => {
try {
// send final result to server
await instanceInManage.post(
`/admin/recruitments/${recruitId}/result?application=${applicationId}`,
{
status,
}
);
setSnackbar({
toastName: 'finalResult',
severity: 'success',
message: '최종 결과가 성공적으로 등록되었습니다.',
clicked: true,
});
} catch (e) {
setSnackbar({
toastName: 'finalResult',
severity: 'error',
message: '최종 결과 등록에 실패했습니다.',
clicked: true,
});
}
};
if (status === 'PROGRESS_INTERVIEW' && interviewDate) {
return (
<div className={styles.container}>
<button onClick={sendInterviewResult}>면접 결과 등록</button>
</div>
);
}

return (
<div className={styles.container}>
<button onClick={sendFinalResult}>최종 결과 등록</button>
</div>
);
}

export default AdminRecruitResultModal;
6 changes: 6 additions & 0 deletions components/modal/modalType/AdminModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import AdminUserCoinModal from 'components/modal/admin/AdminUserCoinModal';
import DeletePenaltyModal from 'components/modal/admin/DeletePenaltyModal';
import DetailModal from 'components/modal/admin/DetailModal';
import AdminSeasonEdit from 'components/modal/admin/SeasonEdit';
import AdminRecruitResultModal from '../admin/AdminRecruitResultModal';

export default function AdminModal() {
const {
Expand All @@ -35,6 +36,7 @@ export default function AdminModal() {
coinPolicy,
tournament,
tournamentId,
recruitResult,
} = useRecoilValue(modalState);

if (!modalName) {
Expand Down Expand Up @@ -92,6 +94,10 @@ export default function AdminModal() {
<AdminTournamentParticipantEditModal tournamentId={tournamentId} />
) : null,
'ADMIN-RECRUIT_MESSAGE_TEMPLATE': <AdminRecruitMessageTemplateModal />,
// 임시 결과 등록 모달
'ADMIN-RECRUIT_RESULT': recruitResult ? (
<AdminRecruitResultModal {...recruitResult} />
) : null,
};

return content[modalName];
Expand Down
10 changes: 9 additions & 1 deletion types/modalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ type AdminModal =
| 'CHECK_SEND_NOTI'
| 'TOURNAMENT_BRAKET_EDIT'
| 'TOURNAMENT_PARTICIPANT_EDIT'
| 'RECRUIT_MESSAGE_TEMPLATE';
| 'RECRUIT_MESSAGE_TEMPLATE'
| 'RECRUIT_RESULT';

type ModalName =
| null
Expand Down Expand Up @@ -142,4 +143,11 @@ export interface Modal {
tournamentInfo?: TournamentInfo;
tournament?: ITournament;
tournamentId?: number;
// recruit result
recruitResult?: {
recruitId: number;
applicationId: number;
status: 'PROGRESS_INTERVIEW' | 'FAIL' | 'PASS';
interviewDate: Date | null;
};
}

0 comments on commit f874e83

Please sign in to comment.