Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8fd2a7a

Browse files
committed
Override label through Yup instead
1 parent 6a339d7 commit 8fd2a7a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

site/src/util/formUtils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ interface FormHelpers {
3939

4040
export const getFormHelpers =
4141
<T>(form: FormikContextType<T>, error?: Error | unknown) =>
42-
(
43-
name: keyof T,
44-
HelperText: ReactNode = "",
45-
friendlyLabel?: string,
46-
): FormHelpers => {
42+
(name: keyof T, HelperText: ReactNode = ""): FormHelpers => {
4743
const apiValidationErrors =
4844
isApiError(error) && hasApiFieldErrors(error)
4945
? (mapApiErrorToFieldErrors(error.response.data) as FormikErrors<T>)
@@ -60,15 +56,11 @@ export const getFormHelpers =
6056
const apiError = getIn(apiValidationErrors, name)
6157
const frontendError = getIn(form.errors, name)
6258
const returnError = apiError ?? frontendError
63-
const friendlyError =
64-
friendlyLabel && returnError
65-
? returnError.replace(name, friendlyLabel)
66-
: returnError
6759
return {
6860
...form.getFieldProps(name),
6961
id: name,
70-
error: touched && Boolean(friendlyError),
71-
helperText: touched ? friendlyError || HelperText : HelperText,
62+
error: touched && Boolean(returnError),
63+
helperText: touched ? returnError || HelperText : HelperText,
7264
}
7365
}
7466

0 commit comments

Comments
 (0)