feat: services kit and copy
This commit is contained in:
60
src/modals/ServicesKitSelectModal/ServicesKitSelectModal.tsx
Normal file
60
src/modals/ServicesKitSelectModal/ServicesKitSelectModal.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import {GetServiceKitSchema} from "../../client";
|
||||
import {ContextModalProps} from "@mantine/modals";
|
||||
import {useState} from "react";
|
||||
import {Button, Flex, rem} from "@mantine/core";
|
||||
import ServicesKitSelect from "../../components/Selects/ServicesKitSelect/ServicesKitSelect.tsx";
|
||||
import {notifications} from "../../shared/lib/notifications.ts";
|
||||
|
||||
type Props = {
|
||||
onSelect: (kit: GetServiceKitSchema) => void;
|
||||
serviceType: number;
|
||||
}
|
||||
|
||||
const ServicesKitSelectModal = ({
|
||||
context,
|
||||
id,
|
||||
innerProps
|
||||
}: ContextModalProps<Props>) => {
|
||||
const [kit, setKit] = useState<GetServiceKitSchema | undefined>();
|
||||
const onSelectClick = () => {
|
||||
if (!kit) {
|
||||
notifications.error({message: "Выберите набор услуг"});
|
||||
return;
|
||||
}
|
||||
innerProps.onSelect(kit);
|
||||
context.closeContextModal(id);
|
||||
}
|
||||
return (
|
||||
<Flex
|
||||
gap={rem(10)}
|
||||
direction={"column"}>
|
||||
<Flex>
|
||||
<ServicesKitSelect
|
||||
w={"100%"}
|
||||
label={"Набор услуг"}
|
||||
placeholder={"Выберите набор услуг"}
|
||||
value={kit}
|
||||
onChange={setKit}
|
||||
filterBy={item => item.serviceType === innerProps.serviceType}
|
||||
/>
|
||||
</Flex>
|
||||
<Flex justify={"flex-end"} gap={rem(10)}>
|
||||
<Button
|
||||
variant={"subtle"}
|
||||
onClick={() => context.closeContextModal(id)}
|
||||
>
|
||||
Отменить
|
||||
</Button>
|
||||
<Button
|
||||
onClick={onSelectClick}
|
||||
variant={"default"}
|
||||
>
|
||||
Добавить
|
||||
</Button>
|
||||
|
||||
</Flex>
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServicesKitSelectModal;
|
||||
@@ -16,6 +16,9 @@ import EmployeeTableModal from "./EmployeeTableModal/EmployeeTableModal.tsx";
|
||||
import PositionFormModal from "./PositionFormModal/PositionFormModal.tsx";
|
||||
import PayRateFormModal from "../pages/AdminPage/modals/PayRateFormModal/PayRateFormModal.tsx";
|
||||
import CreatePaymentRecordModal from "../pages/AdminPage/modals/CreatePaymentRecordModal/CreatePaymentRecordModal.tsx";
|
||||
import ServiceKitModalForm from "../pages/ServicesPage/modals/ServicesKitModalForm.tsx";
|
||||
import ServicesKitSelectModal from "./ServicesKitSelectModal/ServicesKitSelectModal.tsx";
|
||||
import SelectDealProductsModal from "../pages/LeadsPage/modals/SelectDealProductsModal.tsx";
|
||||
|
||||
export const modals = {
|
||||
enterDeadline: EnterDeadlineModal,
|
||||
@@ -34,5 +37,8 @@ export const modals = {
|
||||
employeeTable: EmployeeTableModal,
|
||||
positionForm: PositionFormModal,
|
||||
payRateForm: PayRateFormModal,
|
||||
createPaymentRecord: CreatePaymentRecordModal
|
||||
createPaymentRecord: CreatePaymentRecordModal,
|
||||
serviceKitModalForm: ServiceKitModalForm,
|
||||
servicesKitSelectModal: ServicesKitSelectModal,
|
||||
selectDealProductsModal: SelectDealProductsModal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user