From 0dc0a2a8a87735668e27191faa4affe593f33425 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 17 Jun 2024 17:03:26 +0530 Subject: [PATCH] [WEB-1612] chore: add length validation for state name. (#4837) * [WEB-1612] chore: add length validation for state name. * style: update error message padding. --- .../states/create-update-state-inline.tsx | 252 +++++++++--------- 1 file changed, 128 insertions(+), 124 deletions(-) diff --git a/web/core/components/states/create-update-state-inline.tsx b/web/core/components/states/create-update-state-inline.tsx index 7d7eb3c96a..f218211a12 100644 --- a/web/core/components/states/create-update-state-inline.tsx +++ b/web/core/components/states/create-update-state-inline.tsx @@ -107,9 +107,8 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { setToast({ type: TOAST_TYPE.ERROR, title: "Error!", - message: "State could not be created. Please try again.", + message: error.data.error ?? "State could not be created. Please try again.", }); - captureProjectStateEvent({ eventName: STATE_CREATED, payload: { @@ -173,134 +172,139 @@ export const CreateUpdateStateInline: React.FC = observer((props) => { return (
-
- - {({ open }) => ( - <> - - {watch("color") && watch("color") !== "" && ( - - )} - - - - - ( - onChange(value.hex)} /> - )} - /> - - - - )} - -
- ( - - )} - /> - {data && ( - ( - -
- k === value.toString()) - ? GROUP_CHOICES[value.toString() as keyof typeof GROUP_CHOICES] - : "Select group" - } - input +
+
+ + {({ open }) => ( + <> + - {Object.keys(GROUP_CHOICES).map((key) => ( - - {GROUP_CHOICES[key as keyof typeof GROUP_CHOICES]} - - ))} - -
- + {watch("color") && watch("color") !== "" && ( + + )} + + + + ( + onChange(value.hex)} /> + )} + /> + + + + )} + +
+ ( + )} /> - )} - ( - ( + +
+ k === value.toString()) + ? GROUP_CHOICES[value.toString() as keyof typeof GROUP_CHOICES] + : "Select group" + } + input + > + {Object.keys(GROUP_CHOICES).map((key) => ( + + {GROUP_CHOICES[key as keyof typeof GROUP_CHOICES]} + + ))} + +
+
+ )} /> )} - /> - - + ( + + )} + /> + + +
+ {errors.name?.message &&

{errors.name?.message}

} ); });