popular-magentaP
Refine2y ago
4 replies
popular-magenta

Useing hook in mui

onFinish={async (values) => {
try {
const data = await onFinish({
name: values.name,
salesOwnerId: values.salesOwnerId,
});

const createdCompany = (data as CreateResponse<Company>)?.data;

if ((values.contacts ?? [])?.length > 0) {
await createManyMutateAsync({
resource: "contacts",
values:
values.contacts?.map((contact) => ({
...contact,
companyId: createdCompany.id,
salesOwnerId: createdCompany.salesOwner.id,
})) ?? [],
successNotification: false,
});
}

go({
to: searchParams.get("to") ?? pathname,
query: {
companyId: createdCompany.id,
to: undefined,
},
options: {
keepQuery: true,
},
type: "replace",
});
} catch (error) {
Promise.reject(error);
}
}}

using this hook in mui
Was this page helpful?