Skip to content

Commit

Permalink
Revert to old commit and fix error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
hei98 committed Feb 7, 2024
1 parent 67c9267 commit 6669a33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecruitmentAdmissionDto[]>([]);
const [showSpinner, setShowSpinner] = useState<boolean>(true);
const [disabled, setdisabled] = useState<boolean>(true);
const [nameUser, setNameUser] = useState<string>('');
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));
Expand All @@ -57,7 +59,7 @@ export function InterviewNotesPage() {
<AdminPageLayout title={t(KEY.recruitment_interview_notes)}>
<div className={styles.container}>
<label htmlFor="INotes">
{t(KEY.recruitment_applicant)} {positionId} - {nameUser}
{t(KEY.recruitment_applicant)}: {nameUser}
</label>
<TextAreaField
value={recruitmentAdmission[0] ? recruitmentAdmission[0].interview.notes : ' '}
Expand All @@ -69,7 +71,7 @@ export function InterviewNotesPage() {
}}
disabled={!editingMode}
></TextAreaField>
<Button theme="samf" rounded={true} className={styles.button} onClick={handleEditSave}>
<Button theme="samf" rounded={true} className={styles.button} onClick={handleEditSave} disabled={disabled}>
{editingMode ? t(KEY.common_save) : t(KEY.common_edit)}
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ 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',
EN: 'en',
} as const;

export type LanguageKey = keyof typeof LANGUAGES;
export type LanguageValue = typeof LANGUAGES[LanguageKey];
export type LanguageValue = (typeof LANGUAGES)[LanguageKey];
2 changes: 1 addition & 1 deletion frontend/src/routes/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
// ==================== //
Expand Down

0 comments on commit 6669a33

Please sign in to comment.