This commit is contained in:
2025-12-10 12:38:55 +01:00
parent 0f7fe67d3c
commit fbbcf414a4
87 changed files with 11972 additions and 390 deletions

View 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 });
}
}

View File

@@ -0,0 +1,50 @@
import { NextRequest, NextResponse } from 'next/server';
// Alpha: In-memory sponsor storage
const sponsors: Map<string, {
id: string;
name: string;
contactEmail: string;
websiteUrl?: string;
logoUrl?: string;
createdAt: Date;
}> = new Map();
export async function GET() {
const allSponsors = Array.from(sponsors.values());
return NextResponse.json({ sponsors: allSponsors });
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { name, contactEmail, websiteUrl, logoUrl } = body;
if (!name || !contactEmail) {
return NextResponse.json(
{ error: 'Name and contact email are required' },
{ status: 400 }
);
}
const id = `sponsor-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
const sponsor = {
id,
name,
contactEmail,
websiteUrl: websiteUrl || undefined,
logoUrl: logoUrl || undefined,
createdAt: new Date(),
};
sponsors.set(id, sponsor);
return NextResponse.json({ sponsor }, { status: 201 });
} catch (err) {
console.error('Sponsor creation failed:', err);
return NextResponse.json(
{ error: 'Failed to create sponsor' },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,34 @@
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { cookies } from 'next/headers';
import { getGetSponsorSponsorshipsQuery } 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 = getGetSponsorSponsorshipsQuery();
const sponsorships = await query.execute({ sponsorId });
if (!sponsorships) {
return NextResponse.json(
{ error: 'Sponsor not found' },
{ status: 404 }
);
}
return NextResponse.json(sponsorships);
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to get sponsor sponsorships';
return NextResponse.json({ error: message }, { status: 500 });
}
}