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
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
