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] && (
|
||||
|
||||
@@ -1,20 +1,47 @@
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import type { Report } from '@/domain/schema/report'
|
||||
import Brand from '@/components/brand/Brand'
|
||||
import Button from '@/components/ui/Button'
|
||||
import { formatDateFr } from '@/lib/dates'
|
||||
|
||||
export interface ReportHeaderProps {
|
||||
report: Report
|
||||
onEditInfos?: () => void
|
||||
}
|
||||
|
||||
export default function ReportHeader({ report }: ReportHeaderProps) {
|
||||
export default function ReportHeader({ report, onEditInfos }: ReportHeaderProps) {
|
||||
const navigate = useNavigate()
|
||||
return (
|
||||
<header className="flex items-center justify-between gap-4 px-6 py-3 border-b border-[var(--color-border)] bg-[var(--color-surface)]">
|
||||
<Brand />
|
||||
<div className="text-sm text-right text-[var(--color-ink-muted)]">
|
||||
<div className="text-[var(--color-ink)] font-medium">
|
||||
{report.animal.name} · {report.owner.name}
|
||||
<div className="flex items-center gap-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/')}
|
||||
aria-label="Retour à l'accueil"
|
||||
>
|
||||
← Accueil
|
||||
</Button>
|
||||
<Link
|
||||
to="/"
|
||||
aria-label="Retour à l'accueil"
|
||||
className="rounded-md px-1 py-0.5 hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]"
|
||||
>
|
||||
<Brand />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="text-sm text-right text-[var(--color-ink-muted)]">
|
||||
<div className="text-[var(--color-ink)] font-medium">
|
||||
{report.animal.name} · {report.owner.name}
|
||||
</div>
|
||||
<div>{formatDateFr(report.date)}</div>
|
||||
</div>
|
||||
<div>{formatDateFr(report.date)}</div>
|
||||
{onEditInfos && (
|
||||
<Button variant="secondary" size="sm" onClick={onEditInfos}>
|
||||
Modifier les infos
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user