Skip to content

Commit

Permalink
Description in complaint-requirementsource optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-aot committed Dec 30, 2024
1 parent a7ebf6f commit 21357dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
10 changes: 0 additions & 10 deletions compliance-api/src/compliance_api/schemas/complaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,6 @@ def validate_topic_and_description(
"Topic is required when requirement_source is selected",
field_name="requirement_source_details.topic_id",
)
if not requirement_source_details.get(
"description", None
) and requirement_source_id not in [
RequirementSourceEnum.SCHEDULE_B.value,
RequirementSourceEnum.ORDER.value,
]:
raise ValidationError(
"Description is required when requirement_source is selected",
field_name="requirement_source_details.description",
)

@validates_schema
def validate_order(
Expand Down
20 changes: 0 additions & 20 deletions compliance-web/src/components/App/Complaints/ComplaintFormUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,6 @@ export const ComplaintFormSchema = yup.object().shape({
}),
amendmentNumber: yup.string().nullable(),
amendmentConditionNumber: yup.string().nullable(),
description: yup.string().when("requirementSource", {
is: (reqSource: RequirementSource) =>
[RequirementSourceEnum.NOT_EA_ACT, RequirementSourceEnum.OTHER].includes(
reqSource?.id as RequirementSourceEnum
),
then: (schema) => schema.required("Description is required"),
otherwise: (schema) => schema.notRequired(),
}),
conditionDescription: yup.string().when("requirementSource", {
is: (reqSource: RequirementSource) =>
[
RequirementSourceEnum.EAC,
RequirementSourceEnum.CPD,
RequirementSourceEnum.ACT2018,
RequirementSourceEnum.COMPLAINCE_AGREEMENT,
RequirementSourceEnum.ACT2022,
].includes(reqSource?.id as RequirementSourceEnum),
then: (schema) => schema.required("Condition Description is required"),
otherwise: (schema) => schema.notRequired(),
}),
topic: yup
.object<Topic>()
.nullable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Box } from "@mui/material";
import DynamicInputField, {
DynamicInputFieldConfig,
} from "@/components/App/DynamicInputField";
import ControlledAutoComplete from "@/components/Shared/Controlled/ControlledAutoComplete";
import { FC, useEffect } from "react";
import ConfirmationModal from "@/components/Shared/Popups/ConfirmationModal";
import { RequirementSource } from "@/models/RequirementSource";
import { BCDesignTokens } from "epic.theme";
import { useFormContext, useWatch } from "react-hook-form";
import { Topic } from "@/models/Topic";
import { useDrawer } from "@/store/drawerStore";
import DynamicInputField, {
DynamicInputFieldConfig,
} from "@/components/App/DynamicInputField";
import { useModal } from "@/store/modalStore";
import ConfirmationModal from "@/components/Shared/Popups/ConfirmationModal";
import { RequirementSourceEnum } from "@/utils/constants";
import { Box } from "@mui/material";
import { BCDesignTokens } from "epic.theme";
import { FC, useEffect } from "react";
import { useFormContext, useWatch } from "react-hook-form";

type RequirementSourceFormProps = {
requirementSourceList: RequirementSource[];
Expand Down Expand Up @@ -107,7 +107,7 @@ const RequirementSourceForm: FC<RequirementSourceFormProps> = ({
return {
type: "text",
name: name ?? "conditionDescription",
label: label ?? "Condition Description",
label: `${label ?? "Condition Description"} (optional)`,
required: true,
};
};
Expand Down

0 comments on commit 21357dd

Please sign in to comment.