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

@@ -1,10 +1,16 @@
import { useQuery } from "@tanstack/react-query";
import { ServiceService } from "../../../client";
const useServicesList = () => {
type Props = {
withPlaceholders?: boolean;
}
const useServicesList = (props: Props) => {
const { withPlaceholders = false } = props;
const { isPending, error, data, refetch } = useQuery({
queryKey: ["getAllServices"],
queryFn: ServiceService.getAllServices,
queryKey: ["getAllServices", withPlaceholders],
queryFn: () => ServiceService.getAllServices({ withPlaceholders: withPlaceholders }),
});
const services = isPending || error || !data ? [] : data.services;

View File

@@ -9,7 +9,7 @@ import useServicesList from "./useServicesList.tsx";
import { Text } from "@mantine/core";
const useServicesState = () => {
const { services, refetch } = useServicesList();
const { services, refetch } = useServicesList({ withPlaceholders: true });
const onCreateClick = () => {
modals.openContextModal({
@@ -27,7 +27,7 @@ const useServicesState = () => {
notifications.guess(ok, { message: message });
if (!ok) return;
await refetch();
}
},
);
};
@@ -45,7 +45,7 @@ const useServicesState = () => {
ServiceService.createServiceCategory({
requestBody: { category: category },
}).then(({ ok, message }) =>
notifications.guess(ok, { message: message })
notifications.guess(ok, { message: message }),
);
};