feat: upgrade team admin with click-to-edit, Instagram validation, date picker, city autocomplete
- Team list: click card to open editor (remove pencil button), keep drag-to-reorder - Instagram field: username-only input with @ prefix, async account validation via HEAD request - Victory dates: date range picker replacing text input, auto-formats to DD.MM.YYYY / DD-DD.MM.YYYY - Victory location: city autocomplete via Nominatim API with suggestions dropdown - Links: real-time URL validation with error indicators on all link fields - Save button blocked when any validation errors exist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
27
src/app/api/admin/validate-instagram/route.ts
Normal file
27
src/app/api/admin/validate-instagram/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const username = request.nextUrl.searchParams.get("username")?.trim();
|
||||
if (!username) {
|
||||
return NextResponse.json({ valid: false, error: "No username" });
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`https://www.instagram.com/${username}/`, {
|
||||
method: "HEAD",
|
||||
redirect: "follow",
|
||||
headers: {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
},
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
|
||||
// Instagram returns 200 for existing profiles, 404 for non-existing
|
||||
const valid = res.ok;
|
||||
return NextResponse.json({ valid });
|
||||
} catch {
|
||||
// Network error or timeout — don't block the user
|
||||
return NextResponse.json({ valid: true, uncertain: true });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user