Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ const eslintConfig = [
},
},
...storybook.configs["flat/recommended"],
// 260612 ์ถ”๊ฐ€ : ๊ณต์‹๋ฌธ์„œ ์ฐธ๊ณ 
{
rules: {
"react/no-unescaped-entities": "off",
"@next/next/no-page-custom-font": "off",
},
},
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
];

export default eslintConfig;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint-config-next": "15.4.10",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-storybook": "^10.0.8",
"eslint-plugin-testing-library": "^7.13.4",
"globals": "^16.5.0",
Expand Down
47 changes: 47 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 8 additions & 43 deletions src/hooks/queries/goals/useDeleteGoalMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { deleteGoal } from "@/api/goal";
import goalsQueryKeys from "./queryKeys";
import { useRouter } from "next/navigation";
import { Goal, GoalResponse } from "@/api/types/goal";
import { toast } from "sonner";

type GoalsCache =
| { nextCursor: number | null; totalCount: number; goals: Goal[] }
Expand All @@ -23,63 +24,27 @@ export function useDeleteGoalMutation() {
await queryClient.cancelQueries({
queryKey: goalsQueryKeys.detail(goalId),
});
await queryClient.cancelQueries({
queryKey: goalsQueryKeys.list(),
});

await queryClient.cancelQueries({
queryKey: goalsQueryKeys.infinite(),
});

queryClient.setQueriesData<GoalsCache>(
{ queryKey: goalsQueryKeys.list() },
(old) => {
if (!old?.goals) return old;
return {
...old,
totalCount: old.totalCount - 1,
goals: old.goals.filter((goal) => goal.id !== goalId),
};
},
);

queryClient.setQueriesData<InfiniteData<GoalResponse>>(
{ queryKey: goalsQueryKeys.infinite() },
(old) => {
if (!old?.pages) return old;
return {
...old,
pages: old.pages.map((page) => ({
...page,
totalCount: page.totalCount - 1,
goals: page.goals.filter((goal) => goal.id !== goalId),
})),
};
},
);

queryClient.removeQueries({
queryKey: goalsQueryKeys.detail(goalId),
});
},

onSuccess: () => {
queryClient.invalidateQueries({
queryKey: goalsQueryKeys.list(),
});
queryClient.invalidateQueries({
queryKey: goalsQueryKeys.infinite(),
});

router.replace("/dashboard");
},

onSettled: () => {
queryClient.invalidateQueries({ queryKey: goalsQueryKeys.list() });
queryClient.invalidateQueries({ queryKey: goalsQueryKeys.infinite() });
},

onError: () => {
queryClient.invalidateQueries({
queryKey: goalsQueryKeys.list(),
});
queryClient.invalidateQueries({
queryKey: goalsQueryKeys.infinite(),
});
toast.error("์‚ญ์ œ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.");
},
});
}
Loading