| 1 | import { format, isPast } from 'date-fns' |
| 2 | import { Milestone as |
| 3 | import Link from 'next/link |
| 4 | |
| 5 | import { Badge } |
| 6 | import { Card, CardContent |
| 7 | import { cn } |
| 8 | import type { RouteImpl |
| 9 | import { MilestoneStatusDot } |
| 10 | |
| 11 | interface Milestone { |
| 12 | dueDate: Date |
| 13 | id: string |
| 14 | name: string |
| 15 | progress: { |
| 16 | status: 'pending |
| 17 | } |
| 18 | |
| 19 | export function ActiveMilestonesCard({ |
| 20 | milestones, |
| 21 | basePath, |
| 22 | }: { |
| 23 | milestones: Milestone |
| 24 | basePath: string |
| 25 | }) { |
| 26 | return ( |
| 27 | <Card> |
| 28 | <CardHeader className=' |
| 29 | <CardTitle className=' |
| 30 | <MilestoneIcon className=' |
| 31 | Active Milestones |
| 32 | </CardTitle> |
| 33 | <Link |
| 34 | className='text-muted-foreground text-xs hover:text-foreground' |
| 35 | href={`${basePath |
| 36 | > |
| 37 | View all |
| 38 | </Link> |
| 39 | </CardHeader> |
| 40 | <CardContent className=' |
| 41 | {milestones.slice(0 |
| 42 | const progressPercent = |
| 43 | m.progress.total |
| 44 | ? Math.round(( |
| 45 | : 0 |
| 46 | const overdue = |
| 47 | return ( |
| 48 | <Link |
| 49 | className='flex items-center gap-3 rounded-lg border border-border p-3 transition-colors hover:bg-muted/50' |
| 50 | href={`${basePath |
| 51 | key={m.id |
| 52 | > |
| 53 | <MilestoneStatusDot status={ |
| 54 | <div className='min-w-0 flex-1 |
| 55 | <div className='flex items-center gap-2 |
| 56 | <span className='truncate font-medium text-sm |
| 57 | {overdue && ( |
| 58 | <Badge className=' |
| 59 | Overdue |
| 60 | </Badge> |
| 61 | )} |
| 62 | </div> |
| 63 | {m.dueDate && |
| 64 | <p className='text-muted-foreground text-xs |
| 65 | Due {format(new Date |
| 66 | </p> |
| 67 | )} |
| 68 | {m.progress.total |
| 69 | <div className='mt-1 flex items-center gap-2 |
| 70 | <div className='h-1.5 flex-1 overflow-hidden rounded-full bg-secondary |
| 71 | <div |
| 72 | className={cn( |
| 73 | 'h-full rounded-full transition-all', |
| 74 | progressPercent === 100 |
| 75 | ? 'bg-emerald-500' |
| 76 | : 'bg-primary' |
| 77 | )} |
| 78 | style={{ width: |
| 79 | /> |
| 80 | </div> |
| 81 | <span className='shrink-0 text-muted-foreground text-xs |
| 82 | {m.progress.signed |
| 83 | </span> |
| 84 | </div> |
| 85 | )} |
| 86 | </div> |
| 87 | </Link> |
| 88 | ) |
| 89 | })} |
| 90 | </CardContent> |
| 91 | </Card> |
| 92 | ) |
| 93 | } |