-
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.
- Loading branch information
Showing
8 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
frontend/src/PagesAdmin/RoomAdminPage/CreateInterviewRoomPage/CreateInterviewRoomPage.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,41 @@ | ||
import { useRouteLoaderData } from 'react-router-dom'; | ||
import { toast } from 'react-toastify'; | ||
import { SamfForm } from '~/Forms/SamfForm'; | ||
import { SamfFormField } from '~/Forms/SamfFormField'; | ||
import { postInterviewRoom } from '~/api'; | ||
import type { InterviewRoomDto } from '~/dto'; | ||
import { useCustomNavigate } from '~/hooks'; | ||
import type { RecruitmentLoader } from '~/router/loaders'; | ||
import { ROUTES } from '~/routes'; | ||
|
||
export function CreateInterviewRoomPage() { | ||
const data = useRouteLoaderData('recruitment') as RecruitmentLoader | undefined; | ||
const navigation = useCustomNavigate(); | ||
if (!data?.recruitment?.id) { | ||
return <p>No recruitment id found</p>; | ||
} | ||
|
||
const initialData: Partial<InterviewRoomDto> = { | ||
recruitment: Number(data.recruitment.id), | ||
}; | ||
// ROUTES.frontend.admin_recruitment_room_overview, { recruitmentId: data.recruitment } | ||
function handleSubmit(data: InterviewRoomDto) { | ||
try { | ||
postInterviewRoom(data).then(() => { | ||
toast.success('Interview room created'); | ||
navigation({ url: ROUTES.frontend.admin_recruitment_room_overview }); | ||
}); | ||
} catch (error) { | ||
toast.error('Failed to create interview room'); | ||
} | ||
} | ||
|
||
return ( | ||
<SamfForm<InterviewRoomDto> initialData={initialData} onSubmit={handleSubmit}> | ||
<SamfFormField type="text" field={'name'} /> | ||
<SamfFormField type="text" field={'location'} /> | ||
<SamfFormField type="date_time" field={'start_time'} /> | ||
<SamfFormField type="date_time" field={'end_time'} /> | ||
</SamfForm> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/PagesAdmin/RoomAdminPage/CreateInterviewRoomPage/index.ts
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 @@ | ||
export { CreateInterviewRoomPage } from './CreateInterviewRoomPage'; |
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { CreateInterviewRoomPage } from './CreateInterviewRoomPage'; | ||
export { RoomAdminPage } from './RoomAdminPage'; |
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
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
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
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