feat : add stygian guide
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTransition } from "react";
|
||||
import { RefreshCwIcon } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { syncStygianArchiveAction } from "@/app/admin/stygian/actions";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
|
||||
export function StygianSyncButton() {
|
||||
const router = useRouter();
|
||||
const [pending, startTransition] = useTransition();
|
||||
return (
|
||||
<Button disabled={pending} onClick={() => startTransition(async () => {
|
||||
const result = await syncStygianArchiveAction();
|
||||
if (result.status === "error") toast.error(result.message);
|
||||
else {
|
||||
toast.success(`Imported through ${result.imported.at(-1) ?? "none"}; stopped at ${result.stoppedAt}`);
|
||||
router.refresh();
|
||||
}
|
||||
})}>
|
||||
{pending ? <Spinner data-icon="inline-start" /> : <RefreshCwIcon data-icon="inline-start" />}
|
||||
Sync archive
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user