Add the helpdesk list page and ticket detail page routes. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 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 hasRoles from "@/utils/access-control/hasRoles";
|
|
import { LifeBuoyIcon } from "lucide-react";
|
|
|
|
export const metadata = {
|
|
title: "Helpdesk — Polaris Task Force",
|
|
};
|
|
|
|
export default async function HelpdeskPage() {
|
|
const payload = await getPayload({ config });
|
|
const { user } = await payload.auth({
|
|
headers: await nextHeaders(),
|
|
canSetHeaders: false,
|
|
});
|
|
|
|
if (!user) {
|
|
redirect("/login");
|
|
}
|
|
|
|
const ticketsRes = await payload.find({
|
|
collection: "tickets",
|
|
sort: "-updatedAt",
|
|
limit: 200,
|
|
depth: 2,
|
|
});
|
|
const tickets = ticketsRes.docs as unknown as Ticket[];
|
|
const isStaff = hasRoles(["admin", "developer"], user);
|
|
|
|
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 tickets={tickets} currentUserId={user.id} isStaff={isStaff} />
|
|
</div>
|
|
);
|
|
}
|