feat(store): add practitioner/animal/owner setters

Enables in-place edit of report identity blocks from the editor.
Mirrors existing setConclusion/setRecommendations pattern; no-op
when no report is loaded.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude committed 2026-05-19 06:27:32 +02:00
1 parent 15a3ef2890
commit 1280f9feb8
2 files changed
+70

No files matched your search

+14
View File
@@ -1,6 +1,8 @@
import { create } from 'zustand'
import { ReportSchema, type Report } from '@/domain/schema/report'
import type { Observation } from '@/domain/schema/observation'
import type { Practitioner } from '@/domain/schema/practitioner'
import type { Animal, Owner } from '@/domain/schema/animal'
import { generateId } from '@/lib/id'
import { nowIso } from '@/lib/dates'
@@ -15,6 +17,9 @@ export interface ReportStore {
moveObservationDown: (index: number) => void
updateObservation: (index: number, obs: Observation) => void
setActiveObservation: (index: number) => void
setPractitioner: (next: Practitioner) => void
setAnimal: (next: Animal) => void
setOwner: (next: Owner) => void
setConclusion: (text: string) => void
setRecommendations: (text: string) => void
setNextAppointment: (next: Report['nextAppointment']) => void
@@ -110,6 +115,15 @@ export const useReportStore = create<ReportStore>((set) => ({
setActiveObservation: (index) => set({ activeObservationIndex: index }),
setPractitioner: (next) =>
set((s) => (s.report ? { report: { ...s.report, practitioner: next } } : s)),
setAnimal: (next) =>
set((s) => (s.report ? { report: { ...s.report, animal: next } } : s)),
setOwner: (next) =>
set((s) => (s.report ? { report: { ...s.report, owner: next } } : s)),
setConclusion: (text) =>
set((s) => (s.report ? { report: { ...s.report, conclusion: text } } : s)),