diff options
Diffstat (limited to 'src/components/hooks/queries/useUpdateQuery.ts')
| -rw-r--r-- | src/components/hooks/queries/useUpdateQuery.ts | 15 |
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 }; +} |