fix(rectification): honor declared birth-time uncertainty and split windows over two hours (BUG-571–573)
Intake stores how sure the user is; rectification now searches that range, offers a one-click widen when event fit is low at the edge, and trisects windows longer than two hours before the minute grid. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,11 +5,13 @@ 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 {
|
||||
approximateUncertaintyOptions,
|
||||
birthTimeDisplayState,
|
||||
birthTimeSourceDefaults,
|
||||
birthTimeSourceOptions,
|
||||
type BirthTimeDraft,
|
||||
type BirthTimeDraftPatch,
|
||||
type BirthTimeSource,
|
||||
} from "@/lib/birth-time-intake-model";
|
||||
|
||||
type BirthTimeIntakeProps = {
|
||||
@@ -79,13 +81,20 @@ export function BirthTimeIntakeFields({ value, onPatch }: BirthTimeIntakeProps)
|
||||
const source = value.birthTimeSource;
|
||||
const isConfirmed = value.birthTimeStatus === "confirmed";
|
||||
const displayState = birthTimeDisplayState(value);
|
||||
const knowledgeMode = source === "period_only" || source === "unknown"
|
||||
? "uncertain"
|
||||
: source ? "exact" : "";
|
||||
const selectedSourceOption: BirthTimeSource | "" = source === "family_exact" || source === "approximate"
|
||||
? "approximate"
|
||||
: source === "unknown"
|
||||
? "period_only"
|
||||
: source === "hospital_record" || source === "period_only"
|
||||
? source
|
||||
: "";
|
||||
const usesClockTime = source === "hospital_record"
|
||||
|| source === "family_exact"
|
||||
|| source === "approximate"
|
||||
|| source === "legacy_import";
|
||||
const approximateRadius = source === "family_exact"
|
||||
? 15
|
||||
: value.uncertaintyBeforeMinutes;
|
||||
|
||||
return (
|
||||
<div className="birth-time-intake">
|
||||
@@ -126,20 +135,16 @@ export function BirthTimeIntakeFields({ value, onPatch }: BirthTimeIntakeProps)
|
||||
)}
|
||||
|
||||
{!isConfirmed && <fieldset className="birth-time-source-fieldset">
|
||||
<legend>你对出生时间了解多少?</legend>
|
||||
<p className="birth-time-source-intro">不用猜具体分钟,先选一个最符合你的情况的选项。</p>
|
||||
<legend>你对这个时间有多确定?</legend>
|
||||
<p className="birth-time-source-intro">只用在这里问一次。校正会按你选的范围去比,不再追问你有多确定。</p>
|
||||
<div className="birth-time-source-list">
|
||||
{birthTimeSourceOptions.map((option) => (
|
||||
<label
|
||||
className={`birth-time-source-option ${option.value === "family_exact"
|
||||
? knowledgeMode === "exact" ? "is-selected" : ""
|
||||
: knowledgeMode === "uncertain" ? "is-selected" : ""}`}
|
||||
className={`birth-time-source-option ${option.value === selectedSourceOption ? "is-selected" : ""}`}
|
||||
key={option.value}
|
||||
>
|
||||
<input
|
||||
checked={option.value === "family_exact"
|
||||
? knowledgeMode === "exact"
|
||||
: knowledgeMode === "uncertain"}
|
||||
checked={option.value === selectedSourceOption}
|
||||
name={`birth-time-source-${groupId}`}
|
||||
type="radio"
|
||||
value={option.value}
|
||||
@@ -172,6 +177,32 @@ export function BirthTimeIntakeFields({ value, onPatch }: BirthTimeIntakeProps)
|
||||
{source === "hospital_record" && (
|
||||
<p className="birth-time-detail-note">系统会无感检查前后 2 分钟的上升与 D9 / D10 稳定性。</p>
|
||||
)}
|
||||
{(source === "approximate" || source === "family_exact") && (
|
||||
<fieldset className="birth-time-uncertainty-fieldset">
|
||||
<legend>选一个最接近的范围</legend>
|
||||
<div className="birth-time-uncertainty-list">
|
||||
{approximateUncertaintyOptions.map((option) => (
|
||||
<button
|
||||
className={`birth-time-uncertainty-option ${approximateRadius === option.minutes ? "is-selected" : ""}`}
|
||||
key={option.minutes}
|
||||
type="button"
|
||||
onClick={() => onPatch(
|
||||
option.minutes === 15 && source === "family_exact"
|
||||
? {
|
||||
uncertaintyBeforeMinutes: 0,
|
||||
uncertaintyAfterMinutes: 0,
|
||||
}
|
||||
: {
|
||||
birthTimeSource: "approximate",
|
||||
uncertaintyBeforeMinutes: option.minutes,
|
||||
uncertaintyAfterMinutes: option.minutes,
|
||||
},
|
||||
)}
|
||||
>{option.label}</button>
|
||||
))}
|
||||
</div>
|
||||
</fieldset>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user