import type { TeamMembership } from '../../../services/collaborationTeam'; /** Clinicians actively on the team, in-practice and outside alike. */ export const activeClinicianCount = (members: TeamMembership[]): number => members.filter((member) => member.state === 'active' && (member.memberClass === 'practitioner' || member.memberClass === 'external-practitioner'), ).length; /** "3 clinicians". The card puts it after the practice name, which is shown only when it is known. */ export const clinicianCountLabel = (clinicians: number): string => `${clinicians} clinician${clinicians === 1 ? '' : 's'}`; /** "Joined 12 Mar", dated by the membership's last change, which for an active one is its move to active. */ export const joinedLabel = (membership: TeamMembership | undefined): string | undefined => { if (membership?.state !== 'active' || !membership.updatedAt) return undefined; const at = new Date(membership.updatedAt); if (Number.isNaN(at.getTime())) return undefined; return `Joined ${at.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })}`; };