Um campo responsible (staff campaignUser · leadership · stateDeputy) multi-valor substitui responsible/Contact + advisors + leadership; assessor mantém acesso via notação-objeto equals no access; nova migração esquema+dados (advisors/leadership → responsible); busca q da lista título-only; notificação notifica staff do campo. Closes #426
72 lines
3 KiB
TypeScript
72 lines
3 KiB
TypeScript
import { CalendarIcon, MapPinIcon, UserIcon } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
|
|
import { ActivityStatusBadge } from '@/components/campaign/activity/ActivityStatusBadge'
|
|
import { Badge } from '@/components/ui/Badge'
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
import { formatActivityWhenLabel, type ActivityListViewModel } from '@/utilities/activityViewModels'
|
|
|
|
export const ActivityCard = ({ activity }: { activity: ActivityListViewModel }) => (
|
|
<Card>
|
|
<CardHeader>
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
{activity.tags.map((tag) => (
|
|
<Badge key={tag} variant="secondary">
|
|
{tag}
|
|
</Badge>
|
|
))}
|
|
<ActivityStatusBadge status={activity.status} />
|
|
{activity.deputyPresent ? <Badge>Deputado presente</Badge> : null}
|
|
</div>
|
|
<CardTitle>
|
|
<Link
|
|
href={`/campanha/atividades/${activity.slug}`}
|
|
className="text-foreground underline-offset-4 hover:underline"
|
|
>
|
|
{activity.title}
|
|
</Link>
|
|
</CardTitle>
|
|
</CardHeader>
|
|
<CardContent className="flex flex-col gap-2">
|
|
<div className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
<CalendarIcon aria-hidden="true" className="size-4 shrink-0" />
|
|
<span>{formatActivityWhenLabel(activity.startAt)}</span>
|
|
</div>
|
|
{activity.locationLabel ? (
|
|
<div className="flex items-center gap-1.5 text-sm text-muted-foreground">
|
|
<MapPinIcon aria-hidden="true" className="size-4 shrink-0" />
|
|
<Badge variant="outline">{activity.locationLabel}</Badge>
|
|
</div>
|
|
) : null}
|
|
<div className="flex flex-wrap items-center justify-between gap-2 pt-1 text-sm">
|
|
<span className="flex min-w-0 items-center gap-1.5 text-muted-foreground">
|
|
<UserIcon aria-hidden="true" className="size-4 shrink-0" />
|
|
{activity.responsibles.length ? (
|
|
<span className="flex min-w-0 flex-wrap gap-1">
|
|
{activity.responsibles.slice(0, 2).map((responsible) => (
|
|
<Badge
|
|
key={`${responsible.relationTo}:${responsible.id}`}
|
|
variant="outline"
|
|
className="min-w-0 gap-1"
|
|
>
|
|
<span className="truncate">{responsible.name}</span>
|
|
<span className="shrink-0 text-muted-foreground">{responsible.typeLabel}</span>
|
|
</Badge>
|
|
))}
|
|
{activity.responsibles.length > 2 ? (
|
|
<Badge variant="outline">+{activity.responsibles.length - 2}</Badge>
|
|
) : null}
|
|
</span>
|
|
) : (
|
|
'Resp: Não definido'
|
|
)}
|
|
</span>
|
|
{activity.taskProgress.total > 0 ? (
|
|
<span className="font-medium tabular-nums text-muted-foreground">
|
|
{activity.taskProgress.done}/{activity.taskProgress.total} tarefas
|
|
</span>
|
|
) : null}
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)
|