| 1 | import { formatDistanceToNow } from 'date-fns' |
| 2 | import Link from 'next/link |
| 3 | import StatusBadge from '@/components/status-badge |
| 4 | import { Card } |
| 5 | import type { requirements |
| 6 | import type { Role |
| 7 | |
| 8 | type Requirement |
| 9 | |
| 10 | function stripHtml(html: |
| 11 | return html |
| 12 | .replace(/<[^ |
| 13 | .replace(/\s+/ |
| 14 | .trim() |
| 15 | } |
| 16 | |
| 17 | export default function RequirementCard |
| 18 | requirement, |
| 19 | orgSlug, |
| 20 | projectSlug, |
| 21 | role, |
| 22 | isClientInvolved, |
| 23 | }: { |
| 24 | requirement: Requirement |
| 25 | orgSlug: string |
| 26 | projectSlug: string |
| 27 | role: Role |
| 28 | isClientInvolved?: boolean |
| 29 | }) { |
| 30 | return ( |
| 31 | <Link |
| 32 | className='h-full' |
| 33 | href={`/${orgSlug |
| 34 | > |
| 35 | <Card className=' |
| 36 | <div className='mb-1.5 flex items-center justify-between gap-2 |
| 37 | <StatusBadge |
| 38 | isClientInvolved={isClientInvolved} |
| 39 | role={role} |
| 40 | status={requirement.status |
| 41 | /> |
| 42 | <span className='shrink-0 text-muted-foreground text-xs |
| 43 | {formatDistanceToNow(new Date |
| 44 | addSuffix: true, |
| 45 | })} |
| 46 | </span> |
| 47 | </div> |
| 48 | <h3 className='line-clamp-1 font-semibold |
| 49 | {requirement.body ? |
| 50 | <p className='mt-1 line-clamp-2 flex-1 text-muted-foreground text-sm |
| 51 | {stripHtml(requirement.body |
| 52 | </p> |
| 53 | ) : ( |
| 54 | <p className='mt-1 flex-1 text-muted-foreground/50 text-sm italic |
| 55 | No description |
| 56 | </p> |
| 57 | )} |
| 58 | </Card> |
| 59 | </Link> |
| 60 | ) |
| 61 | } |