fix(customers): improve form field value binding and import organization
- Reorganize imports in alphabetical order for better maintainability - Add value binding to role select field using watch hook for proper form state synchronization - Add value binding to type select field using watch hook for consistent form behavior - Ensure form fields properly reflect current values during editing and user interaction
This commit is contained in:
@@ -6,12 +6,12 @@ import MultiSelect from "@/components/FormElements/MultiSelect";
|
|||||||
import { Select } from "@/components/FormElements/select";
|
import { Select } from "@/components/FormElements/select";
|
||||||
import { ShowcaseSection } from "@/components/Layouts/showcase-section";
|
import { ShowcaseSection } from "@/components/Layouts/showcase-section";
|
||||||
import FormFooter from "@/components/ui/FormFooter";
|
import FormFooter from "@/components/ui/FormFooter";
|
||||||
|
import { AdminRoles } from "@/constants/enums";
|
||||||
import { REGEX } from "@/constants/regex";
|
import { REGEX } from "@/constants/regex";
|
||||||
import { FormErrorMessages } from "@/constants/Texts";
|
import { FormErrorMessages } from "@/constants/Texts";
|
||||||
import { CreateCustomerCredentials } from "@/lib/api";
|
import { CreateCustomerCredentials } from "@/lib/api";
|
||||||
import useCreateCustomerPresenter from "./useCreateCustomerPresenter";
|
|
||||||
import { getEnumAsArray } from "@/utils/shared";
|
import { getEnumAsArray } from "@/utils/shared";
|
||||||
import { AdminRoles } from "@/constants/enums";
|
import useCreateCustomerPresenter from "./useCreateCustomerPresenter";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
editMode?: boolean;
|
editMode?: boolean;
|
||||||
@@ -99,6 +99,7 @@ const CreateCustomer = ({ defaultValues, editMode, id }: IProps) => {
|
|||||||
required: { message: FormErrorMessages.required, value: true },
|
required: { message: FormErrorMessages.required, value: true },
|
||||||
})}
|
})}
|
||||||
name="role"
|
name="role"
|
||||||
|
value={watch("role")}
|
||||||
items={getEnumAsArray(AdminRoles)}
|
items={getEnumAsArray(AdminRoles)}
|
||||||
placeholder="Select Role"
|
placeholder="Select Role"
|
||||||
/>
|
/>
|
||||||
@@ -183,6 +184,7 @@ const CreateCustomer = ({ defaultValues, editMode, id }: IProps) => {
|
|||||||
})}
|
})}
|
||||||
name="type"
|
name="type"
|
||||||
label="Type"
|
label="Type"
|
||||||
|
value={watch("type")}
|
||||||
placeholder="Select Type"
|
placeholder="Select Type"
|
||||||
prefixIcon={<GlobeIcon />}
|
prefixIcon={<GlobeIcon />}
|
||||||
items={[
|
items={[
|
||||||
|
|||||||
Reference in New Issue
Block a user