mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-01 13:33:26 +00:00
refactor: migrate from most of the custom hooks into the api.ts
This commit is contained in:
@@ -19,7 +19,8 @@ import type {
|
||||
FileUploadSetting,
|
||||
} from "@/types/fileUploadSettings";
|
||||
import { getMinFiles } from "@/types/fileUploadSettings";
|
||||
import { useReplaceFileUploadFields } from "@/hooks/useFileUploadSettings";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { api } from "@/services/api";
|
||||
|
||||
export interface ManageFileUploadFieldsDialogProps {
|
||||
setting: FileUploadSetting;
|
||||
@@ -77,7 +78,9 @@ export default function ManageFileUploadFieldsDialog({
|
||||
|
||||
const [fields, setFields] = useState<DraftField[]>(seed);
|
||||
|
||||
const replaceMutation = useReplaceFileUploadFields();
|
||||
const replaceMutation = useMutation(
|
||||
api.fileUploadSettings.replaceFields.mutationOptions(),
|
||||
);
|
||||
|
||||
const update = (i: number, patch: Partial<DraftField>) =>
|
||||
setFields((prev) =>
|
||||
@@ -145,7 +148,7 @@ export default function ManageFileUploadFieldsDialog({
|
||||
}));
|
||||
|
||||
replaceMutation.mutate(
|
||||
{ settingId: setting.id, fields: payload },
|
||||
{ id: setting.id, fields: payload },
|
||||
{
|
||||
onSuccess: () => setOpen(false),
|
||||
onError: (err) =>
|
||||
|
||||
Reference in New Issue
Block a user