feat: enhance tickets portal and admin flows

This commit is contained in:
Esdras Renan 2025-10-07 02:26:09 -03:00
parent 9cdd8763b4
commit c15f0a5b09
67 changed files with 1101 additions and 338 deletions

View file

@ -1,9 +1,9 @@
import { NextResponse } from "next/server"
import { Prisma } from "@prisma/client"
import { hashPassword } from "better-auth/crypto"
import { ConvexHttpClient } from "convex/browser"
// @ts-expect-error Convex generated API lacks types in Next routes
import { api } from "@/convex/_generated/api"
import { DEFAULT_TENANT_ID } from "@/lib/constants"
import { env } from "@/lib/env"
@ -47,9 +47,10 @@ async function syncInvite(invite: NormalizedInvite) {
})
}
export async function GET(_request: Request, { params }: { params: { token: string } }) {
export async function GET(_request: Request, context: { params: Promise<{ token: string }> }) {
const { token } = await context.params
const invite = await prisma.authInvite.findUnique({
where: { token: params.token },
where: { token },
include: { events: { orderBy: { createdAt: "asc" } } },
})
@ -66,7 +67,7 @@ export async function GET(_request: Request, { params }: { params: { token: stri
data: {
inviteId: invite.id,
type: status,
payload: null,
payload: Prisma.JsonNull,
actorId: null,
},
})
@ -80,7 +81,8 @@ export async function GET(_request: Request, { params }: { params: { token: stri
return NextResponse.json({ invite: normalized })
}
export async function POST(request: Request, { params }: { params: { token: string } }) {
export async function POST(request: Request, context: { params: Promise<{ token: string }> }) {
const { token } = await context.params
const payload = (await request.json().catch(() => null)) as Partial<AcceptInvitePayload> | null
if (!payload || typeof payload.password !== "string") {
return NextResponse.json({ error: "Senha inválida" }, { status: 400 })
@ -91,7 +93,7 @@ export async function POST(request: Request, { params }: { params: { token: stri
}
const invite = await prisma.authInvite.findUnique({
where: { token: params.token },
where: { token },
include: { events: { orderBy: { createdAt: "asc" } } },
})
@ -108,7 +110,7 @@ export async function POST(request: Request, { params }: { params: { token: stri
data: {
inviteId: invite.id,
type: "expired",
payload: null,
payload: Prisma.JsonNull,
actorId: null,
},
})