feat: quiz
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import { Can } from "@/components/staff-context";
|
||||
import { toast } from "sonner";
|
||||
import { api, AdminError, type AdminReport, type ReportType } from "@/lib/api";
|
||||
import { usePagedList } from "@/lib/use-paged-list";
|
||||
@@ -46,7 +47,11 @@ export default function ReportsPage() {
|
||||
if (r.type === "post") {
|
||||
return (
|
||||
<>
|
||||
<Button size="sm" variant="outline" onClick={() => run(api.hidePost(r.target_id), "Post hidden.")}>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => run(api.hidePost(r.target_id), "Post hidden.")}
|
||||
>
|
||||
Hide
|
||||
</Button>
|
||||
<Button
|
||||
@@ -56,7 +61,8 @@ export default function ReportsPage() {
|
||||
if (
|
||||
await confirm({
|
||||
title: "Delete this post?",
|
||||
message: "It will be removed from the app. You can undo this.",
|
||||
message:
|
||||
"It will be removed from the app. You can undo this.",
|
||||
confirmLabel: "Delete post",
|
||||
destructive: true,
|
||||
})
|
||||
@@ -79,7 +85,8 @@ export default function ReportsPage() {
|
||||
if (
|
||||
await confirm({
|
||||
title: "Delete this comment?",
|
||||
message: "It will be removed from the thread. You can undo this.",
|
||||
message:
|
||||
"It will be removed from the thread. You can undo this.",
|
||||
confirmLabel: "Delete comment",
|
||||
destructive: true,
|
||||
})
|
||||
@@ -100,7 +107,8 @@ export default function ReportsPage() {
|
||||
if (
|
||||
await confirm({
|
||||
title: "Suspend this account?",
|
||||
message: "They'll be signed out and unable to log in. You can undo this.",
|
||||
message:
|
||||
"They'll be signed out and unable to log in. You can undo this.",
|
||||
confirmLabel: "Suspend account",
|
||||
destructive: true,
|
||||
})
|
||||
@@ -122,7 +130,8 @@ export default function ReportsPage() {
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
if (r.type === "post") run(api.restorePost(r.target_id), "Post restored.");
|
||||
if (r.type === "post")
|
||||
run(api.restorePost(r.target_id), "Post restored.");
|
||||
else if (r.type === "comment")
|
||||
run(api.restoreComment(r.target_id), "Comment restored.");
|
||||
else run(api.unbanUser(r.target_id), "Account restored.");
|
||||
@@ -134,7 +143,11 @@ export default function ReportsPage() {
|
||||
}
|
||||
|
||||
const targetLabel =
|
||||
type === "user" ? "Reported account" : type === "comment" ? "Comment" : "Post";
|
||||
type === "user"
|
||||
? "Reported account"
|
||||
: type === "comment"
|
||||
? "Comment"
|
||||
: "Post";
|
||||
|
||||
return (
|
||||
<ListShell
|
||||
@@ -187,7 +200,9 @@ export default function ReportsPage() {
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<div className="line-clamp-2">{r.target_text || "—"}</div>
|
||||
<div className="line-clamp-2">
|
||||
{r.target_text || "—"}
|
||||
</div>
|
||||
{r.target_author_handle ? (
|
||||
<div className="mt-0.5 text-xs text-muted-foreground">
|
||||
by @{r.target_author_handle}
|
||||
@@ -231,13 +246,15 @@ export default function ReportsPage() {
|
||||
) : (
|
||||
<div className="flex flex-wrap justify-end gap-2">
|
||||
{r.target_removed ? undoButton(r) : modButton(r)}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => setResolveTarget(r)}
|
||||
>
|
||||
Resolve
|
||||
</Button>
|
||||
<Can perm="reports:resolve">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => setResolveTarget(r)}
|
||||
>
|
||||
Resolve
|
||||
</Button>
|
||||
</Can>
|
||||
</div>
|
||||
)}
|
||||
</TD>
|
||||
@@ -281,7 +298,9 @@ function ResolveModal({
|
||||
setNote("");
|
||||
onDone();
|
||||
} catch (err) {
|
||||
toast.error(err instanceof AdminError ? err.message : "Could not resolve.");
|
||||
toast.error(
|
||||
err instanceof AdminError ? err.message : "Could not resolve.",
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user