feat(editor): home navigation and edit-infos dialog
Header now exposes a back button and clickable brand title both linking to /. New "Modifier les infos" button opens a dialog that edits practitioner, animal, and owner via the existing forms with cancel/save and required-name validation. Save also refreshes the practitioner localStorage cache. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
1280f9feb8
commit
908790123d
2 files changed
+120
-7
No files matched your search
@@ -8,14 +8,20 @@ import VertebraPicker, {
|
||||
} from '@/components/observation/VertebraPicker'
|
||||
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 type { Bone, BoneState } from '@/anatomy/types'
|
||||
import type { Observation, ObservationZone } from '@/domain/schema/observation'
|
||||
import type { Pathology } from '@/domain/schema/pathology'
|
||||
import type { Practitioner } from '@/domain/schema/practitioner'
|
||||
import type { Animal, Owner } from '@/domain/schema/animal'
|
||||
import { exportReportToPdf } from '@/pdf/export'
|
||||
|
||||
export default function EditorRoute() {
|
||||
@@ -31,6 +37,9 @@ export default function EditorRoute() {
|
||||
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())
|
||||
@@ -42,6 +51,40 @@ export default function EditorRoute() {
|
||||
} | null>(null)
|
||||
const [vertebraTarget, setVertebraTarget] = useState<number | 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()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!report) navigate('/')
|
||||
@@ -193,7 +236,7 @@ export default function EditorRoute() {
|
||||
|
||||
return (
|
||||
<main className="min-h-screen flex flex-col">
|
||||
<ReportHeader report={report} />
|
||||
<ReportHeader report={report} onEditInfos={openEditInfos} />
|
||||
<div className="flex-1 grid grid-cols-1 lg:grid-cols-[2fr_3fr] gap-6 p-6">
|
||||
<section className="border border-[var(--color-border)] rounded-2xl bg-[var(--color-surface)] overflow-hidden">
|
||||
<AnatomyCanvas
|
||||
@@ -253,6 +296,49 @@ export default function EditorRoute() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{editDraft && (
|
||||
<Dialog
|
||||
open={editOpen}
|
||||
onClose={closeEditInfos}
|
||||
title="Modifier les informations"
|
||||
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}>
|
||||
Annuler
|
||||
</Button>
|
||||
<Button
|
||||
onClick={saveEditInfos}
|
||||
disabled={
|
||||
!editDraft.practitioner.name.trim() ||
|
||||
!editDraft.animal.name.trim() ||
|
||||
!editDraft.owner.name.trim()
|
||||
}
|
||||
>
|
||||
Enregistrer
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
)}
|
||||
|
||||
{vertebraTarget !== null &&
|
||||
activeObs &&
|
||||
activeObs.zones[vertebraTarget] && (
|
||||
|
||||
Reference in new issue
Block a user