From b3d6f5bd0551cb113afcad3a36fe58a961408a13 Mon Sep 17 00:00:00 2001 From: Pyry Koivisto Date: Fri, 27 Dec 2024 16:20:34 +0200 Subject: [PATCH] VKT(Frontend): Confirmation dialog before cancelling enrollment, take updated DialogBox implmentation into use [deploy] --- frontend/packages/vkt/package.json | 2 +- .../vkt/public/i18n/fi-FI/public.json | 11 +++++++ .../PublicEnrollmentContactControlButtons.tsx | 33 ++++++++++++++----- frontend/yarn.lock | 11 ++----- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/frontend/packages/vkt/package.json b/frontend/packages/vkt/package.json index 33a96028e..f547cc34d 100644 --- a/frontend/packages/vkt/package.json +++ b/frontend/packages/vkt/package.json @@ -25,6 +25,6 @@ }, "dependencies": { "reduxjs-toolkit-persist": "^7.2.1", - "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.10" + "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.11" } } diff --git a/frontend/packages/vkt/public/i18n/fi-FI/public.json b/frontend/packages/vkt/public/i18n/fi-FI/public.json index 00bdcbc95..a3b9e5307 100644 --- a/frontend/packages/vkt/public/i18n/fi-FI/public.json +++ b/frontend/packages/vkt/public/i18n/fi-FI/public.json @@ -334,6 +334,17 @@ } }, "publicEnrollmentContact": { + "cancelDialog": { + "actions": { + "cancelEnrollment": "Peru ja valitse toinen vastaanottaja", + "continueEnrollment": "En halua perua" + }, + "description": { + "part1": "Haluatko perua tämän yhteydenoton?", + "part2": "Jo täyttämäsi tiedot tallentuvat selaimen muistiin. Jos haluat että ne pyyhitään pois, sulje selainikkuna." + }, + "title": "Peru yhteydenotto" + }, "controlButtons": { "submit": "Lähetä" }, diff --git a/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx b/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx index 6338411ec..b735079fa 100644 --- a/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx +++ b/frontend/packages/vkt/src/components/publicEnrollmentContact/PublicEnrollmentContactControlButtons.tsx @@ -25,10 +25,7 @@ import { PublicEnrollmentContact, PublicEnrollmentContactRequestDetails, } from 'interfaces/publicEnrollment'; -import { - loadPublicEnrollmentSave, - resetPublicEnrollmentContact, -} from 'redux/reducers/publicEnrollmentContact'; +import { loadPublicEnrollmentSave } from 'redux/reducers/publicEnrollmentContact'; import { publicEnrollmentContactSelector } from 'redux/selectors/publicEnrollmentContact'; import { RouteUtils } from 'utils/routes'; @@ -57,14 +54,34 @@ export const PublicEnrollmentContactControlButtons = ({ ); const dispatch = useAppDispatch(); const navigate = useNavigate(); + const { showDialog } = useDialog(); const handleCancelBtnClick = () => { - dispatch(resetPublicEnrollmentContact()); - navigate(AppRoutes.PublicGoodAndSatisfactoryLevelLanding); + showDialog({ + title: t('cancelDialog.title'), + content: ( +
+ {t('cancelDialog.description.part1')} + {t('cancelDialog.description.part2')} +
+ ), + severity: Severity.Info, + actions: [ + { + title: t('cancelDialog.actions.cancelEnrollment'), + variant: Variant.Outlined, + action: () => + navigate(AppRoutes.PublicGoodAndSatisfactoryLevelLanding), + }, + { + title: t('cancelDialog.actions.continueEnrollment'), + variant: Variant.Contained, + }, + ], + paperClassName: 'align-items-start', + }); }; - const { showDialog } = useDialog(); - useEffect(() => { if (submitStatus === APIResponseStatus.Success) { navigate( diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 177023652..e1fee4071 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -2690,7 +2690,7 @@ __metadata: languageName: unknown linkType: soft -"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared": +"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared, shared@npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.11": version: 0.0.0-use.local resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared" languageName: unknown @@ -2701,7 +2701,7 @@ __metadata: resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.vkt@workspace:packages/vkt" dependencies: reduxjs-toolkit-persist: "npm:^7.2.1" - shared: "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.10" + shared: "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.11" languageName: unknown linkType: soft @@ -11890,13 +11890,6 @@ __metadata: languageName: node linkType: hard -"shared@npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.10": - version: 1.11.10 - resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@npm:1.11.10::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40Opetushallitus%2Fkieli-ja-kaantajatutkinnot.shared%2F1.11.10%2F80621fbbafc123d0cb5d80861674ec557227ba56" - checksum: 37b17f5dc92ea93b4c3bd3cbda9bb19468c697cdc25ab1050788485307ceb87ae0a0472c66e21c02c47ae015989e6b2705d6b120d5259152c3f0866d5b84fd77 - languageName: node - linkType: hard - "shared@npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.11.4": version: 1.11.4 resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@npm:1.11.4::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40Opetushallitus%2Fkieli-ja-kaantajatutkinnot.shared%2F1.11.4%2Fe764b4b5403ca44fd6300537e31b30d03a371525"