fix(app): editor route split into dialogs and pickers components, canvas without lint suppression, findings picker coverage restored; golden test pins every generated draft file; stale doc lines
This commit is contained in:
1 parent
0476276a8f
commit
09d8b01a54
11 files changed
+374
-161
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import type { LateralSide, Observation } from '@faunosteo/domain'
|
||||
import VertebraPicker from '@/components/observation/VertebraPicker'
|
||||
import LateralityPicker from '@/components/observation/LateralityPicker'
|
||||
import { useReportStore } from '@/state/reportStore'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { isObservable, pickLabel, type SheetIndex } from '@/services/sheetIndex'
|
||||
import {
|
||||
addSides,
|
||||
collectVertebrae,
|
||||
sidesPresent,
|
||||
syncVertebrae,
|
||||
type ZoneRef,
|
||||
} from '@/services/zoneInteraction'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export interface ObservationPickersProps {
|
||||
sheet: SheetIndex
|
||||
activeIndex: number
|
||||
activeObs: Observation | undefined
|
||||
vertebraTarget: number | null
|
||||
lateralTarget: ZoneRef | null
|
||||
onCloseVertebra: () => void
|
||||
onCloseLateral: () => void
|
||||
}
|
||||
|
||||
/** Vertebra and laterality pickers of the active observation. */
|
||||
export default function ObservationPickers({
|
||||
sheet,
|
||||
activeIndex,
|
||||
activeObs,
|
||||
vertebraTarget,
|
||||
lateralTarget,
|
||||
onCloseVertebra,
|
||||
onCloseLateral,
|
||||
}: ObservationPickersProps) {
|
||||
const t = useT()
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const updateObservation = useReportStore((s) => s.updateObservation)
|
||||
const vertebraZone =
|
||||
vertebraTarget !== null ? activeObs?.zones[vertebraTarget] : undefined
|
||||
const vertebraAnnotation =
|
||||
vertebraZone && sheet.annotation(vertebraZone.annotationId)
|
||||
const lateralAnnotation =
|
||||
lateralTarget && sheet.annotation(lateralTarget.annotationId)
|
||||
|
||||
return (
|
||||
<>
|
||||
{vertebraTarget !== null &&
|
||||
activeObs &&
|
||||
vertebraZone &&
|
||||
isObservable(vertebraAnnotation) && (
|
||||
<VertebraPicker
|
||||
open
|
||||
onClose={onCloseVertebra}
|
||||
onConfirm={(vertebrae) => {
|
||||
const fresh =
|
||||
useReportStore.getState().report?.observations[activeIndex]
|
||||
if (fresh) {
|
||||
updateObservation(
|
||||
activeIndex,
|
||||
syncVertebrae(fresh, vertebrae, sheet, vertebraZone.viewId),
|
||||
)
|
||||
}
|
||||
onCloseVertebra()
|
||||
}}
|
||||
initial={collectVertebrae(activeObs, sheet, vertebraTarget)}
|
||||
regions={sheet.regions()}
|
||||
title={`${t('vertebra.title_prefix')}${pickLabel(vertebraAnnotation.name, locale)}`}
|
||||
initialRegion={
|
||||
vertebraAnnotation.vertebral_region_code ?? undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{lateralTarget && activeObs && lateralAnnotation && (
|
||||
<LateralityPicker
|
||||
open
|
||||
onClose={onCloseLateral}
|
||||
title={pickLabel(sheet.name(lateralAnnotation), locale)}
|
||||
existingSides={sidesPresent(activeObs, lateralTarget)}
|
||||
onSelect={(sides: LateralSide[]) => {
|
||||
const fresh =
|
||||
useReportStore.getState().report?.observations[activeIndex]
|
||||
if (fresh)
|
||||
updateObservation(
|
||||
activeIndex,
|
||||
addSides(fresh, lateralAnnotation, sides),
|
||||
)
|
||||
onCloseLateral()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user