e6493f5d83
This commit introduces a loading state for form submissions and replaces the custom switch component with a third-party library for improved user experience and maintainability. - Adds `react-switch` as a dependency to replace the custom-built switch component, providing a more robust and feature-rich solution. - Implements a loading indicator on form submission buttons and in the confirmation modal by utilizing the `useIsMutating` hook from TanStack Query. This provides clear visual feedback to the user during asynchronous operations. - Creates a reusable `FormFooter` component to encapsulate the submit and cancel buttons, centralizing the form submission logic and loading state. - Refactors the company create/edit forms to use the new `FormFooter` and `react-switch` components. - Moves the `BreadcrumbItem` type to a shared types file for better code organization.
12 lines
608 B
TypeScript
12 lines
608 B
TypeScript
export const FormErrorMessages = {
|
|
required: "This field is required",
|
|
maxLength: (length: number | string) =>
|
|
`This field must be at most ${length} characters long`,
|
|
minLength: (length: string | number) =>
|
|
`This field must be at least ${length} characters long`,
|
|
min: (value: number | string) => `This field must be at least ${value}`,
|
|
max: (value: number | string) => `This field must be at most ${value}`,
|
|
invalidEmail: "Email address is invalid",
|
|
alphaNumeric: "This field can only contain letters and numbers",
|
|
invalidPattern: "This field does not match the required pattern",
|
|
}; |