Skip to content

Commit

Permalink
VKT(Frontend): Enrollment appointment contact form continues
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Oct 18, 2024
1 parent 630c6c0 commit 1877df5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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]);

Expand All @@ -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);
}
Expand All @@ -85,7 +80,7 @@ export const PublicEnrollmentContactControlButtons = ({
color={Color.Secondary}
onClick={handleCancelBtnClick}
data-testid="public-enrollment__controlButtons__cancel"
disabled={isPaymentLoading}
disabled={isSubmitLoading}
>
{translateCommon('cancel')}
</CustomButton>
Expand All @@ -101,7 +96,7 @@ export const PublicEnrollmentContactControlButtons = ({
startIcon={<ArrowBackIcon />}
disabled={
activeStep == PublicEnrollmentContactFormStep.FillContactDetails ||
isPaymentLoading
isSubmitLoading
}
>
{translateCommon('back')}
Expand All @@ -115,7 +110,7 @@ export const PublicEnrollmentContactControlButtons = ({
onClick={handleNextBtnClick}
data-testid="public-enrollment__controlButtons__next"
endIcon={<ArrowForwardIcon />}
disabled={isPaymentLoading}
disabled={isSubmitLoading}
>
{translateCommon('next')}
</CustomButton>
Expand All @@ -131,7 +126,7 @@ export const PublicEnrollmentContactControlButtons = ({
color={Color.Secondary}
onClick={handleSubmitBtnClick}
data-testid="public-enrollment__controlButtons__submit"
disabled={isPaymentLoading}
disabled={isSubmitLoading}
>
{t('submit')}
</CustomButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,21 @@ const PublicExaminerListingHeader = () => {
};

const DesktopExaminerRow = ({
id,
name,
language,
municipalities,
examDates,
}: Omit<PublicExaminer, 'id'>) => {
}: 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 (
<TableRow sx={{ verticalAlign: 'text-top' }}>
Expand Down Expand Up @@ -98,7 +103,7 @@ const DesktopExaminerRow = ({
<CustomButtonLink
color={Color.Secondary}
variant={Variant.Outlined}
to={AppRoutes.PublicEnrollmentContactContactDetails}
to={contactRoute}
>
Ota yhteyttä
</CustomButtonLink>
Expand All @@ -108,6 +113,7 @@ const DesktopExaminerRow = ({
};

const getRowDetails = ({
id,
name,
language,
municipalities,
Expand All @@ -119,6 +125,7 @@ const getRowDetails = ({
language={language}
municipalities={municipalities}
examDates={examDates}
id={id}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/vkt/src/enums/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 1877df5

Please sign in to comment.