chore(workspace): move the app to apps/app under a pnpm workspace (step 2)

144 files moved with git mv (pure renames). Root package.json delegates
dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and
pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager,
root devDependency, engine-strict). Dockerfile builds @faunosteo/app on
node:24-alpine and copies apps/app/dist; nginx and runtime config
unchanged. CI workflow for Gitea Actions. packages/ reserved (README only).
Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan.
271/271 tests, typecheck, lint, build green from the root.
This commit is contained in:
bchanot committed 2026-10-08 21:51:13 +02:00
1 parent c8d48ab4cc
commit 8673475293
164 files changed
+348 -128

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { BrowserRouter, Routes, Route, useLocation } from 'react-router-dom'
import { ConfigProvider } from './providers/ConfigProvider'
import Footer from '@/components/brand/Footer'
import HomeRoute from './routes/HomeRoute'
import NewReportRoute from './routes/NewReportRoute'
import EditorRoute from './routes/EditorRoute'
import SvgEditorRoute from './routes/SvgEditorRoute'
import EditorsRoute from './routes/EditorsRoute'
import NotFoundRoute from './routes/NotFoundRoute'
function AppShell() {
const hideFooter = useLocation().pathname === '/svg-editor'
return (
<div className="flex min-h-screen flex-col">
<main className="flex-1 flex flex-col">
<Routes>
<Route path="/" element={<HomeRoute />} />
<Route path="/new" element={<NewReportRoute />} />
<Route path="/editor" element={<EditorRoute />} />
<Route path="/svg-editor" element={<SvgEditorRoute />} />
<Route path="/editors" element={<EditorsRoute />} />
<Route path="*" element={<NotFoundRoute />} />
</Routes>
</main>
{!hideFooter && <Footer />}
</div>
)
}
export default function App() {
return (
<ConfigProvider>
<BrowserRouter>
<AppShell />
</BrowserRouter>
</ConfigProvider>
)
}
@@ -0,0 +1,17 @@
import { createContext, useContext, type ReactNode } from 'react'
import { appConfig, type AppConfig } from '@/config/env'
const ConfigContext = createContext<AppConfig>(appConfig)
export function ConfigProvider({ children }: { children: ReactNode }) {
return (
<ConfigContext.Provider value={appConfig}>
{children}
</ConfigContext.Provider>
)
}
/** Returns the resolved app config. Never returns undefined. */
export function useConfig(): AppConfig {
return useContext(ConfigContext)
}
+552
View File
@@ -0,0 +1,552 @@
import { useEffect, useMemo, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import DetailModal from '@/components/canvas/DetailModal'
import ObservationList from '@/components/observation/ObservationList'
import VertebraPicker from '@/components/observation/VertebraPicker'
import { regionFromLabel } from '@/lib/spineZones'
import LateralityPicker from '@/components/observation/LateralityPicker'
import type { LateralSide } from '@/domain/schema/observation'
import ConclusionPanel from '@/components/report/ConclusionPanel'
import ReportHeader from '@/components/report/ReportHeader'
import PractitionerForm from '@/components/report/PractitionerForm'
import AnimalForm from '@/components/report/AnimalForm'
import Button from '@/components/ui/Button'
import Dialog from '@/components/ui/Dialog'
import { useReportStore } from '@/state/reportStore'
import { writeCachedPractitioner } from '@/state/practitionerCache'
import { getSpecies } from '@/domain/species/registry'
import { loadSvg } from '@/anatomy/svgLoader'
import { parseSvgBones } from '@/anatomy/svgConvention'
import { collectSpineVertebrae, syncSpineZones } from '@/lib/spineZones'
import type { Bone, BoneState } from '@/anatomy/types'
import type { Observation, ObservationZone } from '@/domain/schema/observation'
import type { Report } from '@/domain/schema/report'
import type { SpeciesFindings } from '@/domain/schema/findings'
import type { Practitioner } from '@/domain/schema/practitioner'
import type { Animal, Owner } from '@/domain/schema/animal'
import { exportReportToPdf } from '@/pdf/export'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import { boneLabel } from '@/anatomy/labels'
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
/** Merges newly parsed bones into the accumulated map without overwriting. */
function mergeBones(prev: Map<string, Bone>, parsed: Map<string, Bone>) {
const merged = new Map(prev)
parsed.forEach((b, id) => {
if (!merged.has(id)) merged.set(id, b)
})
return merged
}
export default function EditorRoute() {
const navigate = useNavigate()
const t = useT()
const locale = useLocaleStore((s) => s.locale)
const report = useReportStore((s) => s.report)
const activeIndex = useReportStore((s) => s.activeObservationIndex)
const addObservation = useReportStore((s) => s.addObservation)
const updateObservation = useReportStore((s) => s.updateObservation)
const removeObservation = useReportStore((s) => s.removeObservation)
const moveObservationUp = useReportStore((s) => s.moveObservationUp)
const moveObservationDown = useReportStore((s) => s.moveObservationDown)
const setActiveObservation = useReportStore((s) => s.setActiveObservation)
const setConclusion = useReportStore((s) => s.setConclusion)
const setRecommendations = useReportStore((s) => s.setRecommendations)
const setNextAppointment = useReportStore((s) => s.setNextAppointment)
const setPractitioner = useReportStore((s) => s.setPractitioner)
const setAnimal = useReportStore((s) => s.setAnimal)
const setOwner = useReportStore((s) => s.setOwner)
const [bones, setBones] = useState<Map<string, Bone>>(new Map())
const [detailBones, setDetailBones] = useState<Map<string, Bone>>(new Map())
const [findings, setFindings] = useState<SpeciesFindings | null>(null)
const [disclaimer, setDisclaimer] = useState<string | null>(null)
const [detail, setDetail] = useState<{
id: string
src: string
title: string
} | null>(null)
const [vertebraTarget, setVertebraTarget] = useState<number | null>(null)
const [lateralTarget, setLateralTarget] = useState<{
boneId: string
detailSourceId?: string
} | null>(null)
const [exporting, setExporting] = useState(false)
const [editOpen, setEditOpen] = useState(false)
const [editDraft, setEditDraft] = useState<{
practitioner: Practitioner
animal: Animal
owner: Owner
} | null>(null)
function openEditInfos() {
if (!report) return
setEditDraft({
practitioner: report.practitioner,
animal: report.animal,
owner: report.owner,
})
setEditOpen(true)
}
function closeEditInfos() {
setEditOpen(false)
setEditDraft(null)
}
function saveEditInfos() {
if (!editDraft) return closeEditInfos()
const name = editDraft.practitioner.name.trim()
const animalName = editDraft.animal.name.trim()
const ownerName = editDraft.owner.name.trim()
if (!name || !animalName || !ownerName) return
setPractitioner(editDraft.practitioner)
setAnimal(editDraft.animal)
setOwner(editDraft.owner)
writeCachedPractitioner(editDraft.practitioner)
closeEditInfos()
}
function acknowledgeDisclaimer() {
if (typeof sessionStorage !== 'undefined') {
sessionStorage.setItem(DISCLAIMER_FLAG, '1')
}
setDisclaimer(null)
}
useEffect(() => {
if (!report) navigate('/')
}, [report, navigate])
useEffect(() => {
window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
}, [])
const species = useMemo(
() => (report ? getSpecies(report.animal.speciesId) : undefined),
[report],
)
useEffect(() => {
if (!species) return
loadSvg(species.mainSvg).then((root) => setBones(parseSvgBones(root)))
species.findings().then((m) => setFindings(m.default))
// Eagerly preload every detail SVG so observation zones imported
// from a PDF (which can carry detail-popup boneIds without the user
// ever re-opening the popup) resolve their labels and findings
// pickers immediately on mount. Each fetch is independent — a 404
// on one detail asset must not prevent the others from loading.
Object.values(species.details).forEach((path) => {
loadSvg(path)
.then((root) => {
const parsed = parseSvgBones(root)
setDetailBones((prev) => mergeBones(prev, parsed))
})
.catch((err) => {
console.warn(`EditorRoute: failed to preload detail SVG ${path}`, err)
})
})
}, [species])
useEffect(() => {
if (!findings) return
if (typeof sessionStorage === 'undefined') return
if (sessionStorage.getItem(DISCLAIMER_FLAG)) return
setDisclaimer(findings.scope_disclaimer)
}, [findings])
useEffect(() => {
if (!detail) return
let cancelled = false
loadSvg(detail.src).then((root) => {
if (cancelled) return
const parsed = parseSvgBones(root)
setDetailBones((prev) => mergeBones(prev, parsed))
})
return () => {
cancelled = true
}
}, [detail])
const allBones = useMemo(() => {
const m = new Map(bones)
detailBones.forEach((b, id) => {
if (!m.has(id)) m.set(id, b)
})
return m
}, [bones, detailBones])
const activeObs =
activeIndex >= 0 ? report?.observations[activeIndex] : undefined
const boneStates = useMemo<Map<string, BoneState>>(() => {
const map = new Map<string, BoneState>()
if (!report || activeIndex < 0) return map
const active = report.observations[activeIndex]
if (!active) return map
active.zones.forEach((z) => {
map.set(z.boneId, 'current')
})
return map
}, [report, activeIndex])
function onToggleCard(index: number) {
setActiveObservation(activeIndex === index ? -1 : index)
}
/** Opens the detail-popup modal for a bone that carries data-anno-opens-detail. */
function handleDetailOpen(bone: Bone, detailId: string, detailSrc: string) {
setDetail({
id: detailId,
src: detailSrc,
title: boneLabel(bone, locale, detailId),
})
}
/**
* No expanded observation — auto-expand the most recent one (or the
* first if no rows yet) so the click lands somewhere. Defers the actual
* zone add to the next render where activeObs is set.
*/
function activateFallbackObservation(report: Report) {
const fallbackIndex =
report.observations.length > 0 ? report.observations.length - 1 : -1
if (fallbackIndex < 0) return
setActiveObservation(fallbackIndex)
}
/**
* Spine-zone behavior: always open VertebraPicker on click. Adds the
* zone if missing; never toggles it off here (use the ✕ button).
*/
function handleSpineZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
existingIndex: number,
) {
let targetIndex = existingIndex
if (existingIndex < 0) {
const newZone: ObservationZone = {
boneId,
...(detailSourceId ? { detailSourceId } : {}),
}
const nextZones = [...activeObs.zones, newZone]
targetIndex = nextZones.length - 1
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
}
setVertebraTarget(targetIndex)
}
/** Bilateral zone: adding a side, or clearing both once left+right are set. */
function handleBilateralZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
) {
const sidesPresent = activeObs.zones
.filter(
(z) => z.boneId === boneId && z.detailSourceId === detailSourceId,
)
.map((z) => z.side)
.filter(Boolean) as LateralSide[]
if (sidesPresent.includes('left') && sidesPresent.includes('right')) {
const nextZones = activeObs.zones.filter(
(z) => !(z.boneId === boneId && z.detailSourceId === detailSourceId),
)
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
return
}
setLateralTarget({
boneId,
...(detailSourceId ? { detailSourceId } : {}),
})
}
/** Plain zone: toggles it on the active observation. */
function toggleZone(
activeObs: Observation,
boneId: string,
detailSourceId: string | undefined,
existingIndex: number,
) {
const newZone: ObservationZone = {
boneId,
...(detailSourceId ? { detailSourceId } : {}),
}
const nextZones =
existingIndex >= 0
? activeObs.zones.filter((_, k) => k !== existingIndex)
: [...activeObs.zones, newZone]
updateObservation(activeIndex, { ...activeObs, zones: nextZones })
}
function onZoneClick(boneId: string, detailSourceId?: string) {
if (!report) return
const bone = bones.get(boneId) ?? detailBones.get(boneId)
if (!bone) return
if (bone.opensDetail && species?.details[bone.opensDetail]) {
handleDetailOpen(bone, bone.opensDetail, species.details[bone.opensDetail])
return
}
if (!activeObs || activeIndex < 0) {
activateFallbackObservation(report)
return
}
const matches = (z: ObservationZone) =>
z.boneId === boneId && z.detailSourceId === detailSourceId
const existingIndex = activeObs.zones.findIndex(matches)
if (bone.special === 'vertebral-precision') {
handleSpineZone(activeObs, boneId, detailSourceId, existingIndex)
return
}
if (bone.lateral === 'bilateral') {
handleBilateralZone(activeObs, boneId, detailSourceId)
return
}
toggleZone(activeObs, boneId, detailSourceId, existingIndex)
}
async function onExport() {
if (!report) return
setExporting(true)
try {
const bytes = await exportReportToPdf(report, { locale })
const blob = new Blob([bytes as BlobPart], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `bilan-${report.animal.name}-${report.date}.pdf`
a.click()
URL.revokeObjectURL(url)
} catch (err) {
console.error('PDF export failed', err)
window.alert(t('editor.export_failed'))
} finally {
setExporting(false)
}
}
if (!report || !species) return null
return (
<main className="min-h-screen flex flex-col">
<ReportHeader report={report} onEditInfos={openEditInfos} />
<div className="flex-1 grid grid-cols-1 lg:grid-cols-[2fr_3fr] gap-4 sm:gap-6 p-4 sm:p-6">
<section className="border border-[var(--color-border)] rounded-2xl bg-[var(--color-surface)] overflow-hidden max-h-[55vh] lg:max-h-none">
<AnatomyCanvas
src={species.mainSvg}
boneStates={boneStates}
onZoneClick={(id) => onZoneClick(id)}
/>
</section>
<section className="space-y-4 sm:space-y-6">
<ObservationList
observations={report.observations}
activeIndex={activeIndex}
onToggle={onToggleCard}
onAdd={addObservation}
onDelete={removeObservation}
onMoveUp={moveObservationUp}
onMoveDown={moveObservationDown}
bones={allBones}
findings={findings}
onChange={(i, next: Observation) => updateObservation(i, next)}
onOpenVertebraPicker={(_i, zoneIndex) =>
setVertebraTarget(zoneIndex)
}
onRemoveZone={(i, zoneIndex) => {
const obs = report.observations[i]
if (!obs) return
const zones = obs.zones.filter((_, k) => k !== zoneIndex)
updateObservation(i, { ...obs, zones })
}}
/>
<ConclusionPanel
conclusion={report.conclusion}
recommendations={report.recommendations}
nextAppointment={report.nextAppointment}
onChangeConclusion={setConclusion}
onChangeRecommendations={setRecommendations}
onChangeNextAppointment={setNextAppointment}
/>
<div className="flex justify-end">
<Button onClick={onExport} disabled={exporting}>
{exporting ? t('editor.exporting') : t('editor.export')}
</Button>
</div>
</section>
</div>
{detail && (
<DetailModal
open
onClose={() => setDetail(null)}
detailSrc={detail.src}
detailId={detail.id}
title={`${t('editor.detail_title_prefix')}${detail.title}`}
boneStates={boneStates}
onZoneClick={(id, did) => onZoneClick(id, did)}
/>
)}
{editDraft && (
<Dialog
open={editOpen}
onClose={closeEditInfos}
title={t('editor.edit_dialog_title')}
size="lg"
>
<div className="space-y-8">
<PractitionerForm
value={editDraft.practitioner}
onChange={(next) =>
setEditDraft((d) => (d ? { ...d, practitioner: next } : d))
}
/>
<AnimalForm
animal={editDraft.animal}
owner={editDraft.owner}
onChangeAnimal={(next) =>
setEditDraft((d) => (d ? { ...d, animal: next } : d))
}
onChangeOwner={(next) =>
setEditDraft((d) => (d ? { ...d, owner: next } : d))
}
/>
<div className="flex gap-3 justify-end pt-2 border-t border-[var(--color-border)]">
<Button variant="ghost" onClick={closeEditInfos}>
{t('common.cancel')}
</Button>
<Button
onClick={saveEditInfos}
disabled={
!editDraft.practitioner.name.trim() ||
!editDraft.animal.name.trim() ||
!editDraft.owner.name.trim()
}
>
{t('common.save')}
</Button>
</div>
</div>
</Dialog>
)}
{disclaimer && (
<Dialog
open
onClose={acknowledgeDisclaimer}
title={t('editor.disclaimer_title')}
size="md"
>
<div className="space-y-4">
<p className="text-sm text-[var(--color-ink)]">{disclaimer}</p>
<div className="flex justify-end">
<Button onClick={acknowledgeDisclaimer}>{t('common.understood')}</Button>
</div>
</div>
</Dialog>
)}
{vertebraTarget !== null &&
activeObs &&
activeObs.zones[vertebraTarget] && (
<VertebraPicker
open
onClose={() => setVertebraTarget(null)}
onConfirm={(vertebrae) => {
const fresh =
useReportStore.getState().report?.observations[activeIndex]
if (!fresh?.zones[vertebraTarget]) {
setVertebraTarget(null)
return
}
// Picker edits every region at once: reconcile all spine zones —
// spawn newly picked regions, prune emptied ones, keep the rest.
const next = syncSpineZones(fresh.zones, vertebrae, bones)
updateObservation(activeIndex, { ...fresh, zones: next })
setVertebraTarget(null)
}}
initial={collectSpineVertebrae(
activeObs.zones,
bones,
activeObs.zones[vertebraTarget].boneId,
)}
formula={species.vertebralFormula}
title={`${t('vertebra.title_prefix')}${boneLabel(
bones.get(activeObs.zones[vertebraTarget].boneId),
locale,
'',
)}`}
initialRegion={(() => {
const b = bones.get(activeObs.zones[vertebraTarget].boneId)
return regionFromLabel(b?.fr ?? '') ?? regionFromLabel(b?.en ?? '')
})()}
/>
)}
{lateralTarget && activeObs && (
<LateralityPicker
open
onClose={() => setLateralTarget(null)}
title={boneLabel(
allBones.get(lateralTarget.boneId),
locale,
lateralTarget.boneId,
)}
existingSides={
activeObs.zones
.filter(
(z) =>
z.boneId === lateralTarget.boneId &&
z.detailSourceId === lateralTarget.detailSourceId &&
z.side,
)
.map((z) => z.side!) as LateralSide[]
}
onSelect={(sides) => {
const fresh =
useReportStore.getState().report?.observations[activeIndex]
if (!fresh) {
setLateralTarget(null)
return
}
const newSideZones = sides
.filter(
(side) =>
!fresh.zones.some(
(z) =>
z.boneId === lateralTarget.boneId &&
z.detailSourceId === lateralTarget.detailSourceId &&
z.side === side,
),
)
.map((side) => ({
boneId: lateralTarget.boneId,
...(lateralTarget.detailSourceId
? { detailSourceId: lateralTarget.detailSourceId }
: {}),
side,
}))
const nextZones = [...fresh.zones, ...newSideZones]
updateObservation(activeIndex, { ...fresh, zones: nextZones })
setLateralTarget(null)
}}
/>
)}
</main>
)
}
+42
View File
@@ -0,0 +1,42 @@
import { Link } from 'react-router-dom'
import AppHeader from '@/components/brand/AppHeader'
import Card from '@/components/ui/Card'
import { useT } from '@/i18n/useT'
export default function EditorsRoute() {
const t = useT()
return (
<main className="flex-1 flex flex-col">
<AppHeader />
<section className="flex-1 grid place-items-center px-4 sm:px-6">
<div className="grid gap-4 md:grid-cols-2 max-w-3xl w-full">
<Card className="p-4 sm:p-6 space-y-3 sm:space-y-4">
<h2 className="font-serif text-xl sm:text-2xl">{t('editors.svg.title')}</h2>
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editors.svg.description')}
</p>
<Link
to="/svg-editor"
className="inline-block rounded-lg bg-[var(--color-accent)] px-5 py-2 text-sm font-medium text-white hover:bg-[var(--color-accent-strong)] transition-colors"
>
{t('editors.svg.cta')}
</Link>
</Card>
<Card className="p-4 sm:p-6 space-y-3 sm:space-y-4">
<h2 className="font-serif text-xl sm:text-2xl">{t('editors.pathology.title')}</h2>
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editors.pathology.description')}
</p>
<a
href="/pathology-editor.html"
className="inline-block rounded-lg bg-[var(--color-accent)] px-5 py-2 text-sm font-medium text-white hover:bg-[var(--color-accent-strong)] transition-colors"
>
{t('editors.pathology.cta')}
</a>
</Card>
</div>
</section>
</main>
)
}
+74
View File
@@ -0,0 +1,74 @@
import { useNavigate } from 'react-router-dom'
import { useRef, useState } from 'react'
import AppHeader from '@/components/brand/AppHeader'
import Button from '@/components/ui/Button'
import Card from '@/components/ui/Card'
import { importReportFromPdf, ImportError } from '@/pdf/import'
import { useReportStore } from '@/state/reportStore'
import { useT } from '@/i18n/useT'
export default function HomeRoute() {
const navigate = useNavigate()
const fileRef = useRef<HTMLInputElement | null>(null)
const hydrate = useReportStore((s) => s.hydrateReport)
const [error, setError] = useState<string | null>(null)
const [busy, setBusy] = useState(false)
const t = useT()
async function onPickFile(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0]
if (!file) return
setBusy(true)
setError(null)
try {
const bytes = new Uint8Array(await file.arrayBuffer())
const report = await importReportFromPdf(bytes)
hydrate(report)
navigate('/editor')
} catch (err) {
if (err instanceof ImportError) {
if (err.kind === 'incompatible_version') {
setError(
t('home.import.error_incompatible_version').replace(
'{version}',
String(err.foundVersion ?? '?'),
),
)
} else if (err.kind === 'invalid_pdf') {
setError(t('home.import.error_invalid_pdf'))
} else {
setError(t('home.import.error_no_attachment'))
}
} else {
setError(t('home.import.error_generic'))
}
} finally {
setBusy(false)
if (fileRef.current) fileRef.current.value = ''
}
}
return (
<main className="flex-1 flex flex-col">
<AppHeader />
<section className="flex-1 grid place-items-center px-4 sm:px-6">
<div className="grid gap-4 md:grid-cols-2 max-w-3xl w-full">
<Card className="p-4 sm:p-6 space-y-3 sm:space-y-4">
<h2 className="font-serif text-xl sm:text-2xl">{t('home.new_report.title')}</h2>
<p className="text-sm text-[var(--color-ink-muted)]">{t('home.new_report.description')}</p>
<Button onClick={() => navigate('/new')} size="lg">{t('home.new_report.cta')}</Button>
</Card>
<Card className="p-4 sm:p-6 space-y-3 sm:space-y-4">
<h2 className="font-serif text-xl sm:text-2xl">{t('home.import.title')}</h2>
<p className="text-sm text-[var(--color-ink-muted)]">{t('home.import.description')}</p>
<input ref={fileRef} type="file" accept="application/pdf,.pdf" className="hidden" onChange={onPickFile} />
<Button variant="secondary" size="lg" onClick={() => fileRef.current?.click()} disabled={busy}>
{busy ? t('home.import.loading') : t('home.import.cta')}
</Button>
{error && <p className="text-sm text-red-700">{error}</p>}
</Card>
</div>
</section>
</main>
)
}
@@ -0,0 +1,64 @@
import { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import PractitionerForm from '@/components/report/PractitionerForm'
import AnimalForm from '@/components/report/AnimalForm'
import AppHeader from '@/components/brand/AppHeader'
import Button from '@/components/ui/Button'
import Input from '@/components/ui/Input'
import Label from '@/components/ui/Label'
import { todayIso } from '@/lib/dates'
import { readCachedPractitioner, writeCachedPractitioner } from '@/state/practitionerCache'
import { useReportStore } from '@/state/reportStore'
import { useT } from '@/i18n/useT'
export default function NewReportRoute() {
const navigate = useNavigate()
const initReport = useReportStore((s) => s.initReport)
const t = useT()
const [practitioner, setPractitioner] = useState({ name: '' })
const [animal, setAnimal] = useState({ speciesId: 'equine', name: '' })
const [owner, setOwner] = useState({ name: '' })
const [date, setDate] = useState(todayIso())
useEffect(() => {
const cached = readCachedPractitioner()
if (cached) setPractitioner(cached)
}, [])
const canSubmit = practitioner.name.trim() && animal.name.trim() && owner.name.trim()
function submit() {
if (!canSubmit) return
writeCachedPractitioner(practitioner)
initReport({
date,
practitioner,
animal,
owner,
observations: [],
conclusion: '',
recommendations: '',
})
navigate('/editor')
}
return (
<main className="min-h-screen">
<AppHeader />
<div className="max-w-3xl mx-auto px-4 sm:px-6 py-6 sm:py-8 space-y-6 sm:space-y-8">
<h1 className="font-serif text-2xl sm:text-3xl">{t('new_report.title')}</h1>
<div>
<Label htmlFor="date">{t('new_report.date_label')}</Label>
<Input id="date" type="date" value={date} onChange={(e) => setDate(e.target.value)} />
</div>
<PractitionerForm value={practitioner} onChange={setPractitioner} />
<AnimalForm animal={animal} owner={owner} onChangeAnimal={setAnimal} onChangeOwner={setOwner} />
<div className="flex gap-3 justify-end">
<Button variant="ghost" onClick={() => navigate('/')}>{t('common.cancel')}</Button>
<Button disabled={!canSubmit} onClick={submit}>{t('new_report.submit')}</Button>
</div>
</div>
</main>
)
}
+17
View File
@@ -0,0 +1,17 @@
import { useNavigate } from 'react-router-dom'
import Button from '@/components/ui/Button'
import { useT } from '@/i18n/useT'
export default function NotFoundRoute() {
const navigate = useNavigate()
const t = useT()
return (
<main className="min-h-screen grid place-items-center">
<div className="text-center space-y-4">
<h1 className="font-serif text-4xl">{t('not_found.title')}</h1>
<p className="text-[var(--color-ink-muted)]">{t('not_found.description')}</p>
<Button onClick={() => navigate('/')}>{t('common.back_to_home')}</Button>
</div>
</main>
)
}
File diff suppressed because it is too large. Load diff