Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 53x 53x 53x 53x 17x 17x 17x | import type { ReactNode } from 'react'
import { Phone, Stethoscope, Users } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import type { Baby } from '@/features/babies/api/babies.schemas'
import { babyAvatarAppearance, babyInitials } from '@/shared/utils/babyAvatarColor'
import { isPrivateEntry, type Specialist } from '../api/specialists.schemas'
interface Props {
specialist: Specialist
babies: Baby[]
linksPending?: boolean
linksError?: boolean
accessKnown: boolean
isOwner: boolean
actions?: ReactNode
}
export function SpecialistCard({
specialist,
babies,
linksPending,
linksError,
accessKnown,
isOwner,
actions,
}: Props) {
const { t } = useTranslation()
const linked = babies.filter((baby) => specialist.babyIds.includes(baby.id))
const missing = specialist.babyIds.length - linked.length
return (
<article className="flex min-w-0 flex-col rounded-2xl border border-border bg-card p-5 sm:p-6">
<div className="flex items-start gap-3">
<span
aria-hidden
className="flex size-11 shrink-0 items-center justify-center rounded-xl bg-primary/5 text-primary"
>
<Stethoscope className="size-5" />
</span>
<div className="min-w-0">
<h2 className="break-words text-lg font-bold text-ink">{specialist.name}</h2>
<p className="mt-1 break-words text-sm text-ink-muted">
{specialist.specialty || t('specialists.page.noSpecialty')}
</p>
</div>
</div>
{!accessKnown ? (
<p className="mt-3 text-xs text-ink-muted">{t('specialists.page.accessUnknown')}</p>
) : (
!isOwner && (
<div className="mt-3 rounded-xl bg-muted/60 p-3 text-xs text-ink-muted">
<p className="flex items-center gap-2 font-semibold">
<Users aria-hidden className="size-4" />
{t('specialists.page.shared')}
</p>
<p className="mt-1">{t('specialists.page.readOnly')}</p>
</div>
)
)}
<div className="mt-4 border-t border-border pt-3">
{specialist.phone ? (
<a
href={`tel:${specialist.phone.replace(/\s/g, '')}`}
className="inline-flex min-h-11 max-w-full items-center gap-2 rounded-xl py-2 font-sans tabular-nums text-sm font-semibold text-primary underline-offset-4 hover:underline"
>
<Phone aria-hidden className="size-4 shrink-0" />
<span className="break-all">{specialist.phone}</span>
</a>
) : (
<p className="py-3 text-sm text-ink-muted">{t('specialists.page.noPhone')}</p>
)}
{specialist.babyIds.length ? (
linksPending || linksError ? (
<p className="mt-2 text-xs text-ink-muted">
{t(linksError ? 'specialists.page.linksError' : 'common.loading')}
</p>
) : (
<div className="mt-2">
{linked.length > 0 && (
<>
<p className="text-xs text-ink-muted">
{t('specialists.attends', { list: linked.map((baby) => baby.name).join(', ') })}
</p>
<div aria-hidden className="mt-2 flex flex-wrap gap-1.5">
{linked.map((baby) => {
const avatar = babyAvatarAppearance(baby.id, baby.avatarColor)
return (
<span
key={baby.id}
className={`flex size-7 items-center justify-center overflow-hidden rounded-full text-xs font-bold ${avatar.className}`}
style={avatar.style}
>
{baby.avatarUrl ? (
<img src={baby.avatarUrl} alt="" className="size-full object-cover" />
) : (
babyInitials(baby.name)
)}
</span>
)
})}
</div>
</>
)}
{missing > 0 && (
<p className="mt-1 text-xs text-ink-muted">{t('specialists.page.otherLinks')}</p>
)}
</div>
)
) : (
<p className="mt-2 text-xs text-ink-muted">
{t(isPrivateEntry(specialist) ? 'specialists.privateEntry' : 'specialists.sharedOnly')}
</p>
)}
</div>
{actions && (
<div className="mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-border pt-3">
{actions}
</div>
)}
</article>
)
}
|