feat: adding services kit to deal
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import { Button, Flex, rem } from "@mantine/core";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { addKitToDeal, ServicesKitSchema } from "@/lib/client";
|
||||
import { useFulfillmentBaseContext } from "@/modules/dealModules/dealEditorTabs/FulfillmentBaseTab/contexts/FulfillmentBaseContext";
|
||||
import { ServiceType } from "@/modules/dealModules/dealEditorTabs/FulfillmentBaseTab/types/service";
|
||||
|
||||
const ServicesActions = () => {
|
||||
const { dealServicesList, dealServicesCrud, deal } =
|
||||
@ -22,17 +24,27 @@ const ServicesActions = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// const onAddKitClick = () => {
|
||||
// if (!onKitAdd) return;
|
||||
// modals.openContextModal({
|
||||
// modal: "servicesKitSelectModal",
|
||||
// innerProps: {
|
||||
// onSelect: onKitAdd,
|
||||
// serviceType: ServiceType.DEAL_SERVICE,
|
||||
// },
|
||||
// withCloseButton: false,
|
||||
// });
|
||||
// };
|
||||
const onServicesKitAdd = (servicesKit: ServicesKitSchema) => {
|
||||
addKitToDeal({
|
||||
body: {
|
||||
dealId: deal.id,
|
||||
kitId: servicesKit.id,
|
||||
},
|
||||
})
|
||||
.then(() => dealServicesList.refetch())
|
||||
.catch(err => console.error(err));
|
||||
};
|
||||
|
||||
const onAddKitClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "servicesKitSelectModal",
|
||||
innerProps: {
|
||||
onSelect: onServicesKitAdd,
|
||||
serviceType: ServiceType.DEAL_SERVICE,
|
||||
},
|
||||
withCloseButton: false,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex
|
||||
@ -45,12 +57,12 @@ const ServicesActions = () => {
|
||||
variant={"default"}>
|
||||
Добавить услугу
|
||||
</Button>
|
||||
{/*<Button*/}
|
||||
{/* onClick={onAddKitClick}*/}
|
||||
{/* fullWidth*/}
|
||||
{/* variant={"default"}>*/}
|
||||
{/* Добавить набор услуг*/}
|
||||
{/*</Button>*/}
|
||||
<Button
|
||||
onClick={onAddKitClick}
|
||||
fullWidth
|
||||
variant={"default"}>
|
||||
Добавить набор услуг
|
||||
</Button>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user