Skip to content

Commit

Permalink
Merge branch 'master' into 1597-bug-position-route-not-related-to-rec…
Browse files Browse the repository at this point in the history
…ruitment
  • Loading branch information
Snorre98 authored Nov 5, 2024
2 parents 03f4040 + 3bb3c8d commit 0f8b303
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function RecruitmentWithoutInterviewTable({ applicants }: RecruitmentWith
{ content: t(KEY.common_phonenumber), sortable: true },
{ content: t(KEY.recruitment_applicant_top_position), sortable: true },
{ content: t(KEY.recruitment_number_of_applications), sortable: true },
{ content: t(KEY.common_processed), sortable: true },
{ content: t(KEY.recruitment_interview_planned), sortable: true },
];

function filterUsers(): RecruitmentUserDto[] {
Expand Down Expand Up @@ -64,7 +64,8 @@ export function RecruitmentWithoutInterviewTable({ applicants }: RecruitmentWith
value: user.applications_without_interview ? user.applications_without_interview.length : 0,
content: (
<WithoutInterviewModal
applications_without_interview={user.applications_without_interview}
user={user}
applicationsWithoutInterview={user.applications_without_interview}
applications={user.applications}
/>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Icon } from '@iconify/react';
import { useTranslation } from 'react-i18next';
import { Link } from '~/Components';
import { Link, Text } from '~/Components';
import { Table } from '~/Components/Table';
import type { RecruitmentApplicationDto } from '~/dto';
import type { RecruitmentApplicationDto, RecruitmentUserDto } from '~/dto';
import { KEY } from '~/i18n/constants';
import { reverse } from '~/named-urls';
import { ROUTES } from '~/routes';
Expand All @@ -10,40 +11,65 @@ import styles from './WithoutInterview.module.scss';

type WithoutInterviewListProps = {
applications: RecruitmentApplicationDto[];
user: RecruitmentUserDto;
applicationsWithoutInterview: RecruitmentApplicationDto[];
};

export function WithoutInterviewList({ applications }: WithoutInterviewListProps) {
export function WithoutInterviewList({ applications, user, applicationsWithoutInterview }: WithoutInterviewListProps) {
const { t } = useTranslation();

const tableColumns = [
{ content: t(KEY.recruitment_position), sortable: true },

{ content: t(KEY.recruitment_interview_planned), sortable: true },
{ content: t(KEY.recruitment_priority), sortable: true },
];

function applicationToRow(application: RecruitmentApplicationDto) {
const hasInterview = !applicationsWithoutInterview.some((app) => app.id === application.id);

return {
cells: [
{
value: dbT(application.recruitment_position, 'name'),
content: (
<Link
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
pattern: ROUTES.frontend.admin_recruitment_gang_position_applicants_overview,
urlParams: {
applicationID: application.id,
recruitmentId: application.recruitment,
gangId: application.recruitment_position.gang.id,
positionId: application.recruitment_position.id,
},
})}
>
{dbT(application.recruitment_position, 'name')}
</Link>
),
},

{
value: hasInterview ? 1 : 0,
content: (
<Icon
icon={
hasInterview
? 'material-symbols:check-circle-outline-rounded'
: 'material-symbols:close-small-outline-rounded'
}
/>
),
},
application.applicant_priority,
],
};
}

return (
<div className={styles.container}>
<Text size="l">
{user.first_name} {user.last_name}
</Text>
<Table columns={tableColumns} data={applications.map((application) => applicationToRow(application))} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { useState } from 'react';
import { Button, IconButton, Modal } from '~/Components';
import type { RecruitmentApplicationDto } from '~/dto';
import type { RecruitmentApplicationDto, RecruitmentUserDto } from '~/dto';
import styles from './WithoutInterview.module.scss';
import { WithoutInterviewList } from './WithoutInterviewList';

type WithoutInterviewModalProps = {
user: RecruitmentUserDto;
applications: RecruitmentApplicationDto[];
applications_without_interview: RecruitmentApplicationDto[];
applicationsWithoutInterview: RecruitmentApplicationDto[];
};

export function WithoutInterviewModal({ applications, applications_without_interview }: WithoutInterviewModalProps) {
export function WithoutInterviewModal({
applications,
applicationsWithoutInterview,
user,
}: WithoutInterviewModalProps) {
const [withoutInterviewModal, setWithoutInterviewModal] = useState(false);

return (
<>
<Button theme="text" onClick={() => setWithoutInterviewModal(true)}>
{applications.length - applications_without_interview.length} / {applications.length}
<Button theme="outlined" display="pill" onClick={() => setWithoutInterviewModal(true)}>
{applications.length - applicationsWithoutInterview.length} / {applications.length}
</Button>
<Modal isOpen={withoutInterviewModal}>
<IconButton
Expand All @@ -24,7 +29,12 @@ export function WithoutInterviewModal({ applications, applications_without_inter
icon="mdi:close"
onClick={() => setWithoutInterviewModal(false)}
/>
<WithoutInterviewList applications={applications_without_interview} />

<WithoutInterviewList
applicationsWithoutInterview={applicationsWithoutInterview}
user={user}
applications={applications}
/>
</Modal>
</>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export const KEY = {
recruitment_interviewer: 'recruitment_interviewer',
recruitment_interviewers: 'recruitment_interviewers',
recruitment_interviews: 'recruitment_interviews',
recruitment_interview_planned: 'recruitment_interview_planned',
recruitment_no_interviews: 'recruitment_no_interviews',
recruitment_interview_set: 'recruitment_interview_set',
recruitment_interview_groups: 'recruitment_interview_groups',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export const nb = prepareTranslations({
[KEY.recruitment_not_applied]: 'Du har ikke sendt søknader til noen stillinger ennå',
[KEY.recruitment_will_be_anonymized]: 'All info relatert til dine søknader vil bli slettet 3 uker etter opptaket',
[KEY.recruitment_interviews]: 'Intervjuer',
[KEY.recruitment_interview_planned]: 'Intervjuer planlagt',
[KEY.recruitment_interviewer]: 'Intervjuer',
[KEY.recruitment_interviewers]: 'Intervjuere',
[KEY.recruitment_no_interviews]: 'Ingen intervjuer',
Expand Down Expand Up @@ -747,6 +748,7 @@ export const en = prepareTranslations({
[KEY.recruitment_will_be_anonymized]:
'All info related to the applications will be anonymized three weeks after the recruitment is over',
[KEY.recruitment_interviews]: 'Interviews',
[KEY.recruitment_interview_planned]: 'Interviews planned',
[KEY.recruitment_interviewer]: 'Interviewer',
[KEY.recruitment_interviewers]: 'Interviewers',
[KEY.recruitment_no_interviews]: 'No interviews',
Expand Down

0 comments on commit 0f8b303

Please sign in to comment.