This commit is contained in:
Hugo Lextrait 2023-05-05 15:00:33 +02:00
parent f7dd2c244a
commit b3a44dd97c

View File

@ -188,21 +188,18 @@ class AddClientToFolderClass extends BasePage<IPropsClass, IState> {
) {
values["civility"] = ECivility.MALE; // TODO: should maybe be deleted later or added to the form
let customersToLink: IPutFoldersParams["office_folder_has_customers"] = [];
let customersToLink: IPutFoldersParams["office_folder_has_customers"] = this.state.selectedCustomers.map((customer) => {
return {
customer: { uid: customer.value },
};
}) as IPutFoldersParams["office_folder_has_customers"];
if (this.state.isNewClientSelected) {
const customer: Customer = await Customers.getInstance().post({
customer: values,
contact: values,
});
if (!customer.uid) return;
customersToLink = [{ customer: { uid: customer.uid } }];
}
if (this.state.isExistingClientSelected) {
customersToLink = this.state.selectedCustomers.map((customer) => {
return {
customer: { uid: customer.value },
};
}) as IPutFoldersParams["office_folder_has_customers"];
customersToLink?.push({ customer: { uid: customer.uid } });
}
if (customersToLink) {