"use client"; import { useId, useState } from "react"; import { BirthDatePicker } from "@/components/birth-date-picker"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { birthTimeConsultationOptionsCopy } from "@/lib/birth-time-consultation-consent"; import { birthTimeDisplayState, birthTimePeriodOptions, birthTimeSourceDefaults, birthTimeSourceOptions, type BirthTimeDraft, type BirthTimeDraftPatch, } from "@/lib/birth-time-intake-model"; type BirthTimeIntakeProps = { readonly value: BirthTimeDraft; readonly onPatch: (patch: BirthTimeDraftPatch) => void; }; const hours = Array.from({ length: 24 }, (_, index) => String(index).padStart(2, "0")); const minutes = Array.from({ length: 60 }, (_, index) => String(index).padStart(2, "0")); function splitBirthTime(value: string) { const [hour = "", minute = ""] = value.split(":"); return { hour, minute }; } type BirthClockSelectProps = { readonly value: string; readonly onChange: (value: string) => void; }; function BirthClockSelect({ value, onChange }: BirthClockSelectProps) { const currentTime = value || ""; const [timeParts, setTimeParts] = useState(() => splitBirthTime(currentTime)); const patchTime = (part: "hour" | "minute", nextValue: string | null) => { if (nextValue === null) return; const nextParts = { ...timeParts, [part]: nextValue }; setTimeParts(nextParts); if (nextParts.hour && nextParts.minute) onChange(`${nextParts.hour}:${nextParts.minute}`); }; return (
); } export function BirthTimeIntakeFields({ value, onPatch }: BirthTimeIntakeProps) { const groupId = useId(); const source = value.birthTimeSource; const isConfirmed = value.birthTimeStatus === "confirmed"; const displayState = birthTimeDisplayState(value); const knowledgeMode = source === "period_only" || source === "unknown" ? "uncertain" : source ? "exact" : ""; const usesClockTime = source === "hospital_record" || source === "family_exact" || source === "approximate" || source === "legacy_import"; return (
{displayState && (
出生时间记录 {displayState.kind === "candidate" ? "候选时间" : displayState.kind === "accepted" ? "校正采用" : "引擎确认"}
{displayState.kind === "candidate" ? "待验证候选" : "当前排盘时间"}
{displayState.activeTime}
原始填报时间
{displayState.reportedLabel}
{displayState.kind === "candidate" && (

这仍是未确认候选,不会自动成为出生分钟;{birthTimeConsultationOptionsCopy(value)}

)} {displayState.kind === "accepted" && (

这是你从候选中选择的校正采用时间,并非引擎唯一确认分钟;后续排盘会使用它。

)}
)} onPatch({ date })} /> {source === "legacy_import" && (

这是账号里已有的确认时间。本阶段保留原始记录,不在资料表内直接覆盖。

)} {!isConfirmed &&
你对出生时间了解多少?

不用猜具体分钟,先选一个最符合你的情况的选项。

{birthTimeSourceOptions.map((option) => ( ))}
} {usesClockTime && (
{source === "hospital_record" && (

系统会无感检查前后 2 分钟的上升与 D9 / D10 稳定性。

)}
)} {source === "period_only" && (