feat: client returned, slot is a slot

This commit is contained in:
2024-10-02 01:40:29 +03:00
parent f202e9b9fa
commit ec63a51109
4 changed files with 384 additions and 295 deletions

View File

@@ -35,7 +35,7 @@ type Props = {
deal: DealSchema;
};
type FormType = Omit<DealSchema, "statusHistory" | "services" | "products">;
export type DealGeneralFormType = Omit<DealSchema, "statusHistory" | "services" | "products">;
const Content: FC<Props> = ({ deal }) => {
const { setSelectedDeal } = useDealPageContext();
@@ -44,7 +44,7 @@ const Content: FC<Props> = ({ deal }) => {
// ignore typescript
const initialValues: FormType = {
const initialValues: DealGeneralFormType = {
...deal,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
@@ -53,7 +53,7 @@ const Content: FC<Props> = ({ deal }) => {
// @ts-expect-error
receivingSlotDate: deal.receivingSlotDate ? new Date(deal.receivingSlotDate) : null,
};
const form = useForm<FormType>({
const form = useForm<DealGeneralFormType>({
initialValues: initialValues,
validate: {
name: (value: string) =>
@@ -62,7 +62,7 @@ const Content: FC<Props> = ({ deal }) => {
: "Название сделки не может быть пустым",
},
});
const updateDealInfo = async (values: FormType) => {
const updateDealInfo = async (values: DealGeneralFormType) => {
return DealService.updateDealGeneralInfo({
requestBody: {
dealId: deal.id,
@@ -83,14 +83,14 @@ const Content: FC<Props> = ({ deal }) => {
});
});
};
const updateClientInfo = async (values: FormType) => {
const updateClientInfo = async (values: DealGeneralFormType) => {
return ClientService.updateClient({
requestBody: {
data: values.client,
},
}).then(({ ok, message }) => notifications.guess(ok, { message }));
};
const handleSubmit = async (values: FormType) => {
const handleSubmit = async (values: DealGeneralFormType) => {
// Updating client info if there changes
if (!isEqual(values.client, deal.client)) {
await updateClientInfo(values);