import type { ReactNode } from "react"; import { History, Loader2, Pencil } from "lucide-react"; import { FieldHistoryProvider, FieldHistoryScope, useFieldHistory } from "../FieldHistory/FieldHistoryProvider"; import { RELOAD_DISCARDS_MESSAGE } from "../../utils/recordChanged"; import "./ProfileSection.css"; /** One profile section: History and Edit in the heading, one Cancel/Save pair, its own field history. */ const SectionHistory = ({ title }: { title: string }) => { const { isActive, loading, activate, deactivate } = useFieldHistory(); return ( ); }; const SectionHistoryHint = () => { const { isActive, nothingEverEdited, historyUnavailable, historyRefused } = useFieldHistory(); if (!isActive) return null; if (historyRefused) { return
Your access to this patient does not include its edit history.
; } if (historyUnavailable) { returnWe could not read this history just now.
; } return ({nothingEverEdited ? "Nothing in this section has been edited yet." : "Select a highlighted field to see its changes."}
); }; export interface ProfileSectionProps { title: string; icon: ReactNode; /** The Patient whose history this section reads. */ patientId?: string; canEdit: boolean; editing: boolean; saving: boolean; error?: string | null; /** This opening can save nothing more (refused, out of date, or unconfirmed): Reload record or Cancel. */ stale?: boolean; reloading?: boolean; onReload?: () => void; onEdit: () => void; onCancel: () => void; onSave: () => void; readView: ReactNode; editView: ReactNode; } export const ProfileSection = ({ title, icon, patientId, canEdit, editing, saving, error, stale = false, reloading = false, onReload, onEdit, onCancel, onSave, readView, editView, }: ProfileSectionProps) => (