From 6669a33559c3bb332983764c7a48c72694153626 Mon Sep 17 00:00:00 2001 From: hei98 Date: Thu, 8 Feb 2024 00:34:33 +0100 Subject: [PATCH] Revert to old commit and fix error msg --- .../InterviewNotesAdminPage.tsx | 34 ++++++++++--------- frontend/src/i18n/constants.ts | 4 +-- frontend/src/routes/frontend.ts | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/frontend/src/PagesAdmin/InterviewNotesAdminPage/InterviewNotesAdminPage.tsx b/frontend/src/PagesAdmin/InterviewNotesAdminPage/InterviewNotesAdminPage.tsx index 43495eeef..9667603a6 100644 --- a/frontend/src/PagesAdmin/InterviewNotesAdminPage/InterviewNotesAdminPage.tsx +++ b/frontend/src/PagesAdmin/InterviewNotesAdminPage/InterviewNotesAdminPage.tsx @@ -14,37 +14,39 @@ export function InterviewNotesPage() { const recruitmentId = useParams().recruitmentId; const gangId = useParams().gangId; const positionId = useParams().positionId; - const userId = useParams().userId; + const interviewId = useParams().interviewId; const [editingMode, setEditingMode] = useState(false); const [recruitmentAdmission, setRecruitmentAdmission] = useState([]); + const [showSpinner, setShowSpinner] = useState(true); + const [disabled, setdisabled] = useState(true); const [nameUser, setNameUser] = useState(''); const { t } = useTranslation(); useEffect(() => { - if (positionId && recruitmentId && gangId && userId) { + if (positionId && recruitmentId && gangId && interviewId) { getRecruitmentAdmissionsForGang(gangId, recruitmentId).then((response) => { const recruitmentAdmissions = response.data; const admission = recruitmentAdmissions.filter( (admission) => - admission.id.toString() === positionId && admission.interview && userId === admission.user.id.toString(), + admission.recruitment_position && + admission.recruitment_position.toString() === positionId && + admission.interview.id.toString() === interviewId, ); - setRecruitmentAdmission(admission); - setNameUser(admission[0].user.first_name + ' ' + admission[0].user.last_name); + if (admission.length !== 0) { + setdisabled(false); + setRecruitmentAdmission(admission); + setNameUser( + admission[0].user.first_name ? admission[0].user.first_name + ' ' + admission[0].user.last_name : '', + ); + } }); } - }, [recruitmentId, positionId, gangId, userId]); + }, [recruitmentId, positionId, gangId, interviewId, t]); async function handleEditSave() { if (editingMode) { - const updatedAdmission = { - ...recruitmentAdmission[0], - interview: { - ...recruitmentAdmission[0].interview, - notes: recruitmentAdmission[0].interview.notes, - }, - }; try { - await putRecruitmentAdmissionForGang(recruitmentAdmission[0].id.toString(), updatedAdmission); + await putRecruitmentAdmissionForGang(recruitmentAdmission[0].id.toString(), recruitmentAdmission[0]); toast.success(t(KEY.common_save_successful)); } catch (error) { toast.error(t(KEY.common_something_went_wrong)); @@ -57,7 +59,7 @@ export function InterviewNotesPage() {
-
diff --git a/frontend/src/i18n/constants.ts b/frontend/src/i18n/constants.ts index b1100d87e..3b114665f 100644 --- a/frontend/src/i18n/constants.ts +++ b/frontend/src/i18n/constants.ts @@ -242,7 +242,7 @@ export const KEY = { * Reveals errors in translations.ts if some keys are not translated. */ export type KeyKeys = keyof typeof KEY; -export type KeyValues = typeof KEY[KeyKeys]; +export type KeyValues = (typeof KEY)[KeyKeys]; export const LANGUAGES = { NB: 'nb', @@ -250,4 +250,4 @@ export const LANGUAGES = { } as const; export type LanguageKey = keyof typeof LANGUAGES; -export type LanguageValue = typeof LANGUAGES[LanguageKey]; +export type LanguageValue = (typeof LANGUAGES)[LanguageKey]; diff --git a/frontend/src/routes/frontend.ts b/frontend/src/routes/frontend.ts index 77a59dcee..fef04e0e3 100644 --- a/frontend/src/routes/frontend.ts +++ b/frontend/src/routes/frontend.ts @@ -67,7 +67,7 @@ export const ROUTES_FRONTEND = { admin_recruitment_gang_position_applicants_overview: '/control-panel/recruitment/:recruitmentId/gang/:gangId/position/:positionId', admin_recruitment_gang_position_applicants_interview_notes: - '/control-panel/recruitment/:recruitmentId/gang/:gangId/position/:positionId/interview-notes/:userId', + '/control-panel/recruitment/:recruitmentId/gang/:gangId/position/:positionId/interview-notes/:interviewId', // ==================== // // Development // // ==================== //