diff --git a/bciers/apps/administration/app/data/jsonSchema/operationInformation/registrationInformation.ts b/bciers/apps/administration/app/data/jsonSchema/operationInformation/registrationInformation.ts deleted file mode 100644 index 772cf43643..0000000000 --- a/bciers/apps/administration/app/data/jsonSchema/operationInformation/registrationInformation.ts +++ /dev/null @@ -1,81 +0,0 @@ -import SectionFieldTemplate from "@bciers/components/form/fields/SectionFieldTemplate"; -import { RJSFSchema, UiSchema } from "@rjsf/utils"; -import { - getRegistrationPurposes, - getRegulatedProducts, -} from "@bciers/actions/api"; -import { RegistrationPurposes } from "apps/registration/app/components/operations/registration/enums"; - -export const createRegistrationInformationSchema = - async (): Promise => { - // fetch db values that are dropdown options - const regulatedProducts: { id: number; name: string }[] = - await getRegulatedProducts(); - const registrationPurposes = await getRegistrationPurposes(); - - // create the schema with the fetched values - const registrationInformationSchema: RJSFSchema = { - title: "Registration Information", - type: "object", - required: ["registration_purpose", "operation"], - properties: { - registration_purpose: { - type: "string", - title: "The purpose of this registration is to register as a:", - anyOf: registrationPurposes.map((purpose: string) => ({ - const: purpose, - title: purpose, - })), - }, - }, - dependencies: { - registration_purpose: { - oneOf: registrationPurposes.map((purpose: string) => { - return { - required: ["regulated_products"], - properties: { - registration_purpose: { - type: "string", - const: purpose, - }, - ...(purpose !== - RegistrationPurposes.ELECTRICITY_IMPORT_OPERATION && - purpose !== - RegistrationPurposes.POTENTIAL_REPORTING_OPERATION && { - regulated_products: { - title: "Regulated Product Name(s)", - type: "array", - minItems: 1, - items: { - enum: regulatedProducts.map((product) => product.id), - enumNames: regulatedProducts.map( - (product) => product.name, - ), - }, - }, - }), - }, - }; - }), - }, - }, - }; - return registrationInformationSchema; - }; - -export const registrationInformationUiSchema: UiSchema = { - "ui:order": [ - "registration_purpose", - "regulated_operation", - "new_entrant_operation", - "regulated_products", - ], - "ui:FieldTemplate": SectionFieldTemplate, - registration_purpose: { - "ui:widget": "MultiSelectWidget", - }, - regulated_products: { - "ui:widget": "MultiSelectWidget", - "ui:placeholder": "Select Regulated Product", - }, -}; diff --git a/bciers/apps/registration/app/components/operations/registration/ChangeRegistrationPurposeModal.tsx b/bciers/apps/registration/app/components/operations/registration/ChangeRegistrationPurposeModal.tsx deleted file mode 100644 index 1685583d55..0000000000 --- a/bciers/apps/registration/app/components/operations/registration/ChangeRegistrationPurposeModal.tsx +++ /dev/null @@ -1,74 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { Box, Button } from "@mui/material"; -import Modal from "@bciers/components/modal/Modal"; -import React from "react"; - -const ChangeRegistrationPurposeModal = () => { - const [modalState, setModalState] = useState("" as string); - - const resetFormData = () => { - return; - }; - - const handleCloseModal = () => { - setModalState(""); - }; - const handleConfirmChange = () => { - resetFormData(); - setModalState(""); - return; - }; - - return ( - - - - Are you sure you want to change your registration purpose? If you - proceed, all of the form data you have entered will be lost. - - - - - - - - ); -}; - -export default ChangeRegistrationPurposeModal; diff --git a/bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx b/bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx index 8af2c1d981..5014d09910 100644 --- a/bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx +++ b/bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx @@ -17,7 +17,6 @@ import { RegistrationPurposeHelpText, RegistrationPurposes, } from "@/registration/app/components/operations/registration/enums"; -import ChangeRegistrationPurposeModal from "@/registration/app/components/operations/registration/ChangeRegistrationPurposeModal"; interface OperationInformationFormProps { rawFormData: OperationInformationFormData; @@ -130,32 +129,26 @@ const OperationInformationForm = ({ }; return ( - <> - - { - let newSelectedOperation = e.formData?.section1?.operation; - let newSelectedPurpose = e.formData?.section1?.registration_purpose; - if ( - newSelectedOperation && - newSelectedOperation !== selectedOperation - ) - handleSelectOperationChange(e.formData); - if (newSelectedPurpose !== selectedPurpose) - handleSelectedPurposeChange(e.formData); - }} - uiSchema={currentUiSchema} - customValidate={customValidate} - /> - + { + let newSelectedOperation = e.formData?.section1?.operation; + let newSelectedPurpose = e.formData?.section1?.registration_purpose; + if (newSelectedOperation && newSelectedOperation !== selectedOperation) + handleSelectOperationChange(e.formData); + if (newSelectedPurpose !== selectedPurpose) + handleSelectedPurposeChange(e.formData); + }} + uiSchema={currentUiSchema} + customValidate={customValidate} + /> ); }; diff --git a/bciers/apps/registration/app/components/operations/registration/OperationInformationPage.tsx b/bciers/apps/registration/app/components/operations/registration/OperationInformationPage.tsx index b64c83f63e..1a7195f6f0 100644 --- a/bciers/apps/registration/app/components/operations/registration/OperationInformationPage.tsx +++ b/bciers/apps/registration/app/components/operations/registration/OperationInformationPage.tsx @@ -4,7 +4,6 @@ import OperationInformationForm from "apps/registration/app/components/operation import { UUID } from "crypto"; import { validate as isValidUUID } from "uuid"; import { OperationInformationFormData } from "./types"; -import Modal from "@/libs/components/src/modal"; const OperationInformationPage = async ({ step, @@ -24,7 +23,7 @@ const OperationInformationPage = async ({ throw new Error("Failed to fetch operation data"); return (