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