import { prisma } from '@/lib/db';
import { serveKey } from '@/lib/serve';
import { logoContentType } from '@/lib/logo';
export const dynamic = 'force-dynamic';

/** Paylaşılan ilanın 360° tur fotoğrafı (herkese açık, izleme bağlantısıyla). */
export async function GET(req: Request, { params }: { params: Promise<{ token: string }> }) {
  const { token } = await params;
  const o = await prisma.order.findUnique({ where: { shareToken: token }, select: { status: true, tourKey: true } });
  if (!o || o.status !== 'DELIVERED' || !o.tourKey) return new Response('Bulunamadı', { status: 404 });
  return serveKey(req, o.tourKey, logoContentType(o.tourKey));
}
