mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 05:07:15 +01:00
15 lines
554 B
TypeScript
15 lines
554 B
TypeScript
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 };
|
|
}
|