import { useState } from "react"; import { toast } from "sonner"; import { useListServiceContext, usePatientServiceContext } from "../../../services"; import { useFhirClinicalLists } from "../../../hooks"; import { Button } from "../../../components/ui/button"; import { describeWriteFailure } from "../../../utils/fetchFailureMessage"; /** The "none" answer for an empty family list, recorded as a nil-known list like no known family history. */ export const NobodyToAdd = () => { const { patientState } = usePatientServiceContext(); const { confirmNoRelatedPersons } = useListServiceContext(); const { hasConfirmedNoRelatedPersons } = useFhirClinicalLists(); const [saving, setSaving] = useState(false); if (hasConfirmedNoRelatedPersons) { return

You said there is nobody to add for now. You can add someone any time.

; } const confirm = async () => { if (!patientState) { toast.error("Patient context is not available yet."); return; } setSaving(true); try { await confirmNoRelatedPersons(patientState); toast.success("Recorded that you have nobody to add."); } catch (failure) { console.error("Failed to record nobody to add:", failure); toast.error(describeWriteFailure(failure, "Unable to record that you have nobody to add")); } finally { setSaving(false); } }; return ( ); };