From a2be7893d39ab861c5f45d3165d117db471d2069 Mon Sep 17 00:00:00 2001 From: Nitheesh T Ganesh Date: Tue, 31 Dec 2024 12:11:40 -0700 Subject: [PATCH 1/3] COMP-303: Create Inspection Requirement - bug fixes --- .../components/App/Complaints/ComplaintFormUtils.ts | 2 +- .../App/Inspections/Profile/InspectionFileTabs.tsx | 8 ++++---- .../Profile/Requirements/RequirementDrawer.tsx | 13 +++---------- .../Profile/Requirements/RequirementSourceCard.tsx | 11 ++++++++--- compliance-web/src/styles/quill.scss | 10 ++++++++++ 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/compliance-web/src/components/App/Complaints/ComplaintFormUtils.ts b/compliance-web/src/components/App/Complaints/ComplaintFormUtils.ts index c7a8b64..9482560 100644 --- a/compliance-web/src/components/App/Complaints/ComplaintFormUtils.ts +++ b/compliance-web/src/components/App/Complaints/ComplaintFormUtils.ts @@ -149,7 +149,7 @@ export const formatComplaintData = ( case RequirementSourceEnum.NOT_EA_ACT: case RequirementSourceEnum.OTHER: complaintData.requirement_source_details.description = - formData.description; + formData.description ?? ""; break; case RequirementSourceEnum.ACT2018: case RequirementSourceEnum.ACT2022: diff --git a/compliance-web/src/components/App/Inspections/Profile/InspectionFileTabs.tsx b/compliance-web/src/components/App/Inspections/Profile/InspectionFileTabs.tsx index 1fb0d95..658949c 100644 --- a/compliance-web/src/components/App/Inspections/Profile/InspectionFileTabs.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/InspectionFileTabs.tsx @@ -40,10 +40,10 @@ const InspectionFileTabs: React.FC = () => { "&:first-of-type": { paddingLeft: "0", }, - }, - "& .Mui-selected": { - color: BCDesignTokens.typographyColorPrimary, - fontWeight: BCDesignTokens.typographyFontWeightsBold, + "&.Mui-selected": { + color: BCDesignTokens.typographyColorPrimary, + fontWeight: BCDesignTokens.typographyFontWeightsBold, + }, }, }} > diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementDrawer.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementDrawer.tsx index 569b061..4e4255a 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementDrawer.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementDrawer.tsx @@ -25,16 +25,9 @@ type RequirementDrawerProps = { const RequirementFormSchema = yup.object().shape({ requirementSummary: yup.string().nullable(), - topic: yup.object().nullable().required("Primary is required"), - complianceFinding: yup - .object() - .nullable() - .required("Compliance Finding is required"), - enforcementAction: yup - .array() - .of(yup.object()) - .min(1, "At least one Enforcement Action is required") - .required("Enforcement Action is required"), + topic: yup.object().nullable().required("Topic is required"), + complianceFinding: yup.object().nullable(), + enforcementAction: yup.array().of(yup.object()).nullable(), findings: yup .object({ html: yup.string().required("Entry is required"), diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx index 0cf916d..4c8115c 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx @@ -161,9 +161,14 @@ const RequirementSourceCard: FC = memo( - {data.description?.text} - + } /> diff --git a/compliance-web/src/styles/quill.scss b/compliance-web/src/styles/quill.scss index 3c2ded6..8995591 100644 --- a/compliance-web/src/styles/quill.scss +++ b/compliance-web/src/styles/quill.scss @@ -27,4 +27,14 @@ p { margin: 0; } + a { + margin: 0; + -webkit-text-decoration: none; + text-decoration: none; + color: #255a90; + &:hover { + -webkit-text-decoration: underline; + text-decoration: underline; + } + } } From d83439a3dea798d467887f9fea5856a8462dc353 Mon Sep 17 00:00:00 2001 From: Nitheesh T Ganesh Date: Thu, 2 Jan 2025 15:20:18 -0700 Subject: [PATCH 2/3] COMP-272: Edit Requirement Source --- .../Requirements/RequirementFormRight.tsx | 38 ++++++++++++++++--- .../Requirements/RequirementSourceCard.tsx | 9 ++++- .../Requirements/RequirementSourceModal.tsx | 29 +++++++++++--- .../src/models/InspectionRequirement.ts | 1 + 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx index 01be96e..b53cc1d 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx @@ -12,16 +12,37 @@ const RequirementFormRight: FC = () => { RequirementSourceFormData[] >([]); - const handleOnSubmit = (data: RequirementSourceFormData) => { - setClose(); - // eslint-disable-next-line no-console - console.log(data); + const handleOnAddSubmit = (data: RequirementSourceFormData) => { setRequirementSourceFormData((prevData) => [...prevData, data]); + setClose(); + }; + + const handleOnEditSubmit = (data: RequirementSourceFormData) => { + setRequirementSourceFormData((prevData) => + prevData.map((item) => + item.id === data.id ? { ...item, ...data } : item + ) + ); + setClose(); }; const handleAddRequirementSourceModal = () => { setOpen({ - content: , + content: , + width: "640px", + }); + }; + + const handleEditRequirementSourceModal = ( + data: RequirementSourceFormData + ) => { + setOpen({ + content: ( + + ), width: "640px", }); }; @@ -43,7 +64,12 @@ const RequirementFormRight: FC = () => { Requirement Source {requirementSourceFormData.map((data, index) => ( - + ))} ); diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx index 4c8115c..7516dc5 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceCard.tsx @@ -26,10 +26,11 @@ import { RequirementSourceEnum } from "@/utils/constants"; type RequirementSourceCardProps = { data: RequirementSourceFormData; index: number; + onEdit: (data: RequirementSourceFormData) => void; }; const RequirementSourceCard: FC = memo( - ({ data, index }) => { + ({ data, index, onEdit }) => { const [isExpanded, setIsExpanded] = useState(index === 0); const isCondition = [ @@ -110,7 +111,11 @@ const RequirementSourceCard: FC = memo( - + onEdit(data)} + > diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceModal.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceModal.tsx index 13c15b6..02efdd5 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceModal.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementSourceModal.tsx @@ -15,6 +15,7 @@ import { RequirementSourceEnum } from "@/utils/constants"; type RequirementSourceModalProps = { onSubmit: (data: RequirementSourceFormData) => void; + requirementSourceData?: RequirementSourceFormData; }; const requirementSourceFormSchema = yup.object().shape({ @@ -47,12 +48,13 @@ const initFormData: RequirementSourceFormData = { const RequirementSourceModal: React.FC = ({ onSubmit, + requirementSourceData, }) => { const { data: requirementSourceList } = useRequirementSourcesData(); const defaultValues = useMemo(() => { - return initFormData; - }, []); + return requirementSourceData ?? initFormData; + }, [requirementSourceData]); const methods = useForm({ resolver: yupResolver(requirementSourceFormSchema), @@ -75,14 +77,24 @@ const RequirementSourceModal: React.FC = ({ const onSubmitHandler = (data: RequirementSourceSchemaType) => { // eslint-disable-next-line no-console console.log(data); - onSubmit(data as RequirementSourceFormData); + const formData = data as RequirementSourceFormData; + if (!requirementSourceData) { + formData.id = Date.now(); + } + onSubmit(formData); }; return ( <>
- + = ({ getOptionLabel={(option) => option.name} getOptionKey={(option) => option.id} isOptionEqualToValue={(option, value) => option.id === value.id} + disabled={!!requirementSourceData} /> {selectedRequirementSource?.id === RequirementSourceEnum.EACA && ( = ({ RequirementSourceEnum.SCHEDULE_B, RequirementSourceEnum.EAC, RequirementSourceEnum.EACA, - ].includes(selectedRequirementSource?.id as RequirementSourceEnum) + ].includes( + selectedRequirementSource?.id as RequirementSourceEnum + ) ? "Condition # (optional)" : "Section # (optional)" } @@ -121,7 +136,9 @@ const RequirementSourceModal: React.FC = ({ - +
diff --git a/compliance-web/src/models/InspectionRequirement.ts b/compliance-web/src/models/InspectionRequirement.ts index 096c622..de08411 100644 --- a/compliance-web/src/models/InspectionRequirement.ts +++ b/compliance-web/src/models/InspectionRequirement.ts @@ -16,6 +16,7 @@ export interface InspectionRequirementFormData { } export interface RequirementSourceFormData { + id?: number; requirementSource?: RequirementSource; sourceNumber?: string; sourceTitle?: string, From 92ac6e52b7fcea3d2d741ea2cdfeeb183594129a Mon Sep 17 00:00:00 2001 From: Nitheesh T Ganesh Date: Thu, 2 Jan 2025 16:09:59 -0700 Subject: [PATCH 3/3] COMP-274: Delete Requirement Source (front) --- .../Requirements/RequirementFormRight.tsx | 35 +++++++++++++++---- .../Requirements/RequirementSourceCard.tsx | 9 +++-- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx index b53cc1d..b06508c 100644 --- a/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx +++ b/compliance-web/src/components/App/Inspections/Profile/Requirements/RequirementFormRight.tsx @@ -5,6 +5,7 @@ import { useModal } from "@/store/modalStore"; import RequirementSourceModal from "./RequirementSourceModal"; import { RequirementSourceFormData } from "@/models/InspectionRequirement"; import RequirementSourceCard from "./RequirementSourceCard"; +import ConfirmationModal from "@/components/Shared/Popups/ConfirmationModal"; const RequirementFormRight: FC = () => { const { setOpen, setClose } = useModal(); @@ -26,16 +27,21 @@ const RequirementFormRight: FC = () => { setClose(); }; - const handleAddRequirementSourceModal = () => { + const handleOnDeleteSubmit = (data: RequirementSourceFormData) => { + setRequirementSourceFormData((prevData) => + prevData.filter((item) => item.id !== data.id) + ); + setClose(); + }; + + const handleAddRequirementSource = () => { setOpen({ content: , width: "640px", }); }; - const handleEditRequirementSourceModal = ( - data: RequirementSourceFormData - ) => { + const handleEditRequirementSource = (data: RequirementSourceFormData) => { setOpen({ content: ( { }); }; + const handleDeleteRequirementSource = (data: RequirementSourceFormData) => { + setOpen({ + content: ( + handleOnDeleteSubmit(data)} + /> + ), + }); + }; + return ( { >