Skip to content

Commit

Permalink
Get and edit interview notes
Browse files Browse the repository at this point in the history
  • Loading branch information
hei98 committed Jan 11, 2024
1 parent 45ee98b commit 67c9267
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ export function InterviewNotesPage() {
const recruitmentId = useParams().recruitmentId;
const gangId = useParams().gangId;
const positionId = useParams().positionId;
const userId = useParams().userId;
const [editingMode, setEditingMode] = useState(false);
const [recruitmentAdmission, setRecruitmentAdmission] = useState<RecruitmentAdmissionDto[]>([]);
const [nameUser, setNameUser] = useState<string>('');
const { t } = useTranslation();

useEffect(() => {
if (positionId && recruitmentId && gangId) {
if (positionId && recruitmentId && gangId && userId) {
getRecruitmentAdmissionsForGang(gangId, recruitmentId).then((response) => {
const recruitmentAdmissions = response.data;
const admission = recruitmentAdmissions.filter(
(admission) => admission.id.toString() === positionId && admission.interview && admission.interview.notes,
(admission) =>
admission.id.toString() === positionId && admission.interview && userId === admission.user.id.toString(),
);
setRecruitmentAdmission(admission);
setNameUser(admission[0].user.first_name + ' ' + admission[0].user.last_name);
});
}
}, [recruitmentId, positionId, gangId]);
}, [recruitmentId, positionId, gangId, userId]);

async function handleEditSave() {
if (recruitmentAdmission[0] === undefined) {
console.log('no interview notes found');
toast.error(t(KEY.common_something_went_wrong));
return;
}
if (editingMode) {
const updatedAdmission = {
...recruitmentAdmission[0],
Expand All @@ -44,11 +44,9 @@ export function InterviewNotesPage() {
},
};
try {
console.log('Saving this data:', updatedAdmission);
const response = await putRecruitmentAdmissionForGang(recruitmentAdmission[0].id.toString(), updatedAdmission);
console.log('Saved data response:', response);
await putRecruitmentAdmissionForGang(recruitmentAdmission[0].id.toString(), updatedAdmission);
toast.success(t(KEY.common_save_successful));
} catch (error) {
console.error('Error saving notes:', error);
toast.error(t(KEY.common_something_went_wrong));
}
}
Expand All @@ -59,7 +57,7 @@ export function InterviewNotesPage() {
<AdminPageLayout title={t(KEY.recruitment_interview_notes)}>
<div className={styles.container}>
<label htmlFor="INotes">
{t(KEY.recruitment_applicant)} {positionId}
{t(KEY.recruitment_applicant)} {positionId} - {nameUser}
</label>
<TextAreaField
value={recruitmentAdmission[0] ? recruitmentAdmission[0].interview.notes : ' '}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const KEY = {
common_long_description: 'common_long_description',
common_short_description: 'common_short_description',
common_back_to_samfundet: 'common_back_to_samfundet',
common_save_successful: 'common_save_successful',
common_delete_successful: 'common_delete_successful',
common_update_successful: 'common_update_successful',
common_creation_successful: 'common_creation_successful',
Expand Down Expand Up @@ -241,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: 2 additions & 0 deletions frontend/src/i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const nb: Record<KeyValues, string> = {
[KEY.common_long_description]: 'Lang beskrivelse',
[KEY.common_short_description]: 'Kort beskrivelse',
[KEY.common_back_to_samfundet]: 'Tilbake til samfundet.no',
[KEY.common_save_successful]: 'Lagring var vellykket',
[KEY.common_delete_successful]: 'Slettingen var vellykket',
[KEY.common_update_successful]: 'Oppdateringen var vellykket',
[KEY.common_see_in_django_admin]: 'Se i django admin-panel',
Expand Down Expand Up @@ -321,6 +322,7 @@ export const en: Record<KeyValues, string> = {
[KEY.common_long_description]: 'Long description',
[KEY.common_short_description]: 'Short description',
[KEY.common_back_to_samfundet]: 'Back to samfundet.no',
[KEY.common_save_successful]: 'Saving was successful',
[KEY.common_delete_successful]: 'Deletion was successful',
[KEY.common_update_successful]: 'The update was successful',
[KEY.common_see_in_django_admin]: 'See in django admin-panel',
Expand Down
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',
'/control-panel/recruitment/:recruitmentId/gang/:gangId/position/:positionId/interview-notes/:userId',
// ==================== //
// Development //
// ==================== //
Expand Down

0 comments on commit 67c9267

Please sign in to comment.