From 3c9f292353ceb0f2616eeb7aeb472265784c36ca Mon Sep 17 00:00:00 2001 From: Jarkko Pesonen <435495+jrkkp@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:35:51 +0200 Subject: [PATCH] VKT(Frontend & Backend): Examiner admin ui navigation fixes and some demo data --- backend/vkt/db/4_init.sql | 6 +++ .../clerkExamEvent/overview/TopControls.tsx | 9 +++-- .../listing/ExaminerEnrollmentListing.tsx | 13 ++----- .../listing/ExaminerEnrollmentListingRow.tsx | 19 +++++----- .../listing/ExaminerContactRequestListing.tsx | 9 ++++- .../overview/ExaminerExamEventDetails.tsx | 18 +-------- .../ClerkExamEventOverviewPageSkeleton.tsx | 3 +- frontend/packages/vkt/src/enums/app.ts | 5 +-- ...ClerkEnrollmentAppointmentOverviewPage.tsx | 9 +++++ .../ClerkEnrollmentContactRequestPage.tsx | 38 ++++++++----------- .../src/pages/ClerkExamEventOverviewPage.tsx | 2 +- .../ExaminerExamEventOverviewPage.tsx | 3 +- .../packages/vkt/src/routers/AppRouter.tsx | 32 ++++++++-------- 13 files changed, 83 insertions(+), 83 deletions(-) diff --git a/backend/vkt/db/4_init.sql b/backend/vkt/db/4_init.sql index 50bcefb49..86b9315d5 100644 --- a/backend/vkt/db/4_init.sql +++ b/backend/vkt/db/4_init.sql @@ -461,6 +461,12 @@ VALUES (2, 1, 1, 'Anneli', 'Annikkinen', '123c2089-83a8-4163-8180-d8b675ff5337', NOW() - INTERVAL '3 days', NOW() - INTERVAL '6 days'); +INSERT INTO payment(version, enrollment_id, amount, transaction_id, reference, payment_url, + payment_status, refunded_at, enrollment_appointment_id) +VALUES (2, null, 51400, '78b29334-a283-11ef-88a1-bf672bd574b1', '7676156682', + 'https://pay.paytrail.com/pay/78b29334-a283-11ef-88a1-bf672bd574b1', 'OK', + null, 3); + -- Insert enrollment appointment INSERT INTO enrollment_appointment(person_id, examiner_id, examiner_exam_event_id, skill_oral, skill_textual, skill_understanding, diff --git a/frontend/packages/vkt/src/components/clerkExamEvent/overview/TopControls.tsx b/frontend/packages/vkt/src/components/clerkExamEvent/overview/TopControls.tsx index 33144b3a0..1f2d62a75 100644 --- a/frontend/packages/vkt/src/components/clerkExamEvent/overview/TopControls.tsx +++ b/frontend/packages/vkt/src/components/clerkExamEvent/overview/TopControls.tsx @@ -4,15 +4,18 @@ import { CustomButtonLink } from 'shared/components'; import { Variant } from 'shared/enums'; import { useCommonTranslation } from 'configs/i18n'; -import { AppRoutes } from 'enums/app'; -export const TopControls: FC = () => { +interface TopControlsProps { + backTo: string; +} + +export const TopControls: FC = ({ backTo }) => { const translateCommon = useCommonTranslation(); return (
} diff --git a/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListing.tsx b/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListing.tsx index 97e6ad005..f8edd96ea 100644 --- a/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListing.tsx +++ b/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListing.tsx @@ -6,17 +6,11 @@ import { ClerkEnrollmentAppointment } from 'interfaces/clerkEnrollment'; interface ExaminerEnrollmentListingProps { enrollments: Array; - examEventId: number; } -const getRowDetailsWithExamEventId = (examEventId: number) => { +const getRowDetailsWithExamEventId = () => { const getRowDetails = (enrollment: ClerkEnrollmentAppointment) => { - return ( - - ); + return ; }; return getRowDetails; @@ -24,13 +18,12 @@ const getRowDetailsWithExamEventId = (examEventId: number) => { export const ExaminerEnrollmentListing = ({ enrollments, - examEventId, }: ExaminerEnrollmentListingProps) => ( } - getRowDetails={getRowDetailsWithExamEventId(examEventId)} + getRowDetails={getRowDetailsWithExamEventId()} size="small" stickyHeader /> diff --git a/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingRow.tsx b/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingRow.tsx index 59f937886..1b295de73 100644 --- a/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingRow.tsx +++ b/frontend/packages/vkt/src/components/examinerEnrollment/listing/ExaminerEnrollmentListingRow.tsx @@ -1,5 +1,5 @@ import { TableCell, TableRow } from '@mui/material'; -import { useNavigate } from 'react-router'; +import { useNavigate, useParams } from 'react-router'; import { Text } from 'shared/components'; import { useClerkTranslation } from 'configs/i18n'; @@ -26,16 +26,15 @@ function pick(object: T, keys: Array) { export const ExaminerEnrollmentListingRow = ({ enrollment, - examEventId, }: { enrollment: ClerkEnrollmentAppointment; - examEventId: number; }) => { // I18n const { t } = useClerkTranslation({ keyPrefix: 'vkt.component.clerkEnrollmentListing.row', }); const navigate = useNavigate(); + const params = useParams(); const getSelectedPartialExamsText = () => { const partialExams = pick(enrollment, [ @@ -56,12 +55,14 @@ export const ExaminerEnrollmentListingRow = ({ }; const onClick = () => { - navigate( - AppRoutes.ClerkEnrollmentOverviewPage.replace( - /:examEventId/, - `${examEventId}`, - ), - ); + if (params.oid && enrollment.id) { + navigate( + AppRoutes.ExaminerEnrollmentAppointmentPage.replace( + ':oid', + params.oid, + ).replace(/:enrollmentAppointmentId/, `${enrollment.id}`), + ); + } }; return ( diff --git a/frontend/packages/vkt/src/components/examinerExamEvent/listing/ExaminerContactRequestListing.tsx b/frontend/packages/vkt/src/components/examinerExamEvent/listing/ExaminerContactRequestListing.tsx index 9913be824..9f58cff18 100644 --- a/frontend/packages/vkt/src/components/examinerExamEvent/listing/ExaminerContactRequestListing.tsx +++ b/frontend/packages/vkt/src/components/examinerExamEvent/listing/ExaminerContactRequestListing.tsx @@ -1,5 +1,6 @@ import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { TableCell, TableHead, TableRow } from '@mui/material'; +import { useParams } from 'react-router'; import { CustomButtonLink, CustomTable, Text } from 'shared/components'; import { Color, Variant } from 'shared/enums'; @@ -25,6 +26,9 @@ const ExaminerContactRequestListingRow = ({ }: { contactRequest: ContactRequest; }) => { + const params = useParams(); + const oid = params.oid || ''; + return ( @@ -39,7 +43,10 @@ const ExaminerContactRequestListingRow = ({ variant={Variant.Text} color={Color.Secondary} endIcon={} - to={AppRoutes.ClerkEnrollmentContactRequestPage.replace( + to={AppRoutes.ExaminerEnrollmentContactRequestPage.replace( + ':oid', + oid, + ).replace( /:enrollmentContactRequestId/, contactRequest.id.toString(), )} diff --git a/frontend/packages/vkt/src/components/examinerExamEvent/overview/ExaminerExamEventDetails.tsx b/frontend/packages/vkt/src/components/examinerExamEvent/overview/ExaminerExamEventDetails.tsx index 431fb473b..9c121b7bd 100644 --- a/frontend/packages/vkt/src/components/examinerExamEvent/overview/ExaminerExamEventDetails.tsx +++ b/frontend/packages/vkt/src/components/examinerExamEvent/overview/ExaminerExamEventDetails.tsx @@ -18,7 +18,6 @@ import { DateTimeUtils } from 'utils/dateTime'; interface EnrollmentListProps { enrollments: Array; status: EnrollmentAppointmentStatus; - examEventId: number; } const enrollmentFilter = ( @@ -27,11 +26,7 @@ const enrollmentFilter = ( ): Array => enrollments.filter((e: ClerkEnrollmentAppointment) => e.status === status); -const EnrollmentList: FC = ({ - enrollments, - status, - examEventId, -}) => { +const EnrollmentList: FC = ({ enrollments, status }) => { const { t } = useClerkTranslation({ keyPrefix: 'vkt.component.clerkExamEventOverview.examEventListingHeader', }); @@ -46,10 +41,7 @@ const EnrollmentList: FC = ({ data-testid={`clerk-exam-event-overview-page__enrollment-list-${status}__header`} >{`${t(status)}: ${filteredEnrollments.length}`}
- +
)} @@ -119,34 +111,28 @@ export const ExaminerExamEventDetails = () => { ); diff --git a/frontend/packages/vkt/src/components/skeletons/ClerkExamEventOverviewPageSkeleton.tsx b/frontend/packages/vkt/src/components/skeletons/ClerkExamEventOverviewPageSkeleton.tsx index 2bddd8682..27ae8a2f8 100644 --- a/frontend/packages/vkt/src/components/skeletons/ClerkExamEventOverviewPageSkeleton.tsx +++ b/frontend/packages/vkt/src/components/skeletons/ClerkExamEventOverviewPageSkeleton.tsx @@ -3,12 +3,13 @@ import { SkeletonVariant } from 'shared/enums'; import { ClerkExamEventDetails } from 'components/clerkExamEvent/overview/ClerkExamEventDetails'; import { TopControls } from 'components/clerkExamEvent/overview/TopControls'; +import { AppRoutes } from 'enums/app'; export const ClerkExamEventOverviewPageSkeleton = () => { return ( <> - + { const dispatch = useAppDispatch(); const params = useParams(); + const backTo = enrollment?.examEvent?.id + ? AppRoutes.ExaminerExamEventPage.replace(':oid', params.oid || '').replace( + ':examEventId', + enrollment?.examEvent?.id, + ) + : AppRoutes.ExaminerHomePage.replace(':oid', params.oid || ''); useEffect(() => { if ( @@ -29,6 +37,7 @@ export const ClerkEnrollmentAppointmentOverviewPage: FC = () => { return ( +

{ - const translateCommon = useCommonTranslation(); - - return ( - } - className="color-secondary-dark" - data-testid="clerk-create-exam__back-btn" - > - {translateCommon('back')} - - ); -}; - export const ClerkEnrollmentContactRequestPage: FC = () => { const { status, createStatus, enrollment } = useAppSelector( clerkEnrollmentContactRequestSelector, @@ -64,16 +47,26 @@ export const ClerkEnrollmentContactRequestPage: FC = () => { useEffect(() => { if ( createStatus === APIResponseStatus.Success && - params.enrollmentContactRequestId + params.enrollmentContactRequestId && + params.oid ) { navigate( - AppRoutes.ClerkEnrollmentAppointmentPage.replace( + AppRoutes.ExaminerEnrollmentAppointmentPage.replace( + ':oid', + params.oid, + ).replace( ':enrollmentAppointmentId', params.enrollmentContactRequestId, ), ); } - }, [dispatch, navigate, params.enrollmentContactRequestId, createStatus]); + }, [ + dispatch, + navigate, + params.oid, + params.enrollmentContactRequestId, + createStatus, + ]); const isLoading = status === APIResponseStatus.InProgress; const isSavingDisabled = isLoading; @@ -110,6 +103,7 @@ export const ClerkEnrollmentContactRequestPage: FC = () => { const onSubmit = () => { dispatch(createClerkEnrollmentAppointment(enrollment.id)); }; + const backTo = AppRoutes.ExaminerHomePage.replace(':oid', params.oid || ''); return ( @@ -120,7 +114,7 @@ export const ClerkEnrollmentContactRequestPage: FC = () => { className="clerk-homepage__grid-container" >
- +

Yhteydenottopyyntö

diff --git a/frontend/packages/vkt/src/pages/ClerkExamEventOverviewPage.tsx b/frontend/packages/vkt/src/pages/ClerkExamEventOverviewPage.tsx index dfdcd5711..7c740be33 100644 --- a/frontend/packages/vkt/src/pages/ClerkExamEventOverviewPage.tsx +++ b/frontend/packages/vkt/src/pages/ClerkExamEventOverviewPage.tsx @@ -86,7 +86,7 @@ export const ClerkExamEventOverviewPage: FC = () => { ) : ( <> - + )} diff --git a/frontend/packages/vkt/src/pages/examiner/ExaminerExamEventOverviewPage.tsx b/frontend/packages/vkt/src/pages/examiner/ExaminerExamEventOverviewPage.tsx index 454b52b8e..8d1c71edd 100644 --- a/frontend/packages/vkt/src/pages/examiner/ExaminerExamEventOverviewPage.tsx +++ b/frontend/packages/vkt/src/pages/examiner/ExaminerExamEventOverviewPage.tsx @@ -81,6 +81,7 @@ export const ExaminerExamEventOverviewPage: FC = () => { translateCommon, )} ${DateUtils.formatOptionalDate(examEvent.date)}` : ''; + const backTo = AppRoutes.ExaminerHomePage.replace(':oid', params.oid || ''); return ( @@ -93,7 +94,7 @@ export const ExaminerExamEventOverviewPage: FC = () => { ) : ( <> - + )} diff --git a/frontend/packages/vkt/src/routers/AppRouter.tsx b/frontend/packages/vkt/src/routers/AppRouter.tsx index 045b3a3ce..195633405 100644 --- a/frontend/packages/vkt/src/routers/AppRouter.tsx +++ b/frontend/packages/vkt/src/routers/AppRouter.tsx @@ -352,22 +352,6 @@ export const AppRouter: FC = () => { } /> - - - - } - /> - - - - } - /> { } /> + + + + } + /> + + + + } + />