- Add 11 destinations that exist in the app but were absent from the palette: World Map, Event Log, Operations, Ops Ledger, Reservations, Supply Boxes, Promotions, Leaderboard, Minigame Leaderboards, Chronicle, Surveys - Show G N / G A shortcut labels for Notifications and Admin (chords were already wired in KeyboardShortcutsProvider but unlabelled) - Add a Toggle Mini XP Display action mirroring the sidebar control - Add an Open Unassigned Tickets queue shortcut and point Create Support Ticket at the compose deep link - Teach /helpdesk to open the create dialog via ?compose=1 and to preselect a filter tab via ?view=unassigned
95 lines
3 KiB
TypeScript
95 lines
3 KiB
TypeScript
import config from "@payload-config";
|
|
import { headers as nextHeaders } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import { getPayload } from "payload";
|
|
import type { Ticket } from "@/payload-types";
|
|
import { TicketsView } from "@/components/frontend/helpdesk/TicketsView";
|
|
import { hasPermission } from "@/utils/access-control/hasPermission";
|
|
import { LifeBuoyIcon } from "lucide-react";
|
|
import { getTicketVoteSummaries } from "@/lib/tickets/voteState";
|
|
import { NON_ARCHIVED_WHERE } from "@/lib/tickets/ticketMeta";
|
|
|
|
export const metadata = {
|
|
title: "Helpdesk: Polaris Task Force",
|
|
};
|
|
|
|
function HelpdeskDisabled() {
|
|
return (
|
|
<div className="mx-auto flex w-full max-w-2xl flex-col gap-4 p-5">
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<LifeBuoyIcon className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">Helpdesk</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">
|
|
The Helpdesk is currently disabled by a unit admin.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default async function HelpdeskPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
}) {
|
|
const params = await searchParams;
|
|
const compose = params.compose === "1" || params.compose === "true";
|
|
const view = typeof params.view === "string" ? params.view : undefined;
|
|
|
|
const headers = await nextHeaders();
|
|
const payload = await getPayload({ config });
|
|
const { user } = await payload.auth({
|
|
headers,
|
|
canSetHeaders: false,
|
|
});
|
|
|
|
if (!user) {
|
|
const pathname = headers.get("x-invoke-path") || "/helpdesk";
|
|
redirect(`/login?returnTo=${encodeURIComponent(pathname)}`);
|
|
}
|
|
|
|
const { helpdeskEnabled } = await payload.findGlobal({ slug: "game-rules" });
|
|
if (!helpdeskEnabled) {
|
|
return <HelpdeskDisabled />;
|
|
}
|
|
|
|
const ticketsRes = await payload.find({
|
|
collection: "tickets",
|
|
where: NON_ARCHIVED_WHERE,
|
|
sort: "-updatedAt",
|
|
limit: 200,
|
|
depth: 2,
|
|
});
|
|
const tickets = ticketsRes.docs as unknown as Ticket[];
|
|
const [isStaff, voteSummaries] = await Promise.all([
|
|
hasPermission(payload, user, "tickets:staff"),
|
|
getTicketVoteSummaries(
|
|
payload,
|
|
user.id,
|
|
tickets.map((ticket) => ticket.id),
|
|
),
|
|
]);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-6 p-5">
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex items-center gap-2">
|
|
<LifeBuoyIcon className="size-5 text-muted-foreground" />
|
|
<h1 className="text-lg font-semibold">Helpdesk</h1>
|
|
</div>
|
|
<p className="text-sm text-muted-foreground">Submit and track support requests.</p>
|
|
</div>
|
|
|
|
<TicketsView
|
|
key={`${compose ? "compose" : "list"}:${view ?? "default"}`}
|
|
tickets={tickets}
|
|
voteSummaries={voteSummaries}
|
|
isStaff={isStaff}
|
|
initialCompose={compose}
|
|
initialView={view}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|