Skip to content

Commit

Permalink
Merge pull request #1396 from 42organization/recruit
Browse files Browse the repository at this point in the history
[test-deploy] admin 지원자페이지 api 버그 수정 배포
  • Loading branch information
yoouyeon authored Apr 15, 2024
2 parents 1574268 + 14647bd commit 0b28388
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 57 deletions.
17 changes: 17 additions & 0 deletions components/admin/recruitments/RecruitmentsHistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ function RecruitmentsHistoryList({
);
}

if (columnName === 'status') {
const today = new Date();
const todaystring = today.toISOString().slice(0, 19);
const todaydate = new Date(todaystring);
const endDate = new Date(recruit.endDate);
const startDate = new Date(recruit.startDate);
return (
<div>
{recruit.isFinish
? '완료'
: startDate <= todaydate && endDate >= todaydate
? '진행중'
: '진행전'}
</div>
);
}

return (
<AdminContent
content={recruit[columnName as keyof Irecruit]?.toString() as string}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {
TableContainer,
TableRow,
} from '@mui/material';
import { IcheckItem } from 'types/admin/adminRecruitmentsTypes';
import {
AdminEmptyItem,
AdminTableHead,
} from 'components/admin/common/AdminTable';
import PageNation from 'components/Pagination';
import useRecruitmentUserFilter from 'hooks/recruitments/useRecruitmentUserFilter';
import styles from 'styles/admin/recruitments/RecruitmentsUser.module.scss';
import FilterQptionsUI from './FilterOptions';
import renderTableCells from './renderTableCells';
import RecruitmentFilterOptions from './RecruitmentFilterOptions';
import RenderTableCells from './RenderTableCells';

const tableTitle: { [key: string]: string } = {
id: '',
Expand Down Expand Up @@ -47,7 +48,7 @@ function DetailRecruitUserList({ recruitId }: { recruitId: number }) {

return (
<>
{FilterQptionsUI(recruitUserData.applicationResults, recruitId)}
<RecruitmentFilterOptions recruitId={recruitId} />
<TableContainer className={styles.tableContainer} component={Paper}>
<Table className={styles.table} aria-label='customized table'>
<TableHead className={styles.tableHeader}>
Expand All @@ -64,7 +65,7 @@ function DetailRecruitUserList({ recruitId }: { recruitId: number }) {
</TableHead>
<TableBody className={styles.tableBody}>
{recruitUserData.applicationResults.map((recruit) =>
renderTableCells(recruit, questions)
RenderTableCells(recruit, questions, '')
)}
</TableBody>
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
const [currentPage, setCurrentPage] = useState<number>(1);
const [alignment, setAlignment] = useState<Record<number, string | null>>({});
const setSnackBar = useSetRecoilState(toastState);
const [startDate, setStartDate] = useState<Date | null>(new Date());
const [startDate, setStartDate] = useState<Record<number, Date | null>>({});
const setModal = useSetRecoilState(modalState);

const onEditTemplate = () => {
Expand Down Expand Up @@ -98,6 +98,10 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
setAlignment((prev) => ({ ...prev, [id]: newAlignment }));
};

const handleDate = (newDate: Date | null, id: number) => {
setStartDate((prev) => ({ ...prev, [id]: newDate }));
};

const getRecruitNotiHandler = useCallback(async () => {
try {
// const res = await instanceInManage.get(
Expand Down Expand Up @@ -153,8 +157,12 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
return (
<div className={styles.interview}>
<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
selected={startDate[recruit.applicationId]}
showTimeSelect
timeFormat='HH:mm'
dateFormat='yyyy-MM-dd HH:mm'
timeIntervals={60}
onChange={(newDate) => handleDate(newDate, recruit.applicationId)}
/>
&nbsp;
<Button
Expand All @@ -164,7 +172,7 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
recruitId,
recruit.applicationId,
'PROGRESS_INTERVIEW',
startDate
startDate[recruit.applicationId]
);
}}
>
Expand All @@ -177,7 +185,7 @@ function NotificationResults({ recruitId }: { recruitId: number }) {
recruitId,
recruit.applicationId,
'FAIL',
startDate
startDate[recruit.applicationId]
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ const MenuProps = {
},
};

// FIXME : FilterQptionsUI 이름 변경하기 (의미를 알아보기 어려움)
function FilterQptionsUI(
recruitUserData: IrecruitUserTable[],
recruitId: number
) {
const [answers, setAnswers] = useState<Array<IcheckItem>>([]);
const { checklistIds, handleChecklistChange } =
function RecruitmentFilterOptions({ recruitId }: { recruitId: number }) {
const { checklistIds, handleChecklistChange, recruitUserData } =
useRecruitmentUserFilter(recruitId);
const [answers, setAnswers] = useState<Array<IcheckItem>>([]);

useEffect(() => {
setAnswers(
recruitUserData.reduce((acc, recruit) => {
recruit.forms.forEach((formItem) => {
recruitUserData.applicationResults.reduce((acc, recruit) => {
recruit.forms?.forEach((formItem) => {
if (formItem.inputType !== 'TEXT') {
formItem.checkedList?.forEach((item) => {
if (!acc.some((answer) => answer.checkId === item.checkId)) {
Expand Down Expand Up @@ -81,4 +77,4 @@ function FilterQptionsUI(
);
}

export default FilterQptionsUI;
export default RecruitmentFilterOptions;
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ const ExpandableTableRow: React.FC<ExpandableTableRowProps> = ({
);
};

function renderTableCells(recruit: IrecruitUserTable, questions: string[]) {
function RenderTableCells(
recruit: IrecruitUserTable,
questions: string[],
status: string
) {
const answers = questions.map((question) => {
const formItem = recruit.forms.find((form) => form.question === question);
if (!formItem) return 'N/A';

switch (formItem.inputType) {
case 'TEXT':
return formItem.answer;
Expand All @@ -60,31 +63,46 @@ function renderTableCells(recruit: IrecruitUserTable, questions: string[]) {
return 'N/A';
}
});
if (recruit.status === 'PASS') status = '합격';
else if (recruit.status === 'INTERVIEW_FAIL') {
status = '면접 불합격';
} else if (recruit.status === 'APPLICATION_FAIL') {
status = '지원서 불합격';
} else if (recruit.status === 'PROGRESS_DOCS') {
status = '면접 시간 발표 전';
} else if (recruit.status === 'INTERVIEW') {
status = '면접 시간 공개';
} else if (recruit.status === 'FAIL') {
status = '불합격';
} else {
status = '심사중';
}

return (
<ExpandableTableRow
key={recruit.applicationId}
expandComponent={
<div style={{ padding: '16px' }}>
<div className={styles.expandableTableRow}>
<div>
<strong>intraId:</strong> {recruit.intraId}
</div>
<div>
<strong>status:</strong> {recruit.status}
<strong>status:</strong> {status}
</div>
{recruit.forms.map((form, index) => (
<div key={index}>
<strong>{form.question}</strong>:{' '}
{form.answer
? form.answer
: form.checkedList?.map((item) => item.contents).join(', ')}
</div>
))}
{recruit.forms &&
recruit.forms.map((form, index) => (
<div key={index}>
<strong>{form.question}</strong>:{' '}
{form.answer
? form.answer
: form.checkedList?.map((item) => item.contents).join(', ')}
</div>
))}
</div>
}
>
<TableCell className={styles.tableBodyItem}>{recruit.intraId}</TableCell>
<TableCell className={styles.tableBodyItem}>{recruit.status}</TableCell>
<TableCell className={styles.tableBodyItem}>{status}</TableCell>
{answers.map(
(answer: string | undefined, index: React.Key | null | undefined) => (
<TableCell className={styles.tableBodyItem} key={index}>
Expand All @@ -98,4 +116,4 @@ function renderTableCells(recruit: IrecruitUserTable, questions: string[]) {
);
}

export default renderTableCells;
export default RenderTableCells;
61 changes: 56 additions & 5 deletions components/modal/admin/AdminRecruitResultModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import React, { useState, useEffect } from 'react';
import { useSetRecoilState } from 'recoil';
import { instanceInManage } from 'utils/axios';
import { instanceInManage, instance } from 'utils/axios';
import { dateToStringShort , dateToDateTimeLocalString } from 'utils/handleTime';
import { toastState } from 'utils/recoil/toast';
import styles from 'styles/admin/modal/AdminRecruitMessageTemplateModal.module.scss';

interface notiMessageType {
messageId: number;
messageType: string;
isUse: boolean;
message: string;
}

function AdminRecruitResultModal({
recruitId,
applicationId,
Expand All @@ -14,15 +23,19 @@ function AdminRecruitResultModal({
status: 'PROGRESS_INTERVIEW' | 'FAIL' | 'PASS';
interviewDate: Date | null;
}) {
const [passMessage, setPassMessage] = useState<notiMessageType>();
const [failMessage, setFailMessage] = useState<notiMessageType>();
const [interviewMessage, setInterviewMessage] = useState<string>();
const setSnackbar = useSetRecoilState(toastState);
const sendInterviewResult = async () => {
try {
if (!interviewDate) return;
// send interview result to server
await instanceInManage.post(
await instance.post(
`/admin/recruitments/${recruitId}/interview?application=${applicationId}`,
{
status,
interviewDate,
interviewDate: dateToDateTimeLocalString(interviewDate),
}
);
setSnackbar({
Expand All @@ -44,7 +57,7 @@ function AdminRecruitResultModal({
const sendFinalResult = async () => {
try {
// send final result to server
await instanceInManage.post(
await instance.post(
`/admin/recruitments/${recruitId}/result?application=${applicationId}`,
{
status,
Expand All @@ -65,16 +78,54 @@ function AdminRecruitResultModal({
});
}
};

const messagesResult = async () => {
try {
const res = await instance.get(`/admin/recruitments/result/message`);
res.data.messages?.map((message: notiMessageType) => {
if (message.messageType === 'INTERVIEW' && message.isUse) {
if (!interviewDate) return;
const interviewDateMessage = message.message.replace(
'${선택날짜}',
dateToStringShort(interviewDate)
);
if (!interviewDateMessage) return;
setInterviewMessage(interviewDateMessage);
} else if (message.messageType === 'PASS' && message.isUse) {
setPassMessage(message);
} else if (message.messageType === 'FAIL' && message.isUse) {
setFailMessage(message);
}
});
} catch (e: any) {
setSnackbar({
toastName: 'get notification',
severity: 'error',
message: `API 요청에 문제가 발생했습니다.`,
clicked: true,
});
}
};

useEffect(() => {
messagesResult();
}, []);

if (status === 'PROGRESS_INTERVIEW' && interviewDate) {
return (
<div className={styles.container}>
<div>{interviewMessage}</div>
<button onClick={sendInterviewResult}>면접 결과 등록</button>
</div>
);
}

return (
<div className={styles.container}>
{status === 'PASS' ? (
<div>{passMessage?.message}</div>
) : (
<div>{failMessage?.message}</div>
)}
<button onClick={sendFinalResult}>최종 결과 등록</button>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion constants/admin/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const tableFormat: TableFormat = {
},
recruitUserList: {
name: '지원자 목록',
columns: ['', 'intraId', 'status', 'question'],
columns: ['', 'intraId', 'status', 'isFinish', 'question'],
},
recruitEditTitle: {
name: '공고 수정',
Expand Down
Loading

0 comments on commit 0b28388

Please sign in to comment.