Skip to content

Commit 4735cb1

Browse files
Chore: in progress
1 parent fc667b4 commit 4735cb1

File tree

4 files changed

+105
-21
lines changed

4 files changed

+105
-21
lines changed

bciers/apps/administration/app/data/jsonSchema/operationInformation/administrationRegistrationInformation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const registrationInformationUiSchema: UiSchema = {
120120
"ui:classNames": "text-bc-bg-blue text-lg",
121121
"ui:FieldTemplate": TitleOnlyFieldTemplate,
122122
"ui:title": "Regulated Operation",
123+
},
123124
registration_purpose: {
124125
"ui:widget": "ComboBox",
125126
},

bciers/apps/administration/app/data/jsonSchema/operationInformation/registrationInformation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const createRegistrationInformationSchema =
2828
})),
2929
},
3030
},
31-
3231
dependencies: {
3332
registration_purpose: {
3433
oneOf: registrationPurposes.map((purpose: string) => {
@@ -72,6 +71,9 @@ export const registrationInformationUiSchema: UiSchema = {
7271
"regulated_products",
7372
],
7473
"ui:FieldTemplate": SectionFieldTemplate,
74+
registration_purpose: {
75+
"ui:widget": "MultiSelectWidget",
76+
},
7577
regulated_products: {
7678
"ui:widget": "MultiSelectWidget",
7779
"ui:placeholder": "Select Regulated Product",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"use client";
2+
3+
import { useState } from "react";
4+
import { Box, Button } from "@mui/material";
5+
import Modal from "@bciers/components/modal/Modal";
6+
import React from "react";
7+
8+
const ChangeRegistrationPurposeModal = () => {
9+
const [modalState, setModalState] = useState("" as string);
10+
11+
const resetFormData = () => {
12+
return;
13+
};
14+
15+
const handleCloseModal = () => {
16+
setModalState("");
17+
};
18+
const handleConfirmChange = () => {
19+
resetFormData();
20+
setModalState("");
21+
return;
22+
};
23+
24+
return (
25+
<Box>
26+
<Modal
27+
title="Confirmation"
28+
open={Boolean(modalState)}
29+
onClose={handleCloseModal}
30+
>
31+
<Box
32+
sx={{
33+
fontSize: "20px",
34+
minWidth: "100%",
35+
margin: "8px 0",
36+
}}
37+
>
38+
Are you sure you want to change your registration purpose? If you
39+
proceed, all of the form data you have entered will be lost.
40+
</Box>
41+
<Box
42+
sx={{
43+
width: "100%",
44+
display: "flex",
45+
flexDirection: "row",
46+
justifyContent: "center",
47+
alignItems: "center",
48+
marginTop: "24px",
49+
}}
50+
>
51+
<Button
52+
onClick={handleCloseModal}
53+
color="secondary"
54+
variant="contained"
55+
aria-label="Cancel"
56+
sx={{ marginRight: "12px" }}
57+
>
58+
Cancel
59+
</Button>
60+
<Button
61+
onClick={handleConfirmChange}
62+
color="primary"
63+
variant="contained"
64+
aria-label="Confirm"
65+
>
66+
Change registration purpose
67+
</Button>
68+
</Box>
69+
</Modal>
70+
</Box>
71+
);
72+
};
73+
74+
export default ChangeRegistrationPurposeModal;

bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
RegistrationPurposeHelpText,
1818
RegistrationPurposes,
1919
} from "@/registration/app/components/operations/registration/enums";
20+
import ChangeRegistrationPurposeModal from "@/registration/app/components/operations/registration/ChangeRegistrationPurposeModal";
2021

2122
interface OperationInformationFormProps {
2223
rawFormData: OperationInformationFormData;
@@ -129,26 +130,32 @@ const OperationInformationForm = ({
129130
};
130131

131132
return (
132-
<MultiStepBase
133-
key={key}
134-
cancelUrl="/"
135-
formData={formState}
136-
onSubmit={handleSubmit}
137-
schema={schema}
138-
step={step}
139-
steps={steps}
140-
error={error}
141-
onChange={(e: IChangeEvent) => {
142-
let newSelectedOperation = e.formData?.section1?.operation;
143-
let newSelectedPurpose = e.formData?.section1?.registration_purpose;
144-
if (newSelectedOperation && newSelectedOperation !== selectedOperation)
145-
handleSelectOperationChange(e.formData);
146-
if (newSelectedPurpose !== selectedPurpose)
147-
handleSelectedPurposeChange(e.formData);
148-
}}
149-
uiSchema={currentUiSchema}
150-
customValidate={customValidate}
151-
/>
133+
<>
134+
<ChangeRegistrationPurposeModal />
135+
<MultiStepBase
136+
key={key}
137+
cancelUrl="/"
138+
formData={formState}
139+
onSubmit={handleSubmit}
140+
schema={schema}
141+
step={step}
142+
steps={steps}
143+
error={error}
144+
onChange={(e: IChangeEvent) => {
145+
let newSelectedOperation = e.formData?.section1?.operation;
146+
let newSelectedPurpose = e.formData?.section1?.registration_purpose;
147+
if (
148+
newSelectedOperation &&
149+
newSelectedOperation !== selectedOperation
150+
)
151+
handleSelectOperationChange(e.formData);
152+
if (newSelectedPurpose !== selectedPurpose)
153+
handleSelectedPurposeChange(e.formData);
154+
}}
155+
uiSchema={currentUiSchema}
156+
customValidate={customValidate}
157+
/>
158+
</>
152159
);
153160
};
154161

0 commit comments

Comments
 (0)