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:
Jesse_Chen
2026-09-07 12:18:50 +08:00
co-authored by Cursor
parent b2a8d3a005
commit 8e31680b45
49 changed files with 3047 additions and 142 deletions
+42 -11
View File
@@ -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>
)}