Skip to content

Commit

Permalink
fix: move invalidate to onSuccess
Browse files Browse the repository at this point in the history
  • Loading branch information
arian81 committed Jan 3, 2025
1 parent fe1f3b7 commit 4ec039e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pages/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ const AdminCard = ({

const Admin: NextPage = () => {
const { mutateAsync: setKillSwitch } = trpc.admin.setKillSwitch.useMutation();
const { mutateAsync: setDhYear } = trpc.admin.setDhYear.useMutation();
const { mutateAsync: setDhYear } = trpc.admin.setDhYear.useMutation({
onSuccess: () => {
utils.admin.getDhYear.invalidate();
},
});
const { data: currentDhYear } = trpc.admin.getDhYear.useQuery();
const utils = trpc.useUtils();

const handleYearChange = async (newYear: string) => {
try {
await setDhYear(newYear);
await utils.admin.getDhYear.invalidate();
} catch (error) {
console.error("Failed to update DH year:", error);
}
Expand Down

0 comments on commit 4ec039e

Please sign in to comment.