|
| 1 | +import { Card, CardContent } from "@/components/ui/card"; |
| 2 | +import { Badge } from "@/components/ui/badge"; |
| 3 | +import { CheckCircle2 } from "lucide-react"; |
| 4 | +import type { HiringIntent } from "@/lib/utils"; |
| 5 | + |
| 6 | +interface ActionCardProps { |
| 7 | + intent: HiringIntent; |
| 8 | +} |
| 9 | + |
| 10 | +export function ActionCard({ intent }: ActionCardProps) { |
| 11 | + const getCategoryColor = (category?: string) => { |
| 12 | + switch (category) { |
| 13 | + case "funding": |
| 14 | + return "bg-blue-100 text-blue-800"; |
| 15 | + case "growth": |
| 16 | + return "bg-green-100 text-green-800"; |
| 17 | + case "replacement": |
| 18 | + return "bg-amber-100 text-amber-800"; |
| 19 | + default: |
| 20 | + return "bg-gray-100 text-gray-800"; |
| 21 | + } |
| 22 | + }; |
| 23 | + |
| 24 | + const formatDate = (dateString?: string) => { |
| 25 | + if (!dateString) return "N/A"; |
| 26 | + const date = new Date(dateString); |
| 27 | + return date.toLocaleDateString("en-US", { |
| 28 | + year: "numeric", |
| 29 | + month: "short", |
| 30 | + day: "numeric", |
| 31 | + }); |
| 32 | + }; |
| 33 | + |
| 34 | + return ( |
| 35 | + <Card className="hover:shadow-md transition-shadow border-l-4 border-l-green-500 w-full"> |
| 36 | + <CardContent className="pt-4 px-3 md:px-6"> |
| 37 | + <div className="flex items-start gap-2 md:gap-3"> |
| 38 | + <CheckCircle2 className="w-4 h-4 md:w-5 md:h-5 text-green-600 mt-0.5 flex-shrink-0" /> |
| 39 | + <div className="flex-1 min-w-0"> |
| 40 | + <div className="flex items-center gap-2 mb-2 flex-wrap"> |
| 41 | + <h3 className="font-semibold text-sm md:text-base text-gray-900 line-clamp-2"> |
| 42 | + {intent.company_profile?.name || "Unknown Company"} |
| 43 | + </h3> |
| 44 | + {intent.category && ( |
| 45 | + <Badge className={getCategoryColor(intent.category)} variant="secondary"> |
| 46 | + {intent.category} |
| 47 | + </Badge> |
| 48 | + )} |
| 49 | + </div> |
| 50 | + |
| 51 | + {/* Potential Role */} |
| 52 | + {intent.potential_role && ( |
| 53 | + <div className="mb-2"> |
| 54 | + <p className="text-xs font-medium text-gray-500 mb-1">Role</p> |
| 55 | + <div className="flex flex-wrap gap-1"> |
| 56 | + {(Array.isArray(intent.potential_role) |
| 57 | + ? intent.potential_role |
| 58 | + : typeof intent.potential_role === "string" |
| 59 | + ? [intent.potential_role] |
| 60 | + : [] |
| 61 | + ).map((role, index) => ( |
| 62 | + <Badge key={index} variant="outline" className="bg-purple-50 text-purple-700 border-purple-200 text-xs"> |
| 63 | + {role} |
| 64 | + </Badge> |
| 65 | + ))} |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + )} |
| 69 | + |
| 70 | + {/* Reason */} |
| 71 | + {intent.reason && ( |
| 72 | + <div className="mb-2"> |
| 73 | + <p className="text-xs font-medium text-gray-500 mb-0.5">Reason</p> |
| 74 | + <p className="text-sm text-gray-600 line-clamp-2">{intent.reason}</p> |
| 75 | + </div> |
| 76 | + )} |
| 77 | + |
| 78 | + {/* Skills */} |
| 79 | + {intent.skill && ( |
| 80 | + <div className="mb-2"> |
| 81 | + <p className="text-xs font-medium text-gray-500 mb-1">Skills</p> |
| 82 | + <div className="flex flex-wrap gap-1"> |
| 83 | + {(Array.isArray(intent.skill) |
| 84 | + ? intent.skill |
| 85 | + : typeof intent.skill === "string" |
| 86 | + ? [intent.skill] |
| 87 | + : [] |
| 88 | + ).map((skill, index) => ( |
| 89 | + <Badge key={index} variant="outline" className="bg-blue-50 text-blue-700 border-blue-200 text-xs"> |
| 90 | + {skill} |
| 91 | + </Badge> |
| 92 | + ))} |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + )} |
| 96 | + |
| 97 | + {/* Actions metadata */} |
| 98 | + {intent.actions && intent.actions.length > 0 && ( |
| 99 | + <div className="mt-2 pt-2 border-t border-gray-100"> |
| 100 | + <p className="text-xs text-gray-400"> |
| 101 | + Added {formatDate(intent.actions[0].date_created)} |
| 102 | + </p> |
| 103 | + </div> |
| 104 | + )} |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + </CardContent> |
| 108 | + </Card> |
| 109 | + ); |
| 110 | +} |
0 commit comments