import { Link } from "react-router-dom"; import { OrgSection } from "./OrgSection.tsx"; import { usePatientServiceContext } from "../../../../services/PatientService.tsx"; import { useAuthServiceContext } from "../../../../services/AuthService.tsx"; import { SectionReadNotice } from "./SectionReadNotice.tsx"; import { AppSpinner } from "../../../../components"; import { EmptyState } from "../../../../components/ui/empty-state.tsx"; import { joinNames } from "../../../../utils/orgCollabTeams"; import type { OrgCollabTeamsState } from "../useOrgCollabTeams.ts"; /** The patient's collaboration teams this practice has people in, and who those people are. */ export const OrgCollabTeamsSection = ({ collab, organizationName, }: { collab: OrgCollabTeamsState; organizationName?: string; }) => { const practice = organizationName || "This practice"; const { patientState } = usePatientServiceContext(); const { actingAs, currentUser } = useAuthServiceContext(); // The age gate refuses teams when the record has no date of birth. Only on the signed-in patient's own // record, once it has been read, is that theirs to fix; a helper shown the patient they help, and a // known adolescent, keep the ordinary refusal. const ownRecord = currentUser?.fhir?.resourceType === "Patient" && currentUser.fhir.id === patientState?.id; const needsBirthDate = collab.failure === "denied" && !actingAs && ownRecord && !!patientState && !patientState.birthDate; return ( {needsBirthDate ? (

Add your date of birth in your profile so we can determine which features are available to you.

Add your date of birth
) : collab.failure ? ( ) : collab.teams === null ? (
) : collab.teams.length === 0 ? ( ) : (
    {collab.teams.map((team) => (
  • {team.name}

    {joinNames(team.fromHere)} from here · {team.memberCount}{" "} {team.memberCount === 1 ? "member" : "members"} in all

  • ))}
)}
); }; export default OrgCollabTeamsSection;