feat(onboarding): pick the birth place by level instead of by search
The single search field asked people to type a place name and then judge which of several near-identical results was theirs, which is the one thing they cannot verify about their own birth record. Province, city and district are now chosen from the dataset the app already ships, so there is nothing to type and nothing to disambiguate. Levels that offer no choice collapse: municipalities show one level, and prefecture cities without districts stop at the city. A district can be left as the city centre, which is accurate enough because the chart only needs coordinates and a timezone. The timezone is resolved once for the chosen place rather than on every keystroke, through a dedicated route that both this picker and the Geoapify path share. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { resolveBirthLocationTimezone } from "@/lib/birth-location-timezone-service";
|
||||
import { birthLocationTimezoneQuerySchema } from "@/lib/location-contract";
|
||||
import { createServerSupabaseClient } from "@/lib/supabase/server";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const supabase = await createServerSupabaseClient();
|
||||
const { data: { user }, error: authError } = await supabase.auth.getUser();
|
||||
if (authError || !user) return NextResponse.json({ error: "请先登录" }, { status: 401 });
|
||||
|
||||
let body: unknown;
|
||||
try {
|
||||
body = await request.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "时区解析参数不正确" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = birthLocationTimezoneQuerySchema.safeParse(body);
|
||||
if (!parsed.success) return NextResponse.json({
|
||||
error: "时区解析参数不正确",
|
||||
details: parsed.error.flatten(),
|
||||
}, { status: 400 });
|
||||
|
||||
const result = await resolveBirthLocationTimezone(parsed.data);
|
||||
return NextResponse.json(result, { status: result.status === "ok" ? 200 : 503 });
|
||||
}
|
||||
Reference in New Issue
Block a user