- New AvBeatLogo inline-SVG component (rounded-square emblem with forward-leaning AV monogram + horizontal beam detail) at src/components/AvBeatLogo.tsx, three variants (full/wordmark/icon). - Header.tsx now uses the responsive AV BEAT logo lockup in the top-left, links to /, full lockup on desktop (emblem+wordmark+tagline), emblem+wordmark on tablet, emblem-only on mobile. - Removed DualSpeedTicker (the 'RECENT FORUM POSTS' ticker strip); the news ticker / glow chrome does not match the new aesthetic and the forum row was the explicit removal target. - Tailwind theme + globals.css now expose the AV BEAT 2026 palette as semantic tokens: --brand-blue (#1D4ED8), --brand-blue-bright (#38BDF8), --brand-navy (#0F172A), --brand-bg (#F8FAFC), --brand-surface, --brand-border, --brand-text, --brand-text-muted. Legacy --color-* aliases re-point to the new tokens so any inline-styled component re-themes for free. - Site-wide hex sweep migrates 2,769 hardcoded color literals across 144 files from the old dark-broadcast palette to the new tokens (orange -> blue, dark-brown -> white surface / navy text, cream -> navy). - Layout body class flipped from 'bb-neon' to 'bg-brand-bg text-brand-text' so the dark glow chrome no longer leaks through the new light theme.
97 lines
3.4 KiB
TypeScript
97 lines
3.4 KiB
TypeScript
import { createClient } from '@/lib/supabase/server';
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
// GET: list all templates
|
|
export async function GET() {
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
|
|
const { data, error } = await supabase
|
|
.from('newsletter_templates')
|
|
.select('*')
|
|
.order('is_preset', { ascending: false })
|
|
.order('created_at', { ascending: true });
|
|
|
|
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
|
return NextResponse.json({ templates: data || [] });
|
|
}
|
|
|
|
// POST: create a new template
|
|
export async function POST(req: NextRequest) {
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
|
|
const body = await req.json();
|
|
const { name, description, layout, style, subject_prefix, header_text, footer_text, accent_color, article_blocks } = body;
|
|
|
|
if (!name?.trim()) return NextResponse.json({ error: 'Name is required' }, { status: 400 });
|
|
|
|
const { data, error } = await supabase
|
|
.from('newsletter_templates')
|
|
.insert({
|
|
name: name.trim(),
|
|
description: description || '',
|
|
layout: layout || 'standard',
|
|
style: style || 'dark',
|
|
subject_prefix: subject_prefix || '',
|
|
header_text: header_text || '',
|
|
footer_text: footer_text || '',
|
|
accent_color: accent_color || '#1D4ED8',
|
|
article_blocks: article_blocks || [],
|
|
is_preset: false,
|
|
})
|
|
.select()
|
|
.single();
|
|
|
|
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
|
return NextResponse.json({ template: data });
|
|
}
|
|
|
|
// PUT: update a template
|
|
export async function PUT(req: NextRequest) {
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
|
|
const body = await req.json();
|
|
const { id, ...updates } = body;
|
|
if (!id) return NextResponse.json({ error: 'ID required' }, { status: 400 });
|
|
|
|
const { data, error } = await supabase
|
|
.from('newsletter_templates')
|
|
.update({ ...updates, updated_at: new Date().toISOString() })
|
|
.eq('id', id)
|
|
.select()
|
|
.single();
|
|
|
|
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
|
return NextResponse.json({ template: data });
|
|
}
|
|
|
|
// DELETE: remove a template (only non-preset)
|
|
export async function DELETE(req: NextRequest) {
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
|
|
const { id } = await req.json();
|
|
if (!id) return NextResponse.json({ error: 'ID required' }, { status: 400 });
|
|
|
|
// Prevent deleting presets
|
|
const { data: tpl } = await supabase
|
|
.from('newsletter_templates')
|
|
.select('is_preset')
|
|
.eq('id', id)
|
|
.single();
|
|
|
|
if (tpl?.is_preset) {
|
|
return NextResponse.json({ error: 'Cannot delete preset templates' }, { status: 403 });
|
|
}
|
|
|
|
const { error } = await supabase.from('newsletter_templates').delete().eq('id', id);
|
|
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
|
return NextResponse.json({ success: true });
|
|
}
|