Skip to content

Commit

Permalink
Merge branch 'master' into 1430-added-column-for-interviewers-priorit…
Browse files Browse the repository at this point in the history
…y-of-applicant
  • Loading branch information
Snorre98 authored Nov 5, 2024
2 parents cbaecee + 24b97ca commit 434f203
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Table } from '~/Components/Table';
import type { RecruitmentUserDto } from '~/dto';
import { KEY } from '~/i18n/constants';
import { reverse } from '~/named-urls';
import { ROUTES } from '~/routes';
import { dbT } from '~/utils';
import { InputField } from '../InputField';
Expand Down Expand Up @@ -54,7 +55,19 @@ export function RecruitmentWithoutInterviewTable({ applicants }: RecruitmentWith
return [
{
value: `${user.first_name} ${user.last_name}`,
content: <Link url={ROUTES.frontend.recruitment_application}>{`${user.first_name} ${user.last_name}`}</Link>,
content: (
<Link
url={reverse({
pattern: ROUTES.frontend.admin_recruitment_applicant,
urlParams: {
applicationID: user.top_application.id,
},
})}
className={styles.text}
>
{user.first_name} {user.last_name}
</Link>
),
},
user.email,
user.phone_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function GangPosition({ type, recruitmentPositions }: GangItemProps) {
<Link
url={reverse({
pattern: ROUTES.frontend.recruitment_application,
urlParams: { positionId: pos.id, gangId: gang.id },
urlParams: { positionId: pos.id, recruitmentId: pos.recruitment },
})}
className={styles.position_short_desc}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import styles from './GangPositionDropdown.module.scss';

type GangItemProps = {
type: GangTypeDto;
recruitmentId?: string;
recruitmentPositions?: RecruitmentPositionDto[];
};

//TODO: DO IN ISSUE #1121, only get gang types recruiting from backend
// TODO: so the filtering should be done from the backend
export function GangPositionDropdown({ type, recruitmentPositions }: GangItemProps) {
export function GangPositionDropdown({ type, recruitmentPositions, recruitmentId }: GangItemProps) {
const filteredGangs = type.gangs
.map((gang) => {
const filteredPositions = recruitmentPositions?.filter((pos) => pos.gang.id === gang.id);
Expand All @@ -30,7 +31,7 @@ export function GangPositionDropdown({ type, recruitmentPositions }: GangItemPro
<Link
url={reverse({
pattern: ROUTES.frontend.recruitment_application,
urlParams: { positionId: pos.id, gangId: gang.id },
urlParams: { positionId: pos.id, recruitmentId: recruitmentId },
})}
className={styles.position_name}
>
Expand All @@ -39,7 +40,7 @@ export function GangPositionDropdown({ type, recruitmentPositions }: GangItemPro
<Link
url={reverse({
pattern: ROUTES.frontend.recruitment_application,
urlParams: { positionId: pos.id, gangId: gang.id },
urlParams: { positionId: pos.id, recruitmentId: recruitmentId },
})}
className={styles.position_short_desc}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { SamfundetLogoSpinner } from '~/Components';
import { getGangList, getRecruitmentPositions } from '~/api';
import type { GangTypeDto, RecruitmentPositionDto } from '~/dto';
import { GangPositionDropdown } from '../GangPositionDropdown';

type GangTypeContainerProps = {
recruitmentId: string;
};

export function GangTypeContainer({ recruitmentId = '-1' }: GangTypeContainerProps) {
export function GangTypeContainer() {
const [recruitmentPositions, setRecruitmentPositions] = useState<RecruitmentPositionDto[]>();
const [recruitingGangTypes, setRecruitingGangs] = useState<GangTypeDto[]>();
const [loading, setLoading] = useState<boolean>(true);

const { recruitmentId } = useParams();
useEffect(() => {
if (!recruitmentId) return;
Promise.all([getRecruitmentPositions(recruitmentId), getGangList()])
.then(([recruitmentRes, gangsRes]) => {
setRecruitmentPositions(recruitmentRes.data);
Expand All @@ -31,7 +29,12 @@ export function GangTypeContainer({ recruitmentId = '-1' }: GangTypeContainerPro
) : (
<>
{recruitingGangTypes?.map((gangType) => (
<GangPositionDropdown key={gangType.id} type={gangType} recruitmentPositions={recruitmentPositions} />
<GangPositionDropdown
key={gangType.id}
type={gangType}
recruitmentPositions={recruitmentPositions}
recruitmentId={recruitmentId}
/>
))}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export function PositionsTable({ currentSelectedGang, setLoading, loading }: Pos
const [positions, setPositions] = useState<RecruitmentPositionDto[]>([]);
const navigate = useNavigate();
const { t } = useTranslation();
const recruitmentId = useParams();
const { recruitmentId } = useParams();
const { organizationTheme } = useOrganizationContext();

useEffect(() => {
if (!currentSelectedGang || !recruitmentId.recruitmentId) {
if (!currentSelectedGang || !recruitmentId) {
return;
}
setLoading(true);
getRecruitmentPositionsGangForApplicant(recruitmentId.recruitmentId, currentSelectedGang.id)
getRecruitmentPositionsGangForApplicant(recruitmentId, currentSelectedGang.id)
.then((response) => {
setPositions(response.data);
setLoading(false);
Expand All @@ -48,7 +48,7 @@ export function PositionsTable({ currentSelectedGang, setLoading, loading }: Pos
const tableData = positions.map((item) => {
const positionPageURL = reverse({
pattern: ROUTES.frontend.recruitment_application,
urlParams: { positionId: item.id, gangId: item.id },
urlParams: { positionId: item.id, recruitmentId: recruitmentId },
});
return {
cells: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ export function OrganizationRecruitmentPage() {
<Text>Placeholder for tag-autocomplete search </Text>
{/*^^^ issue #1275 */}
</div>
{recruitmentId &&
(viewAllPositions ? <GangTypeContainer recruitmentId={recruitmentId} /> : <RecruitmentTabs />)}
{recruitmentId && (viewAllPositions ? <GangTypeContainer /> : <RecruitmentTabs />)}
{recruitment?.separate_positions && recruitment.separate_positions.length > 0 && (
<GangSeparatePositions recruitmentSeparatePositions={recruitment.separate_positions} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function RecruitmentApplicationFormPage() {

const [loading, setLoading] = useState(true);

const { positionId } = useParams();
const { positionId, recruitmentId } = useParams();

useTitle(recruitmentPosition ? (dbT(recruitmentPosition, 'name') as string) : '');

Expand Down Expand Up @@ -175,7 +175,7 @@ export function RecruitmentApplicationFormPage() {
navigate({
url: reverse({
pattern: ROUTES.frontend.recruitment_application,
urlParams: { positionId: pos.id, gangId: pos.gang.id },
urlParams: { positionId: pos.id, recruitmentId: recruitmentId },
}),
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function RecruitmentApplicationsOverviewPage() {
pattern: ROUTES.frontend.recruitment_application,
urlParams: {
positionId: application.recruitment_position.id,
gangId: application.recruitment_position.gang.id,
recruitmentId: recruitmentId,
},
})}
className={styles.position_name}
Expand Down Expand Up @@ -131,7 +131,7 @@ export function RecruitmentApplicationsOverviewPage() {
pattern: ROUTES.frontend.recruitment_application,
urlParams: {
positionId: application.recruitment_position.id,
gangId: application.recruitment_position.gang.id,
recruitmentId: recruitmentId,
},
})}
className={styles.withdrawnLink}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function RecruitmentGangAdminPage() {
pattern: ROUTES.frontend.recruitment_application,
urlParams: {
positionId: recruitmentPosition.id,
recruitmentId: recruitmentId,
},
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function RecruitmentRecruiterDashboardPage() {
pattern: ROUTES.frontend.recruitment_application,
urlParams: {
positionId: application.recruitment_position.id,
recruitmentId: recruitmentId,
},
})}
>
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 @@ -19,7 +19,7 @@ export const ROUTES_FRONTEND = {
contributors: '/contributors',
// Recruitment:
recruitment: '/recruitment/',
recruitment_application: '/recruitment/position/:positionId/',
recruitment_application: '/recruitment/:recruitmentId/position/:positionId/',
recruitment_application_overview: '/recruitment/:recruitmentId/my-applications/',
organization_recruitment: '/recruitment/:recruitmentId/',
contact: '/contact',
Expand Down

0 comments on commit 434f203

Please sign in to comment.