From 0e56b0c9e900c93b70dbd7dc3c0c7046ce61cd9a Mon Sep 17 00:00:00 2001 From: David Nunez Date: Fri, 12 Jan 2024 11:03:11 -0500 Subject: [PATCH 1/3] Make work title match backend --- epictrack-web/src/components/work/WorkForm/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/epictrack-web/src/components/work/WorkForm/index.tsx b/epictrack-web/src/components/work/WorkForm/index.tsx index 782aff661..fca21d42b 100644 --- a/epictrack-web/src/components/work/WorkForm/index.tsx +++ b/epictrack-web/src/components/work/WorkForm/index.tsx @@ -38,6 +38,7 @@ const schema = yup.object().shape({ title: yup .string() .required("Title is required") + .max(150, "Title should not exceed 150 characters") .test({ name: "checkDuplicateWork", exclusive: true, @@ -48,7 +49,9 @@ const schema = yup.object().shape({ value, parent["id"] ); - return !(validateWorkResult.data as any)["exists"] as boolean; + return validateWorkResult.data + ? (!(validateWorkResult.data as any)["exists"] as boolean) + : true; } return true; }, @@ -123,8 +126,12 @@ export default function WorkForm({ ...props }) { formState: { errors }, reset, setValue, + watch, } = methods; + const title = watch("title"); + const titleLength = title ? title.length : 0; + React.useEffect(() => { reset(ctx.item ?? defaultWork); }, [ctx.item]); @@ -318,7 +325,7 @@ export default function WorkForm({ ...props }) { > - Title + Title ({title?.length || 0}/150) Date: Mon, 15 Jan 2024 12:01:08 -0500 Subject: [PATCH 2/3] change title to ETform with character limit --- epictrack-web/src/components/work/WorkForm/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/epictrack-web/src/components/work/WorkForm/index.tsx b/epictrack-web/src/components/work/WorkForm/index.tsx index fca21d42b..1f622f6df 100644 --- a/epictrack-web/src/components/work/WorkForm/index.tsx +++ b/epictrack-web/src/components/work/WorkForm/index.tsx @@ -26,6 +26,7 @@ import icons from "../../icons"; import { WorkLeadSpecialField } from "./WorkLeadSpecialField"; import { MIN_WORK_START_DATE } from "../../../constants/application-constant"; import { Project } from "../../../models/project"; +import { ETFormLabelWithCharacterLimit } from "../../shared"; const schema = yup.object().shape({ ea_act_id: yup.number().required("EA Act is required"), @@ -130,7 +131,6 @@ export default function WorkForm({ ...props }) { } = methods; const title = watch("title"); - const titleLength = title ? title.length : 0; React.useEffect(() => { reset(ctx.item ?? defaultWork); @@ -325,7 +325,12 @@ export default function WorkForm({ ...props }) { > - Title ({title?.length || 0}/150) + + Title + Date: Mon, 15 Jan 2024 12:01:40 -0500 Subject: [PATCH 3/3] update imports --- epictrack-web/src/components/work/WorkForm/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epictrack-web/src/components/work/WorkForm/index.tsx b/epictrack-web/src/components/work/WorkForm/index.tsx index 1f622f6df..f7c7e00a9 100644 --- a/epictrack-web/src/components/work/WorkForm/index.tsx +++ b/epictrack-web/src/components/work/WorkForm/index.tsx @@ -8,7 +8,7 @@ import codeService, { Code } from "../../../services/codeService"; import { Work, defaultWork } from "../../../models/work"; import { ListType } from "../../../models/code"; import { Ministry } from "../../../models/ministry"; -import { ETFormLabel } from "../../shared"; +import { ETFormLabel, ETFormLabelWithCharacterLimit } from "../../shared"; import { Staff } from "../../../models/staff"; import staffService from "../../../services/staffService/staffService"; import dayjs from "dayjs"; @@ -26,7 +26,6 @@ import icons from "../../icons"; import { WorkLeadSpecialField } from "./WorkLeadSpecialField"; import { MIN_WORK_START_DATE } from "../../../constants/application-constant"; import { Project } from "../../../models/project"; -import { ETFormLabelWithCharacterLimit } from "../../shared"; const schema = yup.object().shape({ ea_act_id: yup.number().required("EA Act is required"),