wip
This commit is contained in:
34
apps/website/app/api/sponsors/dashboard/route.ts
Normal file
34
apps/website/app/api/sponsors/dashboard/route.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { cookies } from 'next/headers';
|
||||
import { getGetSponsorDashboardQuery } from '@/lib/di-container';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Get sponsor ID from cookie (set during demo login)
|
||||
const cookieStore = await cookies();
|
||||
const sponsorId = cookieStore.get('gridpilot_sponsor_id')?.value;
|
||||
|
||||
if (!sponsorId) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Not authenticated as sponsor' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
const query = getGetSponsorDashboardQuery();
|
||||
const dashboard = await query.execute({ sponsorId });
|
||||
|
||||
if (!dashboard) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Sponsor not found' },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(dashboard);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to get sponsor dashboard';
|
||||
return NextResponse.json({ error: message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user