mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 03:38:17 +00:00
feat(WIP): filtering, exporting and more reports
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import {
|
||||
operationsStandardsService,
|
||||
type OperationsStandardsPatch,
|
||||
} from "@/services/operationsStandards.service";
|
||||
import { useErrorHandler } from "@/shared/hooks/useErrorHandler";
|
||||
|
||||
const QUERY_KEY = ["operationsStandards"];
|
||||
|
||||
export const useOperationsStandardsQuery = () =>
|
||||
useQuery({
|
||||
queryKey: QUERY_KEY,
|
||||
queryFn: () => operationsStandardsService.get(),
|
||||
});
|
||||
|
||||
export const useUpdateOperationsStandards = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
const { handleError } = useErrorHandler(t);
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (patch: OperationsStandardsPatch) =>
|
||||
operationsStandardsService.update(patch),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: QUERY_KEY });
|
||||
toast.success(
|
||||
t("operationsStandards.updated", "Operating standards updated"),
|
||||
);
|
||||
},
|
||||
onError: handleError,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user