feat: service deleting and rest categories placeholders

This commit is contained in:
2024-10-09 02:03:52 +03:00
parent dea1221016
commit 891b6cff9f
9 changed files with 41 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ type RestProps = {
};
type Props = Omit<ObjectSelectProps<ServiceSchema>, "data"> & RestProps;
const ServiceSelectNew: FC<Props> = (props: Props) => {
const { services } = useServicesList();
const { services } = useServicesList({ withPlaceholders: false });
const data = props.filterType
? services.filter(service => service.serviceType === props.filterType)
: services;
@@ -28,10 +28,10 @@ const ServiceSelectNew: FC<Props> = (props: Props) => {
return {
...option,
items: option.items.filter((item: ComboboxItem) =>
item.label.toLowerCase().includes(search.toLowerCase())
item.label.toLowerCase().includes(search.toLowerCase()),
),
};
}
},
);
};
return (

View File

@@ -7,7 +7,7 @@ import useServicesList from "../../../pages/ServicesPage/hooks/useServicesList.t
type Props = Omit<ObjectMultiSelectProps<ServiceSchema>, "data">;
const ServicesMultiselect: FC<Props> = (props: Props) => {
const { services } = useServicesList();
const { services } = useServicesList({ withPlaceholders: false });
return (
<ObjectMultiSelect
data={services}

View File

@@ -20,7 +20,7 @@ const ServiceSelect: FC<Props> = props => {
ServiceSchema | undefined
>(props.defaultValue);
const value = isControlled ? props.value : internalValue;
const { services } = useServicesList();
const { services } = useServicesList({ withPlaceholders: false });
const categories = useMemo(
() =>
services.reduce((acc, service) => {
@@ -29,7 +29,7 @@ const ServiceSelect: FC<Props> = props => {
}
return acc;
}, [] as string[]),
[services]
[services],
);
const data = useMemo(
@@ -43,22 +43,22 @@ const ServiceSelect: FC<Props> = props => {
label: service.name,
})),
})),
[services, categories]
[services, categories],
);
const handleOnChange = (value: string) => {
if (isControlled) {
props.onChange(
services.find(
service => service.id.toString() === value
) as ServiceSchema
service => service.id.toString() === value,
) as ServiceSchema,
);
return;
}
setInternalValue(
services.find(
service => service.id.toString() === value
) as ServiceSchema
service => service.id.toString() === value,
) as ServiceSchema,
);
};
useEffect(() => {