feat: a few tabs for module, deal services tab for mobiles
This commit is contained in:
@ -0,0 +1,49 @@
|
||||
import { useCrudOperations } from "@/hooks/cruds/baseCrud";
|
||||
import {
|
||||
CreateServiceSchema,
|
||||
ServiceSchema,
|
||||
UpdateServiceSchema,
|
||||
} from "@/lib/client";
|
||||
import {
|
||||
createServiceMutation,
|
||||
deleteServiceMutation,
|
||||
updateServiceMutation,
|
||||
} from "@/lib/client/@tanstack/react-query.gen";
|
||||
|
||||
type UseServicesProps = {
|
||||
queryKey: any[];
|
||||
};
|
||||
|
||||
export type ServicesCrud = {
|
||||
onCreate: (service: CreateServiceSchema) => void;
|
||||
onUpdate: (
|
||||
serviceId: number,
|
||||
service: UpdateServiceSchema,
|
||||
onSuccess?: () => void
|
||||
) => void;
|
||||
onDelete: (service: ServiceSchema) => void;
|
||||
};
|
||||
|
||||
export const useServicesCrud = ({
|
||||
queryKey,
|
||||
}: UseServicesProps): ServicesCrud => {
|
||||
return useCrudOperations<
|
||||
ServiceSchema,
|
||||
UpdateServiceSchema,
|
||||
CreateServiceSchema
|
||||
>({
|
||||
key: "getServices",
|
||||
queryKey,
|
||||
mutations: {
|
||||
create: createServiceMutation(),
|
||||
update: updateServiceMutation(),
|
||||
delete: deleteServiceMutation(),
|
||||
},
|
||||
getUpdateEntity: (old, update) =>
|
||||
({
|
||||
...old,
|
||||
...update,
|
||||
}) as ServiceSchema,
|
||||
getDeleteConfirmTitle: () => "Удаление услуги",
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user