feat(admin): items_base browser and AdminPageShell on core pages
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
7138ae4445
commit
98613af875
42 files changed
+2196
-698
No files matched your search
+101
-97
@@ -1,6 +1,8 @@
|
||||
import { Shield } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { AdminPageShell } from "@/components/admin/admin-page-shell";
|
||||
import { AdminSimplePager } from "@/components/admin/admin-simple-pager";
|
||||
import { StatusCard } from "@/components/admin/dashboard";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -104,103 +106,105 @@ export default async function AdminGuildsPage({
|
||||
);
|
||||
|
||||
return (
|
||||
<main>
|
||||
{loadError ? (
|
||||
<div className="mb-4 rounded-lg bg-[var(--admin-error-subtle)] p-3 text-xs text-[var(--admin-error)]">
|
||||
{t("loadError")}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<form className="mb-4 flex gap-2" method="get">
|
||||
<input
|
||||
type="search"
|
||||
name="search"
|
||||
defaultValue={q}
|
||||
placeholder={t("searchPlaceholder")}
|
||||
className="admin-input flex-1"
|
||||
/>
|
||||
<Button type="submit" variant="default" size="sm">
|
||||
{t("search")}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
||||
<StatusCard label={t("totalGuilds")} value={total} icon="🛡️" />
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h2 className="admin-section-title">
|
||||
{t("title")} ({total})
|
||||
</h2>
|
||||
{rows.length === 0 ? (
|
||||
<div className="admin-empty">{t("empty")}</div>
|
||||
) : (
|
||||
<div className="admin-card overflow-x-auto" style={{ padding: 0 }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("colId")}</th>
|
||||
<th>{t("colBadge")}</th>
|
||||
<th>{t("colName")}</th>
|
||||
<th>{t("colOwner")}</th>
|
||||
<th>{t("colMembers")}</th>
|
||||
<th>{t("colCreated")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((g) => (
|
||||
<tr key={g.id}>
|
||||
<td className="muted">{g.id}</td>
|
||||
<td>
|
||||
{g.badge ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`https://habbo-stories-content.s3.amazonaws.com/badge-part-images/${g.badge}.gif`}
|
||||
alt=""
|
||||
width={40}
|
||||
height={40}
|
||||
className="h-10 w-10 object-contain"
|
||||
/>
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<Link
|
||||
href={`/admin/guilds/${g.id}`}
|
||||
className="font-medium hover:underline"
|
||||
>
|
||||
{g.name || `#${g.id}`}
|
||||
</Link>
|
||||
{g.description ? (
|
||||
<div className="muted text-xs line-clamp-1 max-w-xs">
|
||||
{g.description}
|
||||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td>
|
||||
<Link href={`/admin/users/show/${g.userId}`}>
|
||||
{ownerById.get(g.userId) ?? `#${g.userId}`}
|
||||
</Link>
|
||||
</td>
|
||||
<td>{membersByGuild.get(g.id) ?? 0}</td>
|
||||
<td className="muted">
|
||||
{formatDate(new Date(g.dateCreated * 1000), "date")}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<AdminPageShell icon={Shield} title={t("title")} subtitle={t("subtitle")}>
|
||||
<main>
|
||||
{loadError ? (
|
||||
<div className="mb-4 rounded-lg bg-[var(--admin-error-subtle)] p-3 text-xs text-[var(--admin-error)]">
|
||||
{t("loadError")}
|
||||
</div>
|
||||
)}
|
||||
<AdminSimplePager
|
||||
page={pagination.page}
|
||||
lastPage={pagination.lastPage}
|
||||
total={total}
|
||||
basePath="/admin/guilds"
|
||||
params={q ? { search: q } : undefined}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
) : null}
|
||||
|
||||
<form className="mb-4 flex gap-2" method="get">
|
||||
<input
|
||||
type="search"
|
||||
name="search"
|
||||
defaultValue={q}
|
||||
placeholder={t("searchPlaceholder")}
|
||||
className="admin-input flex-1"
|
||||
/>
|
||||
<Button type="submit" variant="default" size="sm">
|
||||
{t("search")}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
||||
<StatusCard label={t("totalGuilds")} value={total} icon="🛡️" />
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h2 className="admin-section-title">
|
||||
{t("listHeading", { count: total })}
|
||||
</h2>
|
||||
{rows.length === 0 ? (
|
||||
<div className="admin-empty">{t("empty")}</div>
|
||||
) : (
|
||||
<div className="admin-card overflow-x-auto" style={{ padding: 0 }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("colId")}</th>
|
||||
<th>{t("colBadge")}</th>
|
||||
<th>{t("colName")}</th>
|
||||
<th>{t("colOwner")}</th>
|
||||
<th>{t("colMembers")}</th>
|
||||
<th>{t("colCreated")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((g) => (
|
||||
<tr key={g.id}>
|
||||
<td className="muted">{g.id}</td>
|
||||
<td>
|
||||
{g.badge ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`https://habbo-stories-content.s3.amazonaws.com/badge-part-images/${g.badge}.gif`}
|
||||
alt=""
|
||||
width={40}
|
||||
height={40}
|
||||
className="h-10 w-10 object-contain"
|
||||
/>
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<Link
|
||||
href={`/admin/guilds/${g.id}`}
|
||||
className="font-medium hover:underline"
|
||||
>
|
||||
{g.name || `#${g.id}`}
|
||||
</Link>
|
||||
{g.description ? (
|
||||
<div className="muted text-xs line-clamp-1 max-w-xs">
|
||||
{g.description}
|
||||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td>
|
||||
<Link href={`/admin/users/show/${g.userId}`}>
|
||||
{ownerById.get(g.userId) ?? `#${g.userId}`}
|
||||
</Link>
|
||||
</td>
|
||||
<td>{membersByGuild.get(g.id) ?? 0}</td>
|
||||
<td className="muted">
|
||||
{formatDate(new Date(g.dateCreated * 1000), "date")}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
<AdminSimplePager
|
||||
page={pagination.page}
|
||||
lastPage={pagination.lastPage}
|
||||
total={total}
|
||||
basePath="/admin/guilds"
|
||||
params={q ? { search: q } : undefined}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
</AdminPageShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user