aboutsummaryrefslogtreecommitdiff
path: root/src/components/hooks/queries/useUpdateQuery.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-24 13:09:50 +0000
committerFuwn <[email protected]>2026-01-24 13:09:50 +0000
commit396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b (patch)
treeb9df4ca6a70db45cfffbae6fdd7252e20fb8e93c /src/components/hooks/queries/useUpdateQuery.ts
downloadumami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.tar.xz
umami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.zip
Initial commitHEADmain
Created from https://vercel.com/new
Diffstat (limited to 'src/components/hooks/queries/useUpdateQuery.ts')
-rw-r--r--src/components/hooks/queries/useUpdateQuery.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/components/hooks/queries/useUpdateQuery.ts b/src/components/hooks/queries/useUpdateQuery.ts
new file mode 100644
index 0000000..85a9442
--- /dev/null
+++ b/src/components/hooks/queries/useUpdateQuery.ts
@@ -0,0 +1,15 @@
+import { useToast } from '@umami/react-zen';
+import type { ApiError } from '@/lib/types';
+import { useApi } from '../useApi';
+import { useModified } from '../useModified';
+
+export function useUpdateQuery(path: string, params?: Record<string, any>) {
+ const { post, useMutation } = useApi();
+ const query = useMutation<any, ApiError, Record<string, any>>({
+ mutationFn: (data: Record<string, any>) => post(path, { ...data, ...params }),
+ });
+ const { touch } = useModified();
+ const { toast } = useToast();
+
+ return { ...query, touch, toast };
+}