feat: deal_id fix
This commit is contained in:
@@ -19,7 +19,7 @@ type Props = {
|
||||
deal: DealSchema
|
||||
}
|
||||
|
||||
type FormType = Omit<DealSchema, 'statusHistory' | 'services' | 'products'>
|
||||
type FormType = Omit<DealSchema, "statusHistory" | "services" | "products">
|
||||
|
||||
const Content: FC<Props> = ({ deal }) => {
|
||||
const { setSelectedDeal } = useDealPageContext();
|
||||
@@ -31,16 +31,16 @@ const Content: FC<Props> = ({deal}) => {
|
||||
{
|
||||
initialValues: initialValues,
|
||||
validate: {
|
||||
name: (value: string) => value.length > 0 ? null : 'Название сделки не может быть пустым'
|
||||
}
|
||||
}
|
||||
)
|
||||
name: (value: string) => value.length > 0 ? null : "Название сделки не может быть пустым",
|
||||
},
|
||||
},
|
||||
);
|
||||
const updateDealInfo = async (values: FormType) => {
|
||||
return DealService.updateDealGeneralInfo({
|
||||
requestBody: {
|
||||
dealId: deal.id,
|
||||
data: {...values, shippingWarehouse: values.shippingWarehouse?.toString()}
|
||||
}
|
||||
data: { ...values, shippingWarehouse: values.shippingWarehouse?.toString() },
|
||||
},
|
||||
}).then(({ ok, message }) => {
|
||||
notifications.guess(ok, { message });
|
||||
if (!ok) return;
|
||||
@@ -49,19 +49,19 @@ const Content: FC<Props> = ({deal}) => {
|
||||
setSelectedDeal(data);
|
||||
form.setInitialValues(data);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['getDealSummaries']
|
||||
})
|
||||
})
|
||||
queryKey: ["getDealSummaries"],
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
const updateClientInfo = async (values: FormType) => {
|
||||
return ClientService.updateClient({
|
||||
requestBody: {
|
||||
data: values.client
|
||||
}
|
||||
data: values.client,
|
||||
},
|
||||
}).then(({ ok, message }) =>
|
||||
notifications.guess(ok, { message }));
|
||||
}
|
||||
};
|
||||
const handleSubmit = async (values: FormType) => {
|
||||
// Updating client info if there changes
|
||||
if (!isEqual(values.client, deal.client)) {
|
||||
@@ -69,40 +69,40 @@ const Content: FC<Props> = ({deal}) => {
|
||||
}
|
||||
// updating deal info
|
||||
await updateDealInfo(values);
|
||||
}
|
||||
};
|
||||
const isShippingWarehouse = (value: (ShippingWarehouseSchema | string | null | undefined)): value is ShippingWarehouseSchema => {
|
||||
return !["string", "null", "undefined"].includes((typeof value));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const onCopyGuestUrlClick = () => {
|
||||
DealService.createDealGuestUrl({
|
||||
requestBody: {
|
||||
dealId: deal.id
|
||||
}
|
||||
dealId: deal.id,
|
||||
},
|
||||
}).then(({ ok, message, url }) => {
|
||||
if (!ok)
|
||||
notifications.guess(ok, { message });
|
||||
clipboard.copy(
|
||||
`${window.location.origin}/${url}`
|
||||
`${window.location.origin}/${url}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
return (
|
||||
<form onSubmit={form.onSubmit((values) => handleSubmit(values))}>
|
||||
<Flex direction={'column'}>
|
||||
<Fieldset legend={"Общие параметры [ID: 12311]"}>
|
||||
<Flex direction={"column"}>
|
||||
<Fieldset legend={`Общие параметры [ID: ${deal.id}]`}>
|
||||
<Flex direction={"column"} gap={rem(10)}>
|
||||
<TextInput
|
||||
placeholder={"Название сделки"}
|
||||
label={"Название сделки"}
|
||||
{...form.getInputProps('name')}
|
||||
{...form.getInputProps("name")}
|
||||
/>
|
||||
<TextInput
|
||||
disabled
|
||||
placeholder={"Дата создания"}
|
||||
label={"Дата создания"}
|
||||
value={new Date(deal.createdAt).toLocaleString('ru-RU')}
|
||||
value={new Date(deal.createdAt).toLocaleString("ru-RU")}
|
||||
/>
|
||||
<TextInput
|
||||
disabled
|
||||
@@ -110,9 +110,9 @@ const Content: FC<Props> = ({deal}) => {
|
||||
label={"Текущий статус"}
|
||||
value={DealStatusDictionary[deal.currentStatus as DealStatus]} />
|
||||
<Textarea
|
||||
label={'Коментарий к сделке'}
|
||||
placeholder={'Введите коментарий к сделке'}
|
||||
{...form.getInputProps('comment')}
|
||||
label={"Коментарий к сделке"}
|
||||
placeholder={"Введите коментарий к сделке"}
|
||||
{...form.getInputProps("comment")}
|
||||
/>
|
||||
<ShippingWarehouseAutocomplete
|
||||
placeholder={"Введите склад отгрузки"}
|
||||
@@ -120,10 +120,10 @@ const Content: FC<Props> = ({deal}) => {
|
||||
value={isShippingWarehouse(form.values.shippingWarehouse) ? form.values.shippingWarehouse : undefined}
|
||||
onChange={event => {
|
||||
if (isShippingWarehouse(event)) {
|
||||
form.getInputProps('shippingWarehouse').onChange(event.name)
|
||||
return
|
||||
form.getInputProps("shippingWarehouse").onChange(event.name);
|
||||
return;
|
||||
}
|
||||
form.getInputProps('shippingWarehouse').onChange(event)
|
||||
form.getInputProps("shippingWarehouse").onChange(event);
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
@@ -138,26 +138,26 @@ const Content: FC<Props> = ({deal}) => {
|
||||
<TextInput
|
||||
placeholder={"Введите телефон"}
|
||||
label={"Телефон клиента"}
|
||||
{...form.getInputProps('client.details.phoneNumber')}
|
||||
{...form.getInputProps("client.details.phoneNumber")}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder={"Введите email"}
|
||||
label={"Email"}
|
||||
{...form.getInputProps('client.details.email')}
|
||||
{...form.getInputProps("client.details.email")}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder={"Введите телеграм"}
|
||||
label={"Телеграм"}
|
||||
{...form.getInputProps('client.details.telegram')}
|
||||
{...form.getInputProps("client.details.telegram")}
|
||||
/>
|
||||
<TextInput
|
||||
placeholder={"Введите ИНН"}
|
||||
label={"ИНН"}
|
||||
{...form.getInputProps('client.details.inn')}
|
||||
{...form.getInputProps("client.details.inn")}
|
||||
/>
|
||||
</Fieldset>
|
||||
<Flex mt={'md'} gap={rem(10)} align={'center'} justify={'flex-end'}>
|
||||
<Flex align={'center'} gap={rem(10)} justify={'center'}>
|
||||
<Flex mt={"md"} gap={rem(10)} align={"center"} justify={"flex-end"}>
|
||||
<Flex align={"center"} gap={rem(10)} justify={"center"}>
|
||||
|
||||
<Flex gap={rem(10)}>
|
||||
{(deal.billRequest && deal.billRequest.pdfUrl) ?
|
||||
@@ -199,20 +199,20 @@ const Content: FC<Props> = ({deal}) => {
|
||||
/>
|
||||
<Checkbox
|
||||
label={"Сделка завершена"}
|
||||
{...form.getInputProps('isCompleted')}
|
||||
{...form.getInputProps("isCompleted")}
|
||||
/>
|
||||
|
||||
<Checkbox
|
||||
label={"Сделка удалена"}
|
||||
{...form.getInputProps('isDeleted')}
|
||||
{...form.getInputProps("isDeleted")}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
</Flex>
|
||||
<Divider
|
||||
orientation={'vertical'}
|
||||
orientation={"vertical"}
|
||||
/>
|
||||
<Group align={'center'} justify={'center'}>
|
||||
<Group align={"center"} justify={"center"}>
|
||||
<Button
|
||||
color={"red"}
|
||||
type={"reset"}
|
||||
@@ -230,13 +230,13 @@ const Content: FC<Props> = ({deal}) => {
|
||||
|
||||
</form>
|
||||
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
const DealEditDrawerGeneralTab: FC = () => {
|
||||
const { selectedDeal } = useDealPageContext();
|
||||
if (!selectedDeal) return <>No deal selected</>;
|
||||
return (
|
||||
<Content deal={selectedDeal} />
|
||||
);
|
||||
}
|
||||
};
|
||||
export default DealEditDrawerGeneralTab;
|
||||
Reference in New Issue
Block a user