From 1877df53a47ec42ddc4e50c4f517abc662564a88 Mon Sep 17 00:00:00 2001
From: Jarkko Pesonen <435495+jrkkp@users.noreply.github.com>
Date: Fri, 18 Oct 2024 09:42:05 +0300
Subject: [PATCH] VKT(Frontend): Enrollment appointment contact form continues
---
.../PublicEnrollmentContactControlButtons.tsx | 25 ++++++++-----------
.../PublicExaminerListing.tsx | 11 ++++++--
frontend/packages/vkt/src/enums/api.ts | 1 +
.../redux/sagas/publicEnrollmentContact.ts | 2 +-
4 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx b/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx
index 46a04a45f..cd07a9a0d 100644
--- a/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx
+++ b/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx
@@ -12,7 +12,9 @@ import { useAppDispatch } from 'configs/redux';
import { PublicEnrollmentContactFormStep } from 'enums/publicEnrollment';
import { PublicEnrollmentContact } from 'interfaces/publicEnrollment';
import { setLoadingPayment } from 'redux/reducers/publicEnrollmentAppointment';
+import { loadPublicEnrollmentSave } from 'redux/reducers/publicEnrollmentContact';
import { RouteUtils } from 'utils/routes';
+import { AppRoutes } from 'enums/app';
export const PublicEnrollmentContactControlButtons = ({
activeStep,
@@ -31,7 +33,7 @@ export const PublicEnrollmentContactControlButtons = ({
keyPrefix: 'vkt.component.publicEnrollment.controlButtons',
});
const translateCommon = useCommonTranslation();
- const [isPaymentLoading, setIsPaymentLoading] = useState(false);
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
const dispatch = useAppDispatch();
const navigate = useNavigate();
@@ -42,14 +44,7 @@ export const PublicEnrollmentContactControlButtons = ({
useEffect(() => {
if (submitStatus === APIResponseStatus.Success) {
- // Safari needs time to re-render loading indicator
- setTimeout(() => {
- window.location.href = RouteUtils.getPaymentCreateApiRoute(
- 'appointment',
- enrollment.id,
- );
- }, 200);
- dispatch(setLoadingPayment());
+ navigate(AppRoutes.PublicGoodAndSatisfactoryLevelLanding);
}
}, [submitStatus, enrollment.id, dispatch]);
@@ -70,9 +65,9 @@ export const PublicEnrollmentContactControlButtons = ({
const handleSubmitBtnClick = () => {
if (isStepValid) {
- setIsPaymentLoading(true);
+ setIsSubmitLoading(true);
setShowValidation(false);
- //dispatch(loadPublicEnrollmentSave(enrollment));
+ dispatch(loadPublicEnrollmentSave(enrollment));
} else {
setShowValidation(true);
}
@@ -85,7 +80,7 @@ export const PublicEnrollmentContactControlButtons = ({
color={Color.Secondary}
onClick={handleCancelBtnClick}
data-testid="public-enrollment__controlButtons__cancel"
- disabled={isPaymentLoading}
+ disabled={isSubmitLoading}
>
{translateCommon('cancel')}
@@ -101,7 +96,7 @@ export const PublicEnrollmentContactControlButtons = ({
startIcon={}
disabled={
activeStep == PublicEnrollmentContactFormStep.FillContactDetails ||
- isPaymentLoading
+ isSubmitLoading
}
>
{translateCommon('back')}
@@ -115,7 +110,7 @@ export const PublicEnrollmentContactControlButtons = ({
onClick={handleNextBtnClick}
data-testid="public-enrollment__controlButtons__next"
endIcon={}
- disabled={isPaymentLoading}
+ disabled={isSubmitLoading}
>
{translateCommon('next')}
@@ -131,7 +126,7 @@ export const PublicEnrollmentContactControlButtons = ({
color={Color.Secondary}
onClick={handleSubmitBtnClick}
data-testid="public-enrollment__controlButtons__submit"
- disabled={isPaymentLoading}
+ disabled={isSubmitLoading}
>
{t('submit')}
diff --git a/frontend/packages/vkt/src/components/publicExaminerListing/PublicExaminerListing.tsx b/frontend/packages/vkt/src/components/publicExaminerListing/PublicExaminerListing.tsx
index b59b40c71..a61e3eca7 100644
--- a/frontend/packages/vkt/src/components/publicExaminerListing/PublicExaminerListing.tsx
+++ b/frontend/packages/vkt/src/components/publicExaminerListing/PublicExaminerListing.tsx
@@ -52,16 +52,21 @@ const PublicExaminerListingHeader = () => {
};
const DesktopExaminerRow = ({
+ id,
name,
language,
municipalities,
examDates,
-}: Omit) => {
+}: PublicExaminer) => {
// TODO Rendering for mobile users
const { t } = usePublicTranslation({
keyPrefix: 'vkt.component.publicExaminerListing',
});
const appLanguage = getCurrentLang();
+ const contactRoute = AppRoutes.PublicEnrollmentContactContactDetails.replace(
+ ':examinerId',
+ id.toString(),
+ );
return (
@@ -98,7 +103,7 @@ const DesktopExaminerRow = ({
Ota yhteyttä
@@ -108,6 +113,7 @@ const DesktopExaminerRow = ({
};
const getRowDetails = ({
+ id,
name,
language,
municipalities,
@@ -119,6 +125,7 @@ const getRowDetails = ({
language={language}
municipalities={municipalities}
examDates={examDates}
+ id={id}
/>
);
};
diff --git a/frontend/packages/vkt/src/enums/api.ts b/frontend/packages/vkt/src/enums/api.ts
index f4ffc86b1..d64f74551 100644
--- a/frontend/packages/vkt/src/enums/api.ts
+++ b/frontend/packages/vkt/src/enums/api.ts
@@ -3,6 +3,7 @@ export enum APIEndpoints {
PublicAuthLogout = '/vkt/api/v1/auth/logout',
PublicExamEvent = '/vkt/api/v1/examEvent',
PublicEnrollmentAppointment = '/vkt/api/v1/enrollment/appointment',
+ PublicEnrollmentContact = '/vkt/api/v1/enrollment/contact-request',
PublicExaminer = '/vkt/api/v1/examiner',
PublicEnrollment = '/vkt/api/v1/enrollment',
PublicReservation = '/vkt/api/v1/reservation',
diff --git a/frontend/packages/vkt/src/redux/sagas/publicEnrollmentContact.ts b/frontend/packages/vkt/src/redux/sagas/publicEnrollmentContact.ts
index fe5195d0b..f90a078b3 100644
--- a/frontend/packages/vkt/src/redux/sagas/publicEnrollmentContact.ts
+++ b/frontend/packages/vkt/src/redux/sagas/publicEnrollmentContact.ts
@@ -48,7 +48,7 @@ function* loadPublicEnrollmentSaveSaga(
try {
const { id: _unused2, status: _unused5, ...body } = enrollment;
- const saveUrl = `${APIEndpoints.PublicEnrollmentAppointment}/${enrollment.id}`;
+ const saveUrl = `${APIEndpoints.PublicEnrollmentContact}/${enrollment.id}`;
yield call(axiosInstance.post, saveUrl, body);