first commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const ticket = await getBackend().replyTicket(id, String(body.body ?? ""));
|
||||
if (!ticket) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ ticket });
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
import type { TicketState } from "@lynkd/messaging-inbox-sdk";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function GET(_req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const ticket = await getBackend().getTicket(id);
|
||||
if (!ticket) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ ticket });
|
||||
}
|
||||
|
||||
export async function PATCH(req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const ticket = await getBackend().patchTicket(id, (body.state as TicketState) ?? "OPEN");
|
||||
if (!ticket) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ ticket });
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const scope = req.nextUrl.searchParams.get("scope") ?? undefined;
|
||||
return NextResponse.json({ tickets: await getBackend().listTickets(scope ?? undefined) });
|
||||
}
|
||||
Reference in New Issue
Block a user