Skip to content

Commit 5a48dee

Browse files
♻️ refactor(mutations): clean up types
1 parent b4591d6 commit 5a48dee

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

‎src/frontend/components/app/form/schema/_RenderFormInput.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ export function RenderFormInput(props: IRenderFormInputProps) {
127127
}
128128
}
129129
// TODO: Rating Input (for contributors)
130+
// sliders

‎src/frontend/lib/data/useMutate/types.d.ts

-16
This file was deleted.

‎src/frontend/lib/data/useMutate/useApiMutateOptimisticOptions.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { MessageDescriptor } from "@lingui/core";
12
import { msg } from "@lingui/macro";
23
import { useMutation, useQueryClient } from "@tanstack/react-query";
34

@@ -6,7 +7,21 @@ import { noop } from "@/shared/lib/noop";
67
import { fakeMessageDescriptor } from "@/translations/fake";
78

89
import { getQueryCachekey } from "../constants/getQueryCacheKey";
9-
import type { IApiMutateOptions } from "./types";
10+
11+
export type ToastMessageInput = {
12+
description: MessageDescriptor;
13+
// action?: { label: MessageDescriptor; action: () => void };
14+
};
15+
16+
export interface IApiMutateOptions<T, V, R> {
17+
dataQueryPath: string;
18+
otherEndpoints?: string[];
19+
onMutate: (oldData: T | undefined, form: V) => T;
20+
mutationFn: (form: V) => Promise<R>;
21+
successMessage?: ToastMessageInput;
22+
smartSuccessMessage?: (formData: R) => ToastMessageInput;
23+
onSuccessActionWithFormData?: (formData: R) => void;
24+
}
1025

1126
function useApiMutate<T>(endpoint: string) {
1227
const queryClient = useQueryClient();

0 commit comments

Comments
 (0)