fix: fixed deal service editor modal
This commit is contained in:
@ -20,8 +20,11 @@ type Props = Omit<ObjectSelectProps<ServiceSchema>, "data"> & RestProps;
|
||||
|
||||
const ServiceSelect: FC<Props> = props => {
|
||||
const { services } = useServicesList();
|
||||
const data = props.filterType
|
||||
? services.filter(service => service.serviceType === props.filterType)
|
||||
const data =
|
||||
props.filterType !== undefined
|
||||
? services.filter(
|
||||
service => service.serviceType === props.filterType
|
||||
)
|
||||
: services;
|
||||
|
||||
const restProps = omit(props, ["filterType"]);
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ComboboxItem,
|
||||
ComboboxItemGroup,
|
||||
NumberInput,
|
||||
OptionsFilter,
|
||||
} from "@mantine/core";
|
||||
import { NumberInput } from "@mantine/core";
|
||||
import { useForm } from "@mantine/form";
|
||||
import { ContextModalProps } from "@mantine/modals";
|
||||
import {
|
||||
@ -54,26 +49,6 @@ const DealServiceEditorModal = ({
|
||||
|
||||
const onClose = () => context.closeContextModal(id);
|
||||
|
||||
const serviceOptionsFilter = ({
|
||||
options,
|
||||
}: {
|
||||
options: ComboboxItemGroup[];
|
||||
}) => {
|
||||
if (!innerProps.serviceIdsToExclude) return options;
|
||||
const productServiceIds = innerProps.serviceIdsToExclude;
|
||||
return (options as ComboboxItemGroup[]).map(({ items, group }) => {
|
||||
return {
|
||||
group,
|
||||
items: items.filter(
|
||||
item =>
|
||||
!productServiceIds.includes(
|
||||
Number((item as ComboboxItem).value)
|
||||
)
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<BaseFormModal
|
||||
{...innerProps}
|
||||
@ -90,7 +65,9 @@ const DealServiceEditorModal = ({
|
||||
label: "Услуга",
|
||||
placeholder: "Выберите услугу",
|
||||
disabled: innerProps.isEditing,
|
||||
filter: serviceOptionsFilter as OptionsFilter,
|
||||
filterBy: item =>
|
||||
!innerProps.serviceIdsToExclude?.includes(item.id) ||
|
||||
innerProps.isEditing,
|
||||
}}
|
||||
priceProps={{
|
||||
...form.getInputProps("price"),
|
||||
|
||||
Reference in New Issue
Block a user