Skip to content

Commit

Permalink
Biome:fix and removed imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nemisis84 committed Nov 14, 2024
1 parent 456dd7f commit 6094b85
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { useMutation, useQuery } from '@tanstack/react-query';
import classNames from 'classnames';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate, useParams } from 'react-router-dom';
import { toast } from 'react-toastify';
import { BackButton, Button, FormControl, FormField, FormItem, FormLabel, FormMessage, Link, Page, SamfundetLogoSpinner, Textarea, TextAreaField } from '~/Components';
import { BackButton, Button, Link, SamfundetLogoSpinner } from '~/Components';
import { Table } from '~/Components/Table';
import { Text } from '~/Components/Text/Text';
import { getRecruitmentApplicationsForRecruiter, withdrawRecruitmentApplicationRecruiter } from '~/api';
import type { InterviewDto, RecruitmentApplicationDto, } from '~/dto';
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 { useMutation, useQuery } from '@tanstack/react-query';
import { RecruitmentInterviewNotesForm } from './RecruitmentInterviewNotesForm';



export function RecruitmentApplicantAdminPage() {
const { t } = useTranslation();
const navigate = useNavigate();
Expand Down Expand Up @@ -47,7 +45,7 @@ export function RecruitmentApplicantAdminPage() {
},
onSuccess: () => {
toast.success(t(KEY.common_update_successful));
}
},
});

if (isLoading) {
Expand All @@ -60,7 +58,7 @@ export function RecruitmentApplicantAdminPage() {

const initialData: Partial<InterviewDto> = {
notes: interviewNotes || '',
};
};

return (
<AdminPage title={`${applicant?.first_name} ${applicant?.last_name}`}>
Expand Down Expand Up @@ -88,12 +86,9 @@ export function RecruitmentApplicantAdminPage() {
<Text>{recruitmentApplication?.application_text}</Text>
</div>
<div className={classNames(styles.infoContainer)}>
<RecruitmentInterviewNotesForm
initialData={initialData}
/>

<RecruitmentInterviewNotesForm initialData={initialData} />
</div>

<div className={classNames(styles.infoContainer)}>
<Text size="l" as="strong" className={styles.textBottom}>
{t(KEY.recruitment_all_applications)}
Expand All @@ -106,59 +101,61 @@ export function RecruitmentApplicantAdminPage() {
t(KEY.recruitment_recruiter_status),
t(KEY.recruitment_interview_time),
]}

data={otherRecruitmentApplication ? otherRecruitmentApplication.map((element) => {
return {
cells: [
{
sortable: true,
content: (
<Link
target={'frontend'}
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
urlParams: {
applicationID: element.id,
},
})}
>
{element.applicant_priority}
</Link>
),
},
{
content: (
<Link
target={'frontend'}
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
urlParams: {
applicationID: element.id,
},
})}
>
{dbT(element.recruitment_position, 'name')}
</Link>
),
},
{
content: (
<Link
url={reverse({
pattern: ROUTES.frontend.information_page_detail,
urlParams: { slugField: element.recruitment_position.gang.name_nb.toLowerCase() },
})}
>
{dbT(element.recruitment_position.gang, 'name')}
</Link>
),
},
element.recruiter_priority ? element.recruiter_priority : t(KEY.common_not_set),
element.interview_time ? element.interview_time : t(KEY.common_not_set),
],
};
}) :[]}

data={
otherRecruitmentApplication
? otherRecruitmentApplication.map((element) => {
return {
cells: [
{
sortable: true,
content: (
<Link
target={'frontend'}
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
urlParams: {
applicationID: element.id,
},
})}
>
{element.applicant_priority}
</Link>
),
},
{
content: (
<Link
target={'frontend'}
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
urlParams: {
applicationID: element.id,
},
})}
>
{dbT(element.recruitment_position, 'name')}
</Link>
),
},
{
content: (
<Link
url={reverse({
pattern: ROUTES.frontend.information_page_detail,
urlParams: { slugField: element.recruitment_position.gang.name_nb.toLowerCase() },
})}
>
{dbT(element.recruitment_position.gang, 'name')}
</Link>
),
},
element.recruiter_priority ? element.recruiter_priority : t(KEY.common_not_set),
element.interview_time ? element.interview_time : t(KEY.common_not_set),
],
};
})
: []
}
/>
</div>
<div className={styles.withdrawContainer}>
Expand All @@ -167,9 +164,14 @@ export function RecruitmentApplicantAdminPage() {
{t(KEY.recruitment_withdrawn)}
</Text>
) : (
<Button theme="samf" onClick={ () => {
if (recruitmentApplication?.id) {
adminWithdraw.mutate(recruitmentApplication.id)}}}>
<Button
theme="samf"
onClick={() => {
if (recruitmentApplication?.id) {
adminWithdraw.mutate(recruitmentApplication.id);
}
}}
>
{t(KEY.recruitment_withdraw_application)}
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Textarea } from "~/Components";
import { KEY } from "~/i18n/constants";
import { useTranslation } from "react-i18next";
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) {

export function RecruitmentInterviewNotesForm({ initialData }: RecruitmentInterviewNotesFormProps) {
const { t } = useTranslation();

const form = useForm<RecruitmentInterviewNotesFormType>({
Expand All @@ -32,7 +28,6 @@ export function RecruitmentInterviewNotesForm ({initialData }: RecruitmentInterv
console.log(value);
}


return (
<Form {...form}>
<form>
Expand All @@ -44,19 +39,20 @@ export function RecruitmentInterviewNotesForm ({initialData }: RecruitmentInterv
<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>
)}
<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>
)
</form>
</Form>
);
}

0 comments on commit 6094b85

Please sign in to comment.