-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a refresh button to /admin/manage/irasuto
Signed-off-by: Vu Van Dung <me@joulev.dev>
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use server"; | ||
|
||
import { revalidateTag } from "next/cache"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await -- Server actions must be async | ||
export async function refreshIrasuto() { | ||
revalidateTag("photos"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use client"; | ||
|
||
import { RotateCcw } from "~/components/icons"; | ||
import { Button } from "~/components/ui/button"; | ||
import { useTransitionWithNProgress } from "~/lib/hooks/use-transition-with-nprogress"; | ||
|
||
import { refreshIrasuto } from "./refresh-action"; | ||
|
||
export function RefreshButton() { | ||
const startTransition = useTransitionWithNProgress(); | ||
const refresh = () => startTransition(refreshIrasuto); | ||
return ( | ||
<Button onClick={refresh}> | ||
<RotateCcw /> Force-refresh | ||
</Button> | ||
); | ||
} |