hide company for non company users

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Mohammad Khyata 2026-05-07 11:34:07 +03:00
parent 1fda8d8d7b
commit 4faafe6667

View File

@ -114,7 +114,7 @@ function mapFormToPayload(values: CustomerFormValues) {
const mapLookupOption = (item: any) => ({
value: String(item.id),
label: item.title||item.name || `#${item.id}`,
label: item.title || item.name || `#${item.id}`,
})
const STORE_OBJECT = { getOptionValue: (o: any) => o, getOptionLabel: (o: any) => o.label || o.name || `#${o.id}` }
@ -134,6 +134,7 @@ export function CustomerForm({ resourceId, initialData, onSuccess }: CustomerFor
mapToFormValues: mapCustomerToFormValues,
})
const { customer_type} = form.watch()
const { mutate, error, isPending } = useFormMutation(form, {
mutationFn: (values: CustomerFormValues) => {
const payload = mapFormToPayload(values)
@ -174,7 +175,7 @@ export function CustomerForm({ resourceId, initialData, onSuccess }: CustomerFor
options={SALUTATION_OPTIONS}
/>
<RhfAsyncSelectField
required
required
name="customer_type"
label="Customer Type"
placeholder="Select customer type"
@ -192,7 +193,11 @@ export function CustomerForm({ resourceId, initialData, onSuccess }: CustomerFor
<RhfTextField name="last_name" label="Last Name" placeholder="Doe" required />
</div>
<RhfTextField name="company_name" label="Company Name" placeholder="Doe Holdings" />
{
customer_type?.label === "Company" &&
<RhfTextField name="company_name" label="Company Name" placeholder="Doe Holdings" />
}
{/* Contact */}
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">