refactor(cms): deduplicate shared admin components and fix studio batch completion
- fix(studio): stop markBatchDone infinite recursion so batches complete - refactor(api): merge api-response into api and drop the duplicate module - refactor(media): extract shared media loader and URL validator - refactor(ui): extract shared LoadingSpinner for site and admin groups - refactor(dates): consolidate raw date formatting into formatDate util - refactor(logs): share a single generic log-list loader across tables - refactor(theme): merge both ColorField components and reuse contrast helpers - refactor(import): extract shared ImportErrorBanner and SearchInput - chore(): remove dead theme-editor-tabs after inlining tab components
This commit is contained in:
1 parent
b12e405b34
commit
8c12fc6c60
93 files changed
+1354
-912
No files matched your search
@@ -1,15 +1,5 @@
|
|||||||
export default function FriendsLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function GuildForumLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function SiteLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function MessagesLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function NewsLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function ShopLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--color-primary)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ import {
|
|||||||
RotateCcw,
|
RotateCcw,
|
||||||
Rows3,
|
Rows3,
|
||||||
Save,
|
Save,
|
||||||
Search,
|
|
||||||
Trash2,
|
Trash2,
|
||||||
X,
|
X,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
@@ -48,6 +47,7 @@ import { BulkImportItems } from "@/components/admin/catalog/bulk-import-items";
|
|||||||
import { ItemsShopPreview } from "@/components/admin/catalog/items-shop-preview";
|
import { ItemsShopPreview } from "@/components/admin/catalog/items-shop-preview";
|
||||||
import { QuickAddFurni } from "@/components/admin/catalog/quick-add-furni";
|
import { QuickAddFurni } from "@/components/admin/catalog/quick-add-furni";
|
||||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||||
|
import { SearchInput } from "@/components/admin/search-input";
|
||||||
import {
|
import {
|
||||||
CurrencyIcon,
|
CurrencyIcon,
|
||||||
currencyKindFromPointsType,
|
currencyKindFromPointsType,
|
||||||
@@ -1082,24 +1082,12 @@ export function CatalogItemsTable({
|
|||||||
|
|
||||||
{/* Search bar */}
|
{/* Search bar */}
|
||||||
{items.length > 0 && (
|
{items.length > 0 && (
|
||||||
<div className="relative">
|
<SearchInput
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input
|
|
||||||
placeholder="Filter by name, classname, item ID..."
|
placeholder="Filter by name, classname, item ID..."
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={setSearchQuery}
|
||||||
className="pl-9 h-9"
|
onClear={() => setSearchQuery("")}
|
||||||
/>
|
/>
|
||||||
{searchQuery && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => setSearchQuery("")}
|
|
||||||
>
|
|
||||||
<X className="h-4 w-4" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
|||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { db, EmulatorErrors } from "@/lib/db";
|
import { db, EmulatorErrors } from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
export default async function EmulatorErrorsPage({
|
export default async function EmulatorErrorsPage({
|
||||||
@@ -55,7 +56,7 @@ export default async function EmulatorErrorsPage({
|
|||||||
#{error.id}
|
#{error.id}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{new Date(error.timestamp * 1000).toLocaleString()}
|
{formatDate(new Date(error.timestamp * 1000))}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<pre className="text-xs whitespace-pre-wrap break-all font-mono bg-muted p-2 rounded">
|
<pre className="text-xs whitespace-pre-wrap break-all font-mono bg-muted p-2 rounded">
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Badge } from "@/components/ui/badge";
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { fetchOpsHealth } from "@/lib/admin/ops-health";
|
import { fetchOpsHealth } from "@/lib/admin/ops-health";
|
||||||
import { db, EmulatorErrors, EmulatorSettings } from "@/lib/db";
|
import { db, EmulatorErrors, EmulatorSettings } from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
import { HealthCheckClient } from "./health-check-client";
|
import { HealthCheckClient } from "./health-check-client";
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ export default async function DevOpsPage() {
|
|||||||
#{error.id}
|
#{error.id}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{new Date(error.timestamp * 1000).toLocaleString()}
|
{formatDate(new Date(error.timestamp * 1000))}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<pre className="text-xs whitespace-pre-wrap break-all font-mono text-destructive">
|
<pre className="text-xs whitespace-pre-wrap break-all font-mono text-destructive">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface Registration {
|
interface Registration {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -36,7 +37,7 @@ export function EventRegistrations({ registrations }: Props) {
|
|||||||
>
|
>
|
||||||
<span className="text-sm font-medium">{r.username}</span>
|
<span className="text-sm font-medium">{r.username}</span>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{new Date(r.createdAt).toLocaleString()}
|
{formatDate(new Date(r.createdAt))}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface Winner {
|
interface Winner {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -93,7 +94,7 @@ export function EventWinnersManager({ eventId, winners }: Props) {
|
|||||||
</span>
|
</span>
|
||||||
<span className="font-medium text-sm">{w.username}</span>
|
<span className="font-medium text-sm">{w.username}</span>
|
||||||
<span className="text-xs text-muted-foreground ml-auto">
|
<span className="text-xs text-muted-foreground ml-auto">
|
||||||
{new Date(w.createdAt).toLocaleDateString()}
|
{formatDate(new Date(w.createdAt), "date")}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { AdminBreadcrumb } from "@/components/admin/admin-breadcrumb";
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { db, User, WebsiteEvent, WebsiteEventType } from "@/lib/db";
|
import { db, User, WebsiteEvent, WebsiteEventType } from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
import { EventForm } from "../event-form";
|
import { EventForm } from "../event-form";
|
||||||
import { EventPrizesManager } from "./event-prizes";
|
import { EventPrizesManager } from "./event-prizes";
|
||||||
@@ -94,7 +95,7 @@ export default async function EventDetailPage({
|
|||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<p className="m-0 mt-1 text-sm text-[var(--admin-text-muted)]">
|
<p className="m-0 mt-1 text-sm text-[var(--admin-text-muted)]">
|
||||||
{event.type.name} · {new Date(event.startsAt).toLocaleString()}
|
{event.type.name} · {formatDate(new Date(event.startsAt))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ export default async function EventDetailPage({
|
|||||||
{event.endsAt && (
|
{event.endsAt && (
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{t("endsAt", {
|
{t("endsAt", {
|
||||||
date: new Date(event.endsAt).toLocaleString(),
|
date: formatDate(new Date(event.endsAt)),
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Link from "@/components/link";
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import type { DataTableColumn, PaginatedResult } from "@/types/common";
|
import type { DataTableColumn, PaginatedResult } from "@/types/common";
|
||||||
|
|
||||||
interface EventRow {
|
interface EventRow {
|
||||||
@@ -86,7 +87,7 @@ export function EventsTable({ data }: EventsTableProps) {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
{new Date(value as unknown as string).toLocaleString()}
|
{formatDate(new Date(value as unknown as string))}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface ThreadMessage {
|
interface ThreadMessage {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -162,7 +163,7 @@ export function AdminHelpTicketDetail({
|
|||||||
{msg.isStaff ? ` (${t("staffBadge")})` : ""}
|
{msg.isStaff ? ` (${t("staffBadge")})` : ""}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-[10px] text-muted-foreground">
|
<span className="text-[10px] text-muted-foreground">
|
||||||
{new Date(msg.createdAt).toLocaleString()}
|
{formatDate(new Date(msg.createdAt))}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -308,11 +309,11 @@ export function AdminHelpTicketDetail({
|
|||||||
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
||||||
<div className="flex justify-between gap-2">
|
<div className="flex justify-between gap-2">
|
||||||
<span>{t("colCreated")}</span>
|
<span>{t("colCreated")}</span>
|
||||||
<span>{new Date(ticket.createdAt).toLocaleString()}</span>
|
<span>{formatDate(new Date(ticket.createdAt))}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between gap-2">
|
<div className="flex justify-between gap-2">
|
||||||
<span>{t("colUpdated")}</span>
|
<span>{t("colUpdated")}</span>
|
||||||
<span>{new Date(ticket.updatedAt).toLocaleString()}</span>
|
<span>{formatDate(new Date(ticket.updatedAt))}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between gap-2">
|
<div className="flex justify-between gap-2">
|
||||||
<span>{t("messageCountLabel")}</span>
|
<span>{t("messageCountLabel")}</span>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
|
||||||
BadgeCheck,
|
BadgeCheck,
|
||||||
Check,
|
Check,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { ImportErrorBanner } from "@/components/admin/import-error-banner";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -348,12 +348,7 @@ export function ImportBadgesClient() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Error */}
|
{/* Error */}
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Loading skeleton */}
|
{/* Loading skeleton */}
|
||||||
{loading && badges.length === 0 && (
|
{loading && badges.length === 0 && (
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
|
||||||
Check,
|
Check,
|
||||||
CloudDownload,
|
CloudDownload,
|
||||||
Download,
|
Download,
|
||||||
@@ -16,6 +15,7 @@ import {
|
|||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||||
|
import { ImportErrorBanner } from "@/components/admin/import-error-banner";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -782,12 +782,7 @@ function FurniGrid({ source }: FurniGridProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Error */}
|
{/* Error */}
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Empty state */}
|
{/* Empty state */}
|
||||||
{!loading && items.length === 0 && !error && (
|
{!loading && items.length === 0 && !error && (
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
|
||||||
Check,
|
Check,
|
||||||
Download,
|
Download,
|
||||||
Loader2,
|
Loader2,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { ImportErrorBanner } from "@/components/admin/import-error-banner";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -361,12 +361,7 @@ function LibsView() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!loading && items.length === 0 && !error && (
|
{!loading && items.length === 0 && !error && (
|
||||||
<div className="text-center py-12 text-muted-foreground">
|
<div className="text-center py-12 text-muted-foreground">
|
||||||
@@ -749,12 +744,7 @@ function SetsView() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!loading && items.length === 0 && !error && (
|
{!loading && items.length === 0 && !error && (
|
||||||
<div className="text-center py-12 text-muted-foreground">
|
<div className="text-center py-12 text-muted-foreground">
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
|
||||||
Check,
|
Check,
|
||||||
Download,
|
Download,
|
||||||
Loader2,
|
Loader2,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { ImportErrorBanner } from "@/components/admin/import-error-banner";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -314,12 +314,7 @@ export function ImportEffectsClient() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Error */}
|
{/* Error */}
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Empty */}
|
{/* Empty */}
|
||||||
{!loading && visible.length === 0 && !error && (
|
{!loading && visible.length === 0 && !error && (
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
|
||||||
Check,
|
Check,
|
||||||
Download,
|
Download,
|
||||||
Loader2,
|
Loader2,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { ImportErrorBanner } from "@/components/admin/import-error-banner";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -293,12 +293,7 @@ export function ImportPetsClient() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && (
|
{error && <ImportErrorBanner error={error} />}
|
||||||
<div className="rounded-lg border px-4 py-3 text-sm bg-destructive/10 border-destructive/20 text-destructive flex items-center gap-2">
|
|
||||||
<AlertCircle className="w-4 h-4 shrink-0" />
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!loading && pets.length === 0 && !error && (
|
{!loading && pets.length === 0 && !error && (
|
||||||
<div className="text-center py-12 text-muted-foreground">
|
<div className="text-center py-12 text-muted-foreground">
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
export default function AdminLoading() {
|
import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||||
return (
|
|
||||||
<div
|
export default function Loading() {
|
||||||
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
return <LoadingSpinner accentVar="var(--admin-accent)" />;
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="animate-spin w-8 h-8 border-4 rounded-full"
|
|
||||||
style={{
|
|
||||||
borderColor: "var(--admin-accent)",
|
|
||||||
borderTopColor: "transparent",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -34,6 +34,7 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
const CFH_STATES: Record<number, { label: string; class: string }> = {
|
const CFH_STATES: Record<number, { label: string; class: string }> = {
|
||||||
0: {
|
0: {
|
||||||
@@ -130,7 +131,7 @@ export function CfhDetail({
|
|||||||
</div>
|
</div>
|
||||||
<h1 className="text-xl font-bold">Call For Help Report</h1>
|
<h1 className="text-xl font-bold">Call For Help Report</h1>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{new Date(ticket.timestamp * 1000).toLocaleString()} · Room #
|
{formatDate(new Date(ticket.timestamp * 1000))} · Room #
|
||||||
{ticket.roomId}
|
{ticket.roomId}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -317,7 +318,7 @@ export function CfhDetail({
|
|||||||
<p className="font-medium">{ban.reason || "No reason"}</p>
|
<p className="font-medium">{ban.reason || "No reason"}</p>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
{ban.type} · by {ban.staff} ·{" "}
|
{ban.type} · by {ban.staff} ·{" "}
|
||||||
{new Date(ban.timestamp * 1000).toLocaleDateString()}
|
{formatDate(new Date(ban.timestamp * 1000), "date")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -431,9 +432,7 @@ export function CfhDetail({
|
|||||||
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span>Created</span>
|
<span>Created</span>
|
||||||
<span>
|
<span>{formatDate(new Date(ticket.timestamp * 1000))}</span>
|
||||||
{new Date(ticket.timestamp * 1000).toLocaleString()}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span>Room</span>
|
<span>Room</span>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
User,
|
User,
|
||||||
WebsiteTicket,
|
WebsiteTicket,
|
||||||
} from "@/lib/db";
|
} from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
export default async function ModTeamPage() {
|
export default async function ModTeamPage() {
|
||||||
@@ -169,7 +170,7 @@ export default async function ModTeamPage() {
|
|||||||
{member.online === "1"
|
{member.online === "1"
|
||||||
? "Online"
|
? "Online"
|
||||||
: member.lastOnline
|
: member.lastOnline
|
||||||
? new Date(member.lastOnline * 1000).toLocaleDateString()
|
? formatDate(new Date(member.lastOnline * 1000), "date")
|
||||||
: "—"}
|
: "—"}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
Crown,
|
Crown,
|
||||||
Loader2,
|
Loader2,
|
||||||
Save,
|
Save,
|
||||||
Search,
|
|
||||||
Settings,
|
Settings,
|
||||||
Shield,
|
Shield,
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
@@ -19,6 +18,7 @@ import {
|
|||||||
saveRank as saveRankAction,
|
saveRank as saveRankAction,
|
||||||
setCmsPermissions,
|
setCmsPermissions,
|
||||||
} from "@/actions/permissions";
|
} from "@/actions/permissions";
|
||||||
|
import { SearchInput } from "@/components/admin/search-input";
|
||||||
import Link from "@/components/link";
|
import Link from "@/components/link";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -521,15 +521,11 @@ export function RankEditClient({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="relative">
|
<SearchInput
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input
|
|
||||||
placeholder="Search permissions..."
|
placeholder="Search permissions..."
|
||||||
value={permSearch}
|
value={permSearch}
|
||||||
onChange={(e) => setPermSearch(e.target.value)}
|
onChange={setPermSearch}
|
||||||
className="pl-9"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<PermSection title="Commands" keys={cats.commands} sectionKey="cmd" />
|
<PermSection title="Commands" keys={cats.commands} sectionKey="cmd" />
|
||||||
<PermSection title="Account" keys={cats.account} sectionKey="acc" />
|
<PermSection title="Account" keys={cats.account} sectionKey="acc" />
|
||||||
@@ -606,15 +602,11 @@ export function RankEditClient({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="relative">
|
<SearchInput
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input
|
|
||||||
placeholder="Search CMS permissions..."
|
placeholder="Search CMS permissions..."
|
||||||
value={cmsSearch}
|
value={cmsSearch}
|
||||||
onChange={(e) => setCmsSearch(e.target.value)}
|
onChange={setCmsSearch}
|
||||||
className="pl-9"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{filteredCms.map((perm) => {
|
{filteredCms.map((perm) => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Link from "@/components/link";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
||||||
import { CameraWeb, db, User } from "@/lib/db";
|
import { CameraWeb, db, User } from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
export default async function AdminPhotos({
|
export default async function AdminPhotos({
|
||||||
@@ -133,11 +134,7 @@ export default async function AdminPhotos({
|
|||||||
>
|
>
|
||||||
{t("byUser", { username })}
|
{t("byUser", { username })}
|
||||||
</Link>{" "}
|
</Link>{" "}
|
||||||
·{" "}
|
· {formatDate(new Date(p.timestamp * 1000))}
|
||||||
{new Date(p.timestamp * 1000)
|
|
||||||
.toISOString()
|
|
||||||
.slice(0, 16)
|
|
||||||
.replace("T", " ")}
|
|
||||||
</p>
|
</p>
|
||||||
{canEdit ? (
|
{canEdit ? (
|
||||||
<form
|
<form
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Link from "@/components/link";
|
|||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import type { DataTableColumn, PaginatedResult } from "@/types/common";
|
import type { DataTableColumn, PaginatedResult } from "@/types/common";
|
||||||
|
|
||||||
interface PollRow {
|
interface PollRow {
|
||||||
@@ -93,7 +94,7 @@ export function PollsTable({ data }: PollsTableProps) {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
{new Date(value as unknown as string).toLocaleDateString()}
|
{formatDate(new Date(value as unknown as string), "date")}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
import { PrefixDialog } from "./prefix-dialog";
|
import { PrefixDialog } from "./prefix-dialog";
|
||||||
import {
|
import {
|
||||||
@@ -314,7 +315,7 @@ export function PrefixesClient({ canEdit }: { canEdit: boolean }) {
|
|||||||
<TableCell>{prefix.active ? "Yes" : "No"}</TableCell>
|
<TableCell>{prefix.active ? "Yes" : "No"}</TableCell>
|
||||||
<TableCell className="text-xs">
|
<TableCell className="text-xs">
|
||||||
{prefix.created_at
|
{prefix.created_at
|
||||||
? new Date(prefix.created_at).toLocaleDateString()
|
? formatDate(new Date(prefix.created_at), "date")
|
||||||
: "—"}
|
: "—"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Search, Trash2 } from "lucide-react";
|
import { Trash2 } from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
createSetting,
|
createSetting,
|
||||||
deleteSetting,
|
deleteSetting,
|
||||||
updateSetting,
|
updateSetting,
|
||||||
} from "@/actions/admin-settings";
|
} from "@/actions/admin-settings";
|
||||||
|
import { SearchInput } from "@/components/admin/search-input";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { MANAGED_SETTING_KEYS } from "./cms-settings-config";
|
import { MANAGED_SETTING_KEYS } from "./cms-settings-config";
|
||||||
@@ -64,15 +65,11 @@ export function AdvancedSettingsPanel({
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="relative">
|
<SearchInput
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
||||||
<Input
|
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={setQuery}
|
||||||
placeholder="Search keys, values, comments…"
|
placeholder="Search keys, values, comments…"
|
||||||
className="pl-9"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
{canEdit ? (
|
{canEdit ? (
|
||||||
<form
|
<form
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export function ColorField({
|
|
||||||
name,
|
|
||||||
label,
|
|
||||||
description,
|
|
||||||
defaultValue,
|
|
||||||
}: {
|
|
||||||
name: string;
|
|
||||||
label: string;
|
|
||||||
description: string;
|
|
||||||
defaultValue: string;
|
|
||||||
backgroundColorKey?: string;
|
|
||||||
}) {
|
|
||||||
const [val, setVal] = useState(defaultValue);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="rounded-lg p-2">
|
|
||||||
<div className="flex items-start gap-2">
|
|
||||||
<input
|
|
||||||
type="color"
|
|
||||||
name={name}
|
|
||||||
value={val}
|
|
||||||
onChange={(e) => setVal(e.target.value)}
|
|
||||||
className="w-[42px] h-[36px] p-0 border-none bg-none cursor-pointer flex-shrink-0 rounded"
|
|
||||||
/>
|
|
||||||
<div className="flex flex-col min-w-0 flex-1">
|
|
||||||
<div className="flex items-baseline justify-between gap-2">
|
|
||||||
<span className="text-sm font-semibold text-[var(--admin-text)] leading-tight">
|
|
||||||
{label}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<span className="text-xs text-[var(--admin-text-muted)] leading-snug line-clamp-2">
|
|
||||||
{description}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -7,13 +7,13 @@ import {
|
|||||||
saveCustomTheme,
|
saveCustomTheme,
|
||||||
saveTheme,
|
saveTheme,
|
||||||
} from "@/actions/admin-theme";
|
} from "@/actions/admin-theme";
|
||||||
|
import { ColorField } from "@/components/admin/color-field";
|
||||||
import { RenameTheme } from "@/components/admin/theme/rename-theme";
|
import { RenameTheme } from "@/components/admin/theme/rename-theme";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||||
import { siteSettings } from "@/lib/services/site-settings";
|
import { siteSettings } from "@/lib/services/site-settings";
|
||||||
import { listCustomThemes } from "@/lib/theme-custom-store";
|
import { listCustomThemes } from "@/lib/theme-custom-store";
|
||||||
import { FONTS, PRESETS } from "@/lib/theme-presets";
|
import { FONTS, PRESETS } from "@/lib/theme-presets";
|
||||||
import { ColorField } from "./color-field";
|
|
||||||
|
|
||||||
export const metadata = { title: "Theme" };
|
export const metadata = { title: "Theme" };
|
||||||
|
|
||||||
@@ -297,13 +297,13 @@ function colorFields(
|
|||||||
{fields.map((f) => {
|
{fields.map((f) => {
|
||||||
const val = toHex(current[f.key], f.def);
|
const val = toHex(current[f.key], f.def);
|
||||||
const bgKey = f.bgKey ? `${f.bgKey}${suffix}` : undefined;
|
const bgKey = f.bgKey ? `${f.bgKey}${suffix}` : undefined;
|
||||||
// eslint-disable-next-line security/detect-object-injection -- bgKey derived from hardcoded field list
|
|
||||||
const bgValue = bgKey ? toHex(current[bgKey], "") : undefined;
|
const bgValue = bgKey ? toHex(current[bgKey], "") : undefined;
|
||||||
return (
|
return (
|
||||||
<ColorField
|
<ColorField
|
||||||
key={f.key}
|
key={f.key}
|
||||||
field={f}
|
label={f.label}
|
||||||
value={val}
|
description={f.desc}
|
||||||
|
defaultValue={val}
|
||||||
bgValue={bgValue || undefined}
|
bgValue={bgValue || undefined}
|
||||||
name={`${f.key}${suffix}`}
|
name={`${f.key}${suffix}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { TICKET_PRIORITIES, TICKET_STATUSES } from "@/lib/validators/ticket";
|
import { TICKET_PRIORITIES, TICKET_STATUSES } from "@/lib/validators/ticket";
|
||||||
|
|
||||||
interface TicketMessage {
|
interface TicketMessage {
|
||||||
@@ -215,7 +216,7 @@ export function AdminTicketDetail({
|
|||||||
{msg.isStaff && " (Staff)"}
|
{msg.isStaff && " (Staff)"}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-[10px] text-muted-foreground">
|
<span className="text-[10px] text-muted-foreground">
|
||||||
{new Date(msg.createdAt).toLocaleString()}
|
{formatDate(new Date(msg.createdAt))}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -276,7 +277,7 @@ export function AdminTicketDetail({
|
|||||||
<div className="border-t p-4 text-center text-sm text-muted-foreground">
|
<div className="border-t p-4 text-center text-sm text-muted-foreground">
|
||||||
Ticket closed{" "}
|
Ticket closed{" "}
|
||||||
{ticket.closedAt
|
{ticket.closedAt
|
||||||
? `on ${new Date(ticket.closedAt).toLocaleDateString()}`
|
? `on ${formatDate(new Date(ticket.closedAt), "date")}`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -413,9 +414,10 @@ export function AdminTicketDetail({
|
|||||||
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||||
<Calendar className="h-3 w-3" />
|
<Calendar className="h-3 w-3" />
|
||||||
Registered{" "}
|
Registered{" "}
|
||||||
{new Date(
|
{formatDate(
|
||||||
ticket.creator.accountCreated * 1000,
|
new Date(ticket.creator.accountCreated * 1000),
|
||||||
).toLocaleDateString()}
|
"date",
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -428,12 +430,12 @@ export function AdminTicketDetail({
|
|||||||
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
<CardContent className="space-y-2 text-xs text-muted-foreground">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span>Created</span>
|
<span>Created</span>
|
||||||
<span>{new Date(ticket.createdAt).toLocaleString()}</span>
|
<span>{formatDate(new Date(ticket.createdAt))}</span>
|
||||||
</div>
|
</div>
|
||||||
{ticket.closedAt && (
|
{ticket.closedAt && (
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span>Closed</span>
|
<span>Closed</span>
|
||||||
<span>{new Date(ticket.closedAt).toLocaleString()}</span>
|
<span>{formatDate(new Date(ticket.closedAt))}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { MessageSquare, Terminal } from "lucide-react";
|
|||||||
import Link from "@/components/link";
|
import Link from "@/components/link";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface ChatMessage {
|
interface ChatMessage {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -25,13 +26,7 @@ interface UserActivityLogProps {
|
|||||||
|
|
||||||
function formatTime(ts: number) {
|
function formatTime(ts: number) {
|
||||||
if (!ts) return "-";
|
if (!ts) return "-";
|
||||||
const d = new Date(ts * 1000);
|
return formatDate(new Date(ts * 1000));
|
||||||
return d.toLocaleString(undefined, {
|
|
||||||
day: "2-digit",
|
|
||||||
month: "short",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserActivityLog({
|
export function UserActivityLog({
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { useServerAction } from "@/hooks/use-server-action";
|
import { useServerAction } from "@/hooks/use-server-action";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface BanInfo {
|
interface BanInfo {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -110,7 +111,7 @@ export function UserBanSection({
|
|||||||
By {activeBan.staffName} ·{" "}
|
By {activeBan.staffName} ·{" "}
|
||||||
{activeBan.banExpire === 0
|
{activeBan.banExpire === 0
|
||||||
? "Permanent"
|
? "Permanent"
|
||||||
: `Expires ${new Date(activeBan.banExpire * 1000).toLocaleString()}`}
|
: `Expires ${formatDate(new Date(activeBan.banExpire * 1000))}`}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -174,7 +175,7 @@ export function UserBanSection({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs text-muted-foreground">
|
<span className="text-xs text-muted-foreground">
|
||||||
{new Date(ban.timestamp * 1000).toLocaleDateString()}
|
{formatDate(new Date(ban.timestamp * 1000), "date")}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
import Link from "@/components/link";
|
import Link from "@/components/link";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
|
||||||
interface UserAccountInfoProps {
|
interface UserAccountInfoProps {
|
||||||
user: {
|
user: {
|
||||||
@@ -36,14 +37,7 @@ export function UserAccountInfo({ user }: UserAccountInfoProps) {
|
|||||||
<Calendar className="h-4 w-4 text-muted-foreground shrink-0" />
|
<Calendar className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||||
<span className="text-muted-foreground">Registered</span>
|
<span className="text-muted-foreground">Registered</span>
|
||||||
<span className="ml-auto font-medium">
|
<span className="ml-auto font-medium">
|
||||||
{new Date(user.accountCreated * 1000).toLocaleDateString(
|
{formatDate(new Date(user.accountCreated * 1000), "date")}
|
||||||
"it-IT",
|
|
||||||
{
|
|
||||||
day: "2-digit",
|
|
||||||
month: "short",
|
|
||||||
year: "numeric",
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3 text-sm">
|
<div className="flex items-center gap-3 text-sm">
|
||||||
@@ -51,16 +45,7 @@ export function UserAccountInfo({ user }: UserAccountInfoProps) {
|
|||||||
<span className="text-muted-foreground">Last Login</span>
|
<span className="text-muted-foreground">Last Login</span>
|
||||||
<span className="ml-auto font-medium">
|
<span className="ml-auto font-medium">
|
||||||
{user.lastLogin
|
{user.lastLogin
|
||||||
? new Date(user.lastLogin * 1000).toLocaleDateString(
|
? formatDate(new Date(user.lastLogin * 1000))
|
||||||
"it-IT",
|
|
||||||
{
|
|
||||||
day: "2-digit",
|
|
||||||
month: "short",
|
|
||||||
year: "numeric",
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: "Never"}
|
: "Never"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
|||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import { hostname } from "node:os";
|
import { hostname } from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permission-slugs";
|
import { PERMS } from "@/lib/permission-slugs";
|
||||||
import {
|
import {
|
||||||
catalogStateRoot,
|
catalogStateRoot,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { publicCatalogConfig } from "@/lib/services/catalog-git-config";
|
import { publicCatalogConfig } from "@/lib/services/catalog-git-config";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import {
|
import {
|
||||||
catalogueAssetDirectories,
|
catalogueAssetDirectories,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import {
|
import {
|
||||||
catalogueAssetDirectories,
|
catalogueAssetDirectories,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { loadCatalogItemsData } from "@/lib/services/catalog-items-loader";
|
import { loadCatalogItemsData } from "@/lib/services/catalog-items-loader";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { getHabboGamedataHotel } from "@/lib/services/habbo-gamedata-hotel";
|
import { getHabboGamedataHotel } from "@/lib/services/habbo-gamedata-hotel";
|
||||||
import { batchLookupByClassnames } from "@/lib/services/habbofurni";
|
import { batchLookupByClassnames } from "@/lib/services/habbofurni";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { asc, count, eq, inArray, like, or } from "drizzle-orm";
|
import { asc, count, eq, inArray, like, or } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { CatalogItemsBc, CatalogPages, CatalogPagesBc, db } from "@/lib/db";
|
import { CatalogItemsBc, CatalogPages, CatalogPagesBc, db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { setCsrfCookie } from "@/lib/foundation/security";
|
import { setCsrfCookie } from "@/lib/foundation/security";
|
||||||
|
|
||||||
export const GET = withAdmin({ requireCsrf: false }, async () => {
|
export const GET = withAdmin({ requireCsrf: false }, async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { asc, eq, like, or } from "drizzle-orm";
|
import { asc, eq, like, or } from "drizzle-orm";
|
||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { db, ItemsBase } from "@/lib/db";
|
import { db, ItemsBase } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { getGamedataRoot } from "@/lib/services/furni-asset-dirs";
|
import { getGamedataRoot } from "@/lib/services/furni-asset-dirs";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { getGamedataRoot } from "@/lib/services/furni-asset-dirs";
|
import { getGamedataRoot } from "@/lib/services/furni-asset-dirs";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { extractFurniIconPng } from "@/lib/services/clone-icon";
|
import { extractFurniIconPng } from "@/lib/services/clone-icon";
|
||||||
import { getSource } from "@/lib/services/clone-sources";
|
import { getSource } from "@/lib/services/clone-sources";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { importClothingSet } from "@/lib/services/clothing-set-import";
|
import { importClothingSet } from "@/lib/services/clothing-set-import";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import {
|
import {
|
||||||
getClothingSetList,
|
getClothingSetList,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { addSize32AllNitros } from "@/lib/services/repair-nitros";
|
import { addSize32AllNitros } from "@/lib/services/repair-nitros";
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { existsSync, promises as fs } from "node:fs";
|
import { existsSync, promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { db, ItemsBase } from "@/lib/db";
|
import { db, ItemsBase } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
|
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { getSource } from "@/lib/services/clone-sources";
|
import { getSource } from "@/lib/services/clone-sources";
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { existsSync, promises as fs } from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { eq, sql } from "drizzle-orm";
|
import { eq, sql } from "drizzle-orm";
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db, ItemsBase } from "@/lib/db";
|
import { db, ItemsBase } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
import { asc, inArray, sql } from "drizzle-orm";
|
import { asc, inArray, sql } from "drizzle-orm";
|
||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { db, ItemsBase } from "@/lib/db";
|
import { db, ItemsBase } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { existsSync, promises as fs } from "node:fs";
|
import { existsSync, promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { eq, sql } from "drizzle-orm";
|
import { eq, sql } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db, ItemsBase } from "@/lib/db";
|
import { db, ItemsBase } from "@/lib/db";
|
||||||
import { normalizeClassname } from "@/lib/furni/classname";
|
import { normalizeClassname } from "@/lib/furni/classname";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { uploadSingleFurni } from "@/lib/services/upload-import";
|
import { uploadSingleFurni } from "@/lib/services/upload-import";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { verifyAndFixInteractionModesCount } from "@/lib/services/furni-import";
|
import { verifyAndFixInteractionModesCount } from "@/lib/services/furni-import";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import { runSseBatch } from "@/lib/services/import/core/sse-batch";
|
import { runSseBatch } from "@/lib/services/import/core/sse-batch";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logAudit } from "@/lib/services/audit";
|
import { logAudit } from "@/lib/services/audit";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import { revalidateTag } from "next/cache";
|
import { revalidateTag } from "next/cache";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { AclModelRole, db } from "@/lib/db";
|
import { AclModelRole, db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { and, eq } from "drizzle-orm";
|
|||||||
import type { ResultSetHeader } from "mysql2";
|
import type { ResultSetHeader } from "mysql2";
|
||||||
import { revalidateTag } from "next/cache";
|
import { revalidateTag } from "next/cache";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { apiError } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError } from "@/lib/api-response";
|
|
||||||
import { AclModelPermission, AclModelRole, AclRole, db } from "@/lib/db";
|
import { AclModelPermission, AclModelRole, AclRole, db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { eq, like, or } from "drizzle-orm";
|
import { eq, like, or } from "drizzle-orm";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiOk } from "@/lib/api-response";
|
|
||||||
import {
|
import {
|
||||||
db,
|
db,
|
||||||
Guilds,
|
Guilds,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import { desc, eq } from "drizzle-orm";
|
import { desc, eq } from "drizzle-orm";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { db, Soundtracks } from "@/lib/db";
|
import { db, Soundtracks } from "@/lib/db";
|
||||||
import { logger } from "@/lib/logger";
|
import { logger } from "@/lib/logger";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
||||||
import { PERMS } from "@/lib/permission-slugs";
|
import { PERMS } from "@/lib/permission-slugs";
|
||||||
import { stageFurnitureAttachment } from "@/lib/services/furni-attachment";
|
import { stageFurnitureAttachment } from "@/lib/services/furni-attachment";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { after } from "next/server";
|
import { after } from "next/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
||||||
import { PERMS } from "@/lib/permission-slugs";
|
import { PERMS } from "@/lib/permission-slugs";
|
||||||
import { redis } from "@/lib/redis";
|
import { redis } from "@/lib/redis";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
||||||
import { PERMS } from "@/lib/permission-slugs";
|
import { PERMS } from "@/lib/permission-slugs";
|
||||||
import { inspectFurniture } from "@/lib/services/furniture-inspection";
|
import { inspectFurniture } from "@/lib/services/furniture-inspection";
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import {
|
import {
|
||||||
inspectNitroScales,
|
inspectNitroScales,
|
||||||
object,
|
object,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { createHash, randomUUID } from "node:crypto";
|
import { createHash, randomUUID } from "node:crypto";
|
||||||
import { promises as fs } from "node:fs";
|
import { promises as fs } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import { generateScale32 } from "@/lib/furni/nitro-scale32";
|
import { generateScale32 } from "@/lib/furni/nitro-scale32";
|
||||||
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
import { validateClassnames } from "@/lib/furni/studio-inspection";
|
||||||
import { PERMS } from "@/lib/permission-slugs";
|
import { PERMS } from "@/lib/permission-slugs";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { apiError, apiOk } from "@/lib/api";
|
||||||
import { withAdmin } from "@/lib/api-handler";
|
import { withAdmin } from "@/lib/api-handler";
|
||||||
import { apiError, apiOk } from "@/lib/api-response";
|
|
||||||
import type {
|
import type {
|
||||||
SourceAssetCheck,
|
SourceAssetCheck,
|
||||||
SourceAssetItem,
|
SourceAssetItem,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { type CfhRow, CfhTable } from "@/app/admin/moderation/cfh/cfh-table";
|
|||||||
import { requireModPermission } from "@/lib/admin/guard";
|
import { requireModPermission } from "@/lib/admin/guard";
|
||||||
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
||||||
import { db, SupportTickets, User } from "@/lib/db";
|
import { db, SupportTickets, User } from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
import { logServerError } from "@/lib/server-log";
|
import { logServerError } from "@/lib/server-log";
|
||||||
|
|
||||||
@@ -143,10 +144,7 @@ export default async function ModCfhListPage({
|
|||||||
issue: ticket.issue,
|
issue: ticket.issue,
|
||||||
roomId: ticket.roomId,
|
roomId: ticket.roomId,
|
||||||
when: ticket.timestamp
|
when: ticket.timestamp
|
||||||
? new Date(ticket.timestamp * 1000)
|
? formatDate(new Date(ticket.timestamp * 1000))
|
||||||
.toISOString()
|
|
||||||
.slice(0, 16)
|
|
||||||
.replace("T", " ")
|
|
||||||
: "—",
|
: "—",
|
||||||
sender: userMap.get(ticket.senderId) ?? "—",
|
sender: userMap.get(ticket.senderId) ?? "—",
|
||||||
senderId: ticket.senderId,
|
senderId: ticket.senderId,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
User,
|
User,
|
||||||
WebsiteTicket,
|
WebsiteTicket,
|
||||||
} from "@/lib/db";
|
} from "@/lib/db";
|
||||||
|
import { formatDate } from "@/lib/format-date";
|
||||||
import { PERMS } from "@/lib/permissions";
|
import { PERMS } from "@/lib/permissions";
|
||||||
|
|
||||||
export default async function ModTeamLitePage() {
|
export default async function ModTeamLitePage() {
|
||||||
@@ -157,7 +158,7 @@ export default async function ModTeamLitePage() {
|
|||||||
{member.online === "1"
|
{member.online === "1"
|
||||||
? "Online"
|
? "Online"
|
||||||
: member.lastOnline
|
: member.lastOnline
|
||||||
? new Date(member.lastOnline * 1000).toLocaleDateString()
|
? formatDate(new Date(member.lastOnline * 1000), "date")
|
||||||
: "—"}
|
: "—"}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,6 @@
|
|||||||
import { AlertCircle } from "lucide-react";
|
import { AlertCircle } from "lucide-react";
|
||||||
|
|
||||||
|
/** Shared destructive banner for the import/admin clients. */
|
||||||
export function ImportErrorBanner({ error }: { error: string }) {
|
export function ImportErrorBanner({ error }: { error: string }) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -5,20 +5,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|||||||
import { deleteMedia, uploadMedia } from "@/actions/admin-media";
|
import { deleteMedia, uploadMedia } from "@/actions/admin-media";
|
||||||
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
import { useConfirmDialog } from "@/components/admin/confirm-dialog";
|
||||||
import { formatDate } from "@/lib/format-date";
|
import { formatDate } from "@/lib/format-date";
|
||||||
|
import type { MediaFile } from "@/lib/media-files";
|
||||||
type MediaFile = {
|
import { loadMediaFiles, validImageUrl } from "@/lib/media-files";
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
size: number;
|
|
||||||
uploaded: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
function validImageUrl(url: string): string {
|
|
||||||
if (!url.startsWith("/")) return "";
|
|
||||||
if (/[<>"']/.test(url)) return "";
|
|
||||||
if (/(data|javascript|vbscript|file):/i.test(url)) return "";
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatSize(bytes: number): string {
|
function formatSize(bytes: number): string {
|
||||||
if (bytes < 1024) return `${bytes} B`;
|
if (bytes < 1024) return `${bytes} B`;
|
||||||
@@ -47,13 +35,7 @@ export function AdminMediaGrid() {
|
|||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
setFiles(await loadMediaFiles());
|
||||||
const res = await fetch("/api/media");
|
|
||||||
const data = await res.json();
|
|
||||||
setFiles(data.files ?? []);
|
|
||||||
} catch {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,39 @@
|
|||||||
|
import { Search, X } from "lucide-react";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
|
||||||
|
type SearchInputProps = {
|
||||||
|
value: string;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
placeholder?: string;
|
||||||
|
onClear?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Admin search field with a leading search icon and optional clear button. */
|
||||||
|
export function SearchInput({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
placeholder,
|
||||||
|
onClear,
|
||||||
|
}: SearchInputProps) {
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
||||||
|
<Input
|
||||||
|
placeholder={placeholder}
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
className="pl-9 h-9"
|
||||||
|
/>
|
||||||
|
{value && onClear && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClear}
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||||
|
aria-label="Clear search"
|
||||||
|
>
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
type LoadingSpinnerProps = {
|
||||||
|
className?: string;
|
||||||
|
accentVar?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Centered pulsing spinner used across site and admin loading.tsx placeholders. */
|
||||||
|
export function LoadingSpinner({
|
||||||
|
className,
|
||||||
|
accentVar = "var(--color-primary)",
|
||||||
|
}: LoadingSpinnerProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{ display: "flex", justifyContent: "center", padding: "4rem 0" }}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="animate-spin w-8 h-8 border-4 rounded-full"
|
||||||
|
style={{
|
||||||
|
borderColor: accentVar,
|
||||||
|
borderTopColor: "transparent",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
|
|
||||||
/** Standard success response: { ok: true, ...data } */
|
|
||||||
export function apiOk(data?: Record<string, unknown>) {
|
|
||||||
return NextResponse.json({ ok: true, ...data });
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Standard error response: { error: message } with given status */
|
|
||||||
export function apiError(message: string, status: number = 400) {
|
|
||||||
return NextResponse.json({ error: message }, { status });
|
|
||||||
}
|
|
||||||
+18
-1
@@ -1,5 +1,22 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { apiUnavailable, pagination, positiveBigInt } from "@/lib/api";
|
import { apiOk, apiUnavailable, pagination, positiveBigInt } from "@/lib/api";
|
||||||
|
|
||||||
|
describe("apiOk", () => {
|
||||||
|
it("returns a BigInt-safe success envelope with ok: true", async () => {
|
||||||
|
const response = apiOk({ id: 9007199254740993n });
|
||||||
|
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
expect(response.headers.get("cache-control")).toBe("no-store");
|
||||||
|
await expect(response.json()).resolves.toEqual({
|
||||||
|
ok: true,
|
||||||
|
id: "9007199254740993",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows empty payloads", async () => {
|
||||||
|
await expect(apiOk().json()).resolves.toEqual({ ok: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("apiUnavailable", () => {
|
describe("apiUnavailable", () => {
|
||||||
it("returns a no-store 503 error without exposing internal details", async () => {
|
it("returns a no-store 503 error without exposing internal details", async () => {
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ export function apiJson(data: unknown, init?: ResponseInit): NextResponse {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Standard success envelope: { ok: true, ...data }. */
|
||||||
|
export function apiOk(data?: Record<string, unknown>): NextResponse {
|
||||||
|
return apiJson({ ok: true, ...data });
|
||||||
|
}
|
||||||
|
|
||||||
/** Standard error envelope. */
|
/** Standard error envelope. */
|
||||||
export function apiError(message: string, status = 400): NextResponse {
|
export function apiError(message: string, status = 400): NextResponse {
|
||||||
return apiJson({ error: message }, { status });
|
return apiJson({ error: message }, { status });
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export type MediaFile = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
size: number;
|
||||||
|
uploaded: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Only allow safe, relative /api/media URLs as image src. */
|
||||||
|
export function validImageUrl(url: string): string {
|
||||||
|
if (!url.startsWith("/")) return "";
|
||||||
|
if (/[<>"']/.test(url)) return "";
|
||||||
|
if (/(data|javascript|vbscript|file):/i.test(url)) return "";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load the media library from /api/media, tolerating transient failures. */
|
||||||
|
export async function loadMediaFiles(): Promise<MediaFile[]> {
|
||||||
|
try {
|
||||||
|
const res = await fetch("/api/media");
|
||||||
|
const data = await res.json();
|
||||||
|
return Array.isArray(data?.files) ? (data.files as MediaFile[]) : [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user