Files
sorsfonalak/services/frontend/src/app/forum/valaszok/ReadAll.tsx
T

32 lines
741 B
TypeScript
Raw Normal View History

"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api } from "@/lib/api";
/** "Mind olvasott": the answers stay in the list, the count on the tab goes. */
export function ReadAll() {
const router = useRouter();
const [busy, setBusy] = useState(false);
return (
<button
type="button"
className="btn btn-ghost btn-sm"
disabled={busy}
onClick={async () => {
setBusy(true);
try {
await api("/forum/replies/read", { method: "POST" });
window.dispatchEvent(new Event("forum:nav"));
router.refresh();
} finally {
setBusy(false);
}
}}
>
Mind olvasott
</button>
);
}