Skip to content

Commit

Permalink
♻️ Refactor : change fetch -> mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
codingaring committed May 12, 2024
1 parent e1c5d03 commit fd3e932
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/common/Modals/RenameModal/RenameModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ import { RenameFolderProps } from "../ModalProp";
import { MouseEvent } from "react";
import { useInputValue } from "@hooks/useInputValue";
import { putRenameFolder } from "@data-access/axios/putRenameFolder";
import { useMutation } from "@tanstack/react-query";

export function RenameModal({
handleCloseModal,
selectFolderId,
}: RenameFolderProps) {
const { insertValue, onChange } = useInputValue();
const renameFolderMutation = useMutation({
mutationFn: ({
folderId,
folderTitle,
}: {
folderId: number;
folderTitle: string;
}) => putRenameFolder({ folderId, folderTitle }),
});

async function handleRenameFolder(event: MouseEvent<HTMLButtonElement>) {
if (insertValue) {
const result = await putRenameFolder({
renameFolderMutation.mutate({
folderId: selectFolderId,
folderTitle: insertValue,
});
Expand Down

0 comments on commit fd3e932

Please sign in to comment.