feat: prettier
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {ServiceService} from "../../../client";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ServiceService } from "../../../client";
|
||||
|
||||
const useServiceCategoriesList = () => {
|
||||
const {isPending, error, data, refetch} = useQuery({
|
||||
queryKey: ['getAllServiceCategories'],
|
||||
const { isPending, error, data, refetch } = useQuery({
|
||||
queryKey: ["getAllServiceCategories"],
|
||||
queryFn: ServiceService.getAllServiceCategories,
|
||||
});
|
||||
const categories = isPending || error || !data ? [] : data.categories;
|
||||
|
||||
return {categories, refetch}
|
||||
}
|
||||
return { categories, refetch };
|
||||
};
|
||||
|
||||
export default useServiceCategoriesList;
|
||||
export default useServiceCategoriesList;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import ObjectList from "../../../hooks/objectList.tsx";
|
||||
import { ServiceService } from "../../../client";
|
||||
|
||||
const useServicePriceCategoriesList = () => ObjectList({
|
||||
queryFn: ServiceService.getAllPriceCategories,
|
||||
getObjectsFn: (response) => response.priceCategories,
|
||||
queryKey: "getAllPriceCategories",
|
||||
});
|
||||
const useServicePriceCategoriesList = () =>
|
||||
ObjectList({
|
||||
queryFn: ServiceService.getAllPriceCategories,
|
||||
getObjectsFn: response => response.priceCategories,
|
||||
queryKey: "getAllPriceCategories",
|
||||
});
|
||||
|
||||
export default useServicePriceCategoriesList;
|
||||
export default useServicePriceCategoriesList;
|
||||
|
||||
@@ -1,62 +1,45 @@
|
||||
import UseObjectState from "../../../types/UseObjectState.ts";
|
||||
import { type ServicePriceCategorySchema, ServiceService } from "../../../client";
|
||||
import {
|
||||
type ServicePriceCategorySchema,
|
||||
ServiceService,
|
||||
} from "../../../client";
|
||||
import useServicePriceCategoriesList from "./useServicePriceCategoriesList.tsx";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { notifications } from "../../../shared/lib/notifications.ts";
|
||||
|
||||
const useServicePriceCategoryState = (): UseObjectState<ServicePriceCategorySchema> => {
|
||||
const { objects, refetch } = useServicePriceCategoriesList();
|
||||
const onCreateClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "servicePriceCategoryForm",
|
||||
title: "Создание категории цен",
|
||||
withCloseButton: false,
|
||||
innerProps: {
|
||||
onCreate,
|
||||
},
|
||||
});
|
||||
};
|
||||
const onCreate = (values: ServicePriceCategorySchema) => {
|
||||
console.log(ServiceService);
|
||||
ServiceService.createPriceCategory({
|
||||
requestBody: {
|
||||
name: values.name,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
};
|
||||
const onDelete = (item: ServicePriceCategorySchema) => {
|
||||
modals.openConfirmModal({
|
||||
title: "Удаление категории",
|
||||
children: "Вы уверены, что хотите удалить категорию?",
|
||||
onConfirm: () => {
|
||||
|
||||
ServiceService.deletePriceCategory({
|
||||
requestBody: {
|
||||
id: item.id,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
const onChange = (item: ServicePriceCategorySchema) => {
|
||||
modals.openContextModal({
|
||||
modal: "servicePriceCategoryForm",
|
||||
title: "Изменение категории цен",
|
||||
withCloseButton: false,
|
||||
innerProps: {
|
||||
onChange: (values: ServicePriceCategorySchema) => {
|
||||
ServiceService.updatePriceCategory({
|
||||
const useServicePriceCategoryState =
|
||||
(): UseObjectState<ServicePriceCategorySchema> => {
|
||||
const { objects, refetch } = useServicePriceCategoriesList();
|
||||
const onCreateClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "servicePriceCategoryForm",
|
||||
title: "Создание категории цен",
|
||||
withCloseButton: false,
|
||||
innerProps: {
|
||||
onCreate,
|
||||
},
|
||||
});
|
||||
};
|
||||
const onCreate = (values: ServicePriceCategorySchema) => {
|
||||
console.log(ServiceService);
|
||||
ServiceService.createPriceCategory({
|
||||
requestBody: {
|
||||
name: values.name,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
};
|
||||
const onDelete = (item: ServicePriceCategorySchema) => {
|
||||
modals.openConfirmModal({
|
||||
title: "Удаление категории",
|
||||
children: "Вы уверены, что хотите удалить категорию?",
|
||||
onConfirm: () => {
|
||||
ServiceService.deletePriceCategory({
|
||||
requestBody: {
|
||||
id: item.id,
|
||||
name: values.name,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
@@ -64,17 +47,37 @@ const useServicePriceCategoryState = (): UseObjectState<ServicePriceCategorySche
|
||||
await refetch();
|
||||
});
|
||||
},
|
||||
element: item,
|
||||
},
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
const onChange = (item: ServicePriceCategorySchema) => {
|
||||
modals.openContextModal({
|
||||
modal: "servicePriceCategoryForm",
|
||||
title: "Изменение категории цен",
|
||||
withCloseButton: false,
|
||||
innerProps: {
|
||||
onChange: (values: ServicePriceCategorySchema) => {
|
||||
ServiceService.updatePriceCategory({
|
||||
requestBody: {
|
||||
id: item.id,
|
||||
name: values.name,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
},
|
||||
element: item,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
onCreateClick,
|
||||
onCreate,
|
||||
onDelete,
|
||||
onChange,
|
||||
objects,
|
||||
return {
|
||||
onCreateClick,
|
||||
onCreate,
|
||||
onDelete,
|
||||
onChange,
|
||||
objects,
|
||||
};
|
||||
};
|
||||
};
|
||||
export default useServicePriceCategoryState;
|
||||
export default useServicePriceCategoryState;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import ObjectList from "../../../hooks/objectList.tsx";
|
||||
import {ServiceService} from "../../../client";
|
||||
import { ServiceService } from "../../../client";
|
||||
|
||||
const useServicesKitsList = () => ObjectList({
|
||||
queryFn: ServiceService.getAllServicesKits,
|
||||
getObjectsFn: (response) => response.servicesKits,
|
||||
queryKey: "getAllServicesKits"
|
||||
})
|
||||
const useServicesKitsList = () =>
|
||||
ObjectList({
|
||||
queryFn: ServiceService.getAllServicesKits,
|
||||
getObjectsFn: response => response.servicesKits,
|
||||
queryKey: "getAllServicesKits",
|
||||
});
|
||||
|
||||
export default useServicesKitsList;
|
||||
export default useServicesKitsList;
|
||||
|
||||
@@ -5,7 +5,8 @@ import { modals } from "@mantine/modals";
|
||||
import useServicesKitsList from "./useServicesKitsList.tsx";
|
||||
|
||||
const useServicesKitsState = () => {
|
||||
const { objects: servicesKits, refetch: refetchKits } = useServicesKitsList();
|
||||
const { objects: servicesKits, refetch: refetchKits } =
|
||||
useServicesKitsList();
|
||||
|
||||
const onKitCreate = (kit: GetServiceKitSchema) => {
|
||||
ServiceService.createServicesKit({
|
||||
@@ -54,4 +55,4 @@ const useServicesKitsState = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export default useServicesKitsState;
|
||||
export default useServicesKitsState;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {ServiceService} from "../../../client";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ServiceService } from "../../../client";
|
||||
|
||||
const useServicesList = () => {
|
||||
const {isPending, error, data, refetch} = useQuery({
|
||||
queryKey: ['getAllServices'],
|
||||
queryFn: ServiceService.getAllServices
|
||||
const { isPending, error, data, refetch } = useQuery({
|
||||
queryKey: ["getAllServices"],
|
||||
queryFn: ServiceService.getAllServices,
|
||||
});
|
||||
const services = isPending || error || !data ? [] : data.services;
|
||||
|
||||
return {services, refetch}
|
||||
}
|
||||
export default useServicesList;
|
||||
return { services, refetch };
|
||||
};
|
||||
export default useServicesList;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { modals } from "@mantine/modals";
|
||||
import { ServiceCategorySchema, ServiceSchema, ServiceService } from "../../../client";
|
||||
import {
|
||||
ServiceCategorySchema,
|
||||
ServiceSchema,
|
||||
ServiceService,
|
||||
} from "../../../client";
|
||||
import { notifications } from "../../../shared/lib/notifications.ts";
|
||||
import useServicesList from "./useServicesList.tsx";
|
||||
import { Text } from "@mantine/core";
|
||||
@@ -18,12 +22,13 @@ const useServicesState = () => {
|
||||
});
|
||||
};
|
||||
const onCreate = (values: ServiceSchema) => {
|
||||
ServiceService.createService({ requestBody: { service: values } })
|
||||
.then(async ({ ok, message }) => {
|
||||
ServiceService.createService({ requestBody: { service: values } }).then(
|
||||
async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const onCreateCategoryClick = () => {
|
||||
@@ -37,24 +42,29 @@ const useServicesState = () => {
|
||||
});
|
||||
};
|
||||
const onCategoryCreate = (category: ServiceCategorySchema) => {
|
||||
ServiceService.createServiceCategory({ requestBody: { category: category } })
|
||||
.then(({ ok, message }) =>
|
||||
notifications.guess(ok, { message: message }));
|
||||
ServiceService.createServiceCategory({
|
||||
requestBody: { category: category },
|
||||
}).then(({ ok, message }) =>
|
||||
notifications.guess(ok, { message: message })
|
||||
);
|
||||
};
|
||||
|
||||
const onServiceDelete = (service: ServiceSchema) => {
|
||||
modals.openConfirmModal({
|
||||
title: "Удаление услуги",
|
||||
children: (<Text>
|
||||
Вы уверены, что хотите удалить услугу "{service.name}"?
|
||||
</Text>),
|
||||
children: (
|
||||
<Text>
|
||||
Вы уверены, что хотите удалить услугу "{service.name}"?
|
||||
</Text>
|
||||
),
|
||||
onConfirm: () => {
|
||||
ServiceService.deleteService({ requestBody: { serviceId: service.id } })
|
||||
.then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
ServiceService.deleteService({
|
||||
requestBody: { serviceId: service.id },
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
},
|
||||
labels: {
|
||||
confirm: "Удалить",
|
||||
@@ -64,17 +74,15 @@ const useServicesState = () => {
|
||||
};
|
||||
|
||||
const onServiceUpdate = (service: ServiceSchema) => {
|
||||
ServiceService
|
||||
.updateService({
|
||||
requestBody: {
|
||||
data: service,
|
||||
},
|
||||
})
|
||||
.then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
ServiceService.updateService({
|
||||
requestBody: {
|
||||
data: service,
|
||||
},
|
||||
}).then(async ({ ok, message }) => {
|
||||
notifications.guess(ok, { message: message });
|
||||
if (!ok) return;
|
||||
await refetch();
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -86,4 +94,4 @@ const useServicesState = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export default useServicesState;
|
||||
export default useServicesState;
|
||||
|
||||
Reference in New Issue
Block a user