From 98444919b530399e64912b7333b6e02eabbee830 Mon Sep 17 00:00:00 2001 From: magsyg Date: Sun, 22 Dec 2024 15:09:48 +0100 Subject: [PATCH] restructure applicant admin --- .../RecruitmentApplicantAdminPage.module.scss | 8 +- .../RecruitmentApplicantAdminPage.tsx | 130 +++--------------- .../RecruitmentApplicantAllApplications.tsx | 82 +++++++++++ .../index.ts | 1 + .../RecruitmentApplicantInfo.tsx | 27 ++++ .../RecruitmentApplicantInfo/index.ts | 1 + .../RecruitmentApplicantWithdraw.module.scss | 8 ++ .../RecruitmentApplicantWithdraw.tsx | 46 +++++++ .../RecruitmentApplicantWithdraw/index.ts | 1 + .../RecruitmentInterviewNotesForm.tsx | 0 .../RecruitmentInterviewNotesForm/index.ts | 1 + .../components/index.ts | 4 + frontend/src/i18n/constants.ts | 2 + frontend/src/i18n/translations.ts | 2 + 14 files changed, 198 insertions(+), 115 deletions(-) create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/RecruitmentApplicantAllApplications.tsx create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/index.ts create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/RecruitmentApplicantInfo.tsx create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/index.ts create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.module.scss create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.tsx create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/index.ts rename frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/{ => components/RecruitmentInterviewNotesForm}/RecruitmentInterviewNotesForm.tsx (100%) create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/index.ts create mode 100644 frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/index.ts diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.module.scss b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.module.scss index 17caad5c7..bb7abd798 100644 --- a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.module.scss +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.module.scss @@ -11,12 +11,12 @@ } } +.infoContainer { + margin-top: 1em; +} + .withdrawContainer { display: flex; flex-direction: row; justify-content: center; } - -.withdrawnText { - color: $red-samf; -} diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx index 1585bb699..3b8568ac1 100644 --- a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx @@ -1,21 +1,24 @@ -import { useMutation, useQuery } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; import { useNavigate, useParams } from 'react-router-dom'; import { toast } from 'react-toastify'; -import { BackButton, Button, Link, SamfundetLogoSpinner } from '~/Components'; -import { Table } from '~/Components/Table'; +import { BackButton, SamfundetLogoSpinner } from '~/Components'; import { Text } from '~/Components/Text/Text'; -import { getRecruitmentApplicationsForRecruiter, withdrawRecruitmentApplicationRecruiter } from '~/api'; +import { getRecruitmentApplicationsForRecruiter } from '~/api'; import type { InterviewDto } from '~/dto'; import { STATUS } from '~/http_status_codes'; import { KEY } from '~/i18n/constants'; -import { reverse } from '~/named-urls'; import { ROUTES } from '~/routes'; import { dbT } from '~/utils'; import { AdminPage } from '../AdminPageLayout'; import styles from './RecruitmentApplicantAdminPage.module.scss'; -import { RecruitmentInterviewNotesForm } from './RecruitmentInterviewNotesForm'; +import { + RecruitmentApplicantAllApplications, + RecruitmentApplicantInfo, + RecruitmentApplicantWithdraw, + RecruitmentInterviewNotesForm, +} from './components'; export function RecruitmentApplicantAdminPage() { const { t } = useTranslation(); @@ -35,18 +38,8 @@ export function RecruitmentApplicantAdminPage() { const recruitmentApplication = data?.data.application; const applicant = data?.data.user; - const otherRecruitmentApplications = data?.data.other_applications; const interviewNotes = recruitmentApplication?.interview?.notes; - const adminWithdraw = useMutation({ - mutationFn: (id: string) => { - return withdrawRecruitmentApplicationRecruiter(id); - }, - onSuccess: () => { - toast.success(t(KEY.common_update_successful)); - }, - }); - if (isLoading) { return (
@@ -63,20 +56,7 @@ export function RecruitmentApplicantAdminPage() {
- +
@@ -85,95 +65,23 @@ export function RecruitmentApplicantAdminPage() { {recruitmentApplication?.application_text}
- {recruitmentApplication?.withdrawn ? ( - - {t(KEY.recruitment_withdrawn)} - - ) : ( - - )} +
- +
+ + {t(KEY.recruitment_applications)} {t(KEY.common_in)}{' '} + {dbT(data?.data.application.recruitment_position.gang, 'name')} + + +
{t(KEY.recruitment_all_applications)} -
{ - return { - cells: [ - { - sortable: true, - content: ( - - {element.applicant_priority} - - ), - }, - { - content: ( - - {dbT(element.recruitment_position, 'name')} - - ), - }, - { - content: ( - - {dbT(element.recruitment_position.gang, 'name')} - - ), - }, - element.recruiter_priority ? element.recruiter_priority : t(KEY.common_not_set), - element.interview_time ? element.interview_time : t(KEY.common_not_set), - ], - }; - }) - : [] - } - /> + ); diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/RecruitmentApplicantAllApplications.tsx b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/RecruitmentApplicantAllApplications.tsx new file mode 100644 index 000000000..9bf70481e --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/RecruitmentApplicantAllApplications.tsx @@ -0,0 +1,82 @@ +import { useTranslation } from 'react-i18next'; +import { Link, Table } from '~/Components'; +import type { RecruitmentApplicationDto } from '~/dto'; +import { KEY } from '~/i18n/constants'; +import { reverse } from '~/named-urls'; +import { ROUTES } from '~/routes'; +import { dbT } from '~/utils'; + +type Props = { + applications: RecruitmentApplicationDto[] | undefined; +}; + +export function RecruitmentApplicantAllApplications({ applications }: Props) { + const { t } = useTranslation(); + + const tableColumns = [ + { content: '#', sortable: true, hideSortButton: true }, + { content: t(KEY.common_recruitmentposition), sortable: true, hideSortButton: true }, + { content: t(KEY.common_gang), sortable: true, hideSortButton: true }, + { content: t(KEY.recruitment_recruiter_status), sortable: true, hideSortButton: true }, + { content: t(KEY.recruitment_interview_time), sortable: true, hideSortButton: true }, + ]; + function applicationToRow(application: RecruitmentApplicationDto) { + return { + cells: [ + { + value: application.applicant_priority, + content: ( + + {application.applicant_priority} + + ), + }, + { + value: dbT(application.recruitment_position, 'name'), + content: ( + + {dbT(application.recruitment_position, 'name')} + + ), + }, + { + content: ( + + {dbT(application.recruitment_position.gang, 'name')} + + ), + }, + application.recruiter_priority ? application.recruiter_priority : t(KEY.common_not_set), + application.interview_time ? application.interview_time : t(KEY.common_not_set), + ], + }; + } + + return ( +
applicationToRow(application)) : []} + /> + ); +} diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/index.ts b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/index.ts new file mode 100644 index 000000000..2262bd91d --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantAllApplications/index.ts @@ -0,0 +1 @@ +export { RecruitmentApplicantAllApplications } from './RecruitmentApplicantAllApplications'; diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/RecruitmentApplicantInfo.tsx b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/RecruitmentApplicantInfo.tsx new file mode 100644 index 000000000..38e884e19 --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/RecruitmentApplicantInfo.tsx @@ -0,0 +1,27 @@ +import { useTranslation } from 'react-i18next'; +import { Table } from '~/Components'; +import type { RecruitmentUserDto } from '~/dto'; +import { KEY } from '~/i18n/constants'; +import { dbT } from '~/utils'; + +type Props = { + applicant: RecruitmentUserDto | undefined; +}; + +export function RecruitmentApplicantInfo({ applicant }: Props) { + const { t } = useTranslation(); + + return ( +
+ ); +} diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/index.ts b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/index.ts new file mode 100644 index 000000000..a67f39daf --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantInfo/index.ts @@ -0,0 +1 @@ +export { RecruitmentApplicantInfo } from './RecruitmentApplicantInfo'; diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.module.scss b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.module.scss new file mode 100644 index 000000000..bda37fa18 --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.module.scss @@ -0,0 +1,8 @@ +@import 'src/constants'; + +@import 'src/mixins'; + + +.withdrawnText { + color: $red-samf; +} diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.tsx b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.tsx new file mode 100644 index 000000000..53353c614 --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/RecruitmentApplicantWithdraw.tsx @@ -0,0 +1,46 @@ +import { useMutation } from '@tanstack/react-query'; +import { useTranslation } from 'react-i18next'; +import { toast } from 'react-toastify'; +import { Button, Text } from '~/Components'; +import { withdrawRecruitmentApplicationRecruiter } from '~/api'; +import type { RecruitmentApplicationDto } from '~/dto'; +import { KEY } from '~/i18n/constants'; +import styles from './RecruitmentApplicantWithdraw.module.scss'; + +type Props = { + application: RecruitmentApplicationDto | undefined; +}; + +export function RecruitmentApplicantWithdraw({ application }: Props) { + const { t } = useTranslation(); + + const adminWithdraw = useMutation({ + mutationFn: (id: string) => { + return withdrawRecruitmentApplicationRecruiter(id); + }, + onSuccess: () => { + toast.success(t(KEY.common_update_successful)); + }, + }); + + return ( + <> + {application?.withdrawn ? ( + + {t(KEY.recruitment_withdrawn)} + + ) : ( + + )} + + ); +} diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/index.ts b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/index.ts new file mode 100644 index 000000000..b2e4b97df --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentApplicantWithdraw/index.ts @@ -0,0 +1 @@ +export { RecruitmentApplicantWithdraw } from './RecruitmentApplicantWithdraw'; diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentInterviewNotesForm.tsx b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/RecruitmentInterviewNotesForm.tsx similarity index 100% rename from frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentInterviewNotesForm.tsx rename to frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/RecruitmentInterviewNotesForm.tsx diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/index.ts b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/index.ts new file mode 100644 index 000000000..0394d30f6 --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/RecruitmentInterviewNotesForm/index.ts @@ -0,0 +1 @@ +export { RecruitmentInterviewNotesForm } from './RecruitmentInterviewNotesForm'; diff --git a/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/index.ts b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/index.ts new file mode 100644 index 000000000..f50be057d --- /dev/null +++ b/frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/components/index.ts @@ -0,0 +1,4 @@ +export { RecruitmentApplicantAllApplications } from './RecruitmentApplicantAllApplications'; +export { RecruitmentApplicantInfo } from './RecruitmentApplicantInfo'; +export { RecruitmentInterviewNotesForm } from './RecruitmentInterviewNotesForm'; +export { RecruitmentApplicantWithdraw } from './RecruitmentApplicantWithdraw'; diff --git a/frontend/src/i18n/constants.ts b/frontend/src/i18n/constants.ts index 2c1566ca0..ca897e039 100644 --- a/frontend/src/i18n/constants.ts +++ b/frontend/src/i18n/constants.ts @@ -176,6 +176,7 @@ export const KEY = { common_processed: 'common_processed', common_rejected: 'common_rejected', common_it: 'common_it', + common_in: 'common_in', common_will: 'common_will', common_get: 'common_get', common_count: 'common_count', @@ -375,6 +376,7 @@ export const KEY = { recruitment_admitted: 'recruitment_admitted', recruitment_statistics: 'recruitment_statistics', recruitment_applications: 'recruitment_applications', + recruitment_applications_processed: 'recruitment_applications_processed', recruitment_automatic_rejection: 'recruitment_automatic_rejection', recruitment_rejection_email: 'recruitment_rejection_email', diff --git a/frontend/src/i18n/translations.ts b/frontend/src/i18n/translations.ts index 603fdc1da..36b310734 100644 --- a/frontend/src/i18n/translations.ts +++ b/frontend/src/i18n/translations.ts @@ -161,6 +161,7 @@ export const nb = prepareTranslations({ [KEY.common_processed]: 'behandlet', [KEY.common_rejected]: 'avvist', [KEY.common_it]: 'det', + [KEY.common_in]: 'i', [KEY.common_will]: 'vil', [KEY.common_get]: 'få', [KEY.common_received]: 'mottat', @@ -657,6 +658,7 @@ export const en = prepareTranslations({ [KEY.common_personal]: 'Personal', [KEY.common_rejected]: 'rejected', [KEY.common_it]: 'it', + [KEY.common_in]: 'in', [KEY.common_will]: 'will', [KEY.common_get]: 'get', [KEY.common_received]: 'received',