-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1470 interview notes on recruitmentpositionoverviewpage (#1568)
* Refactor to use useQuery instead of useState * Added form for interview form * Translation change * Removed unused file * Biome:fix and removed imports * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Update frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentApplicantAdminPage.tsx Co-authored-by: Snorre Sæther <[email protected]> * Made changes requested from review --------- Co-authored-by: Snorre Sæther <[email protected]>
- Loading branch information
Showing
3 changed files
with
157 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
frontend/src/PagesAdmin/RecruitmentApplicantAdminPage/RecruitmentInterviewNotesForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm } from 'react-hook-form'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { z } from 'zod'; | ||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Textarea } from '~/Components'; | ||
import { KEY } from '~/i18n/constants'; | ||
|
||
const recruitmentNotesSchema = z.object({ | ||
notes: z.string(), | ||
}); | ||
|
||
type RecruitmentInterviewNotesFormType = z.infer<typeof recruitmentNotesSchema>; | ||
|
||
interface RecruitmentInterviewNotesFormProps { | ||
initialData: Partial<RecruitmentInterviewNotesFormType>; | ||
} | ||
|
||
export function RecruitmentInterviewNotesForm({ initialData }: RecruitmentInterviewNotesFormProps) { | ||
const { t } = useTranslation(); | ||
|
||
const form = useForm<RecruitmentInterviewNotesFormType>({ | ||
resolver: zodResolver(recruitmentNotesSchema), | ||
defaultValues: initialData, | ||
}); | ||
|
||
function handleUpdateNotes(value: string) { | ||
// TODO: Update notes using a put request | ||
console.log(value); | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form> | ||
<div> | ||
<FormField | ||
control={form.control} | ||
name="notes" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>{t(KEY.recruitment_interview_notes)}</FormLabel> | ||
<FormControl> | ||
<Textarea | ||
{...field} | ||
onBlur={(newNotes) => { | ||
field.onBlur(); // Call the default onBlur handler from react-hook-form | ||
handleUpdateNotes(newNotes.target.value); // Call your custom function on blur | ||
}} | ||
/> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
</div> | ||
</form> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters