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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | 1x 1x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 23x 23x 23x 1x 1x 1x 1x 1x 22x 22x 22x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 1x 1x 1x 1x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 22x 22x 22x 23x 22x 22x 66x 66x 66x 66x 22x 22x 22x 22x 22x 22x 23x 22x 22x 110x 110x 110x 22x 22x 22x 22x 22x 22x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x | 'use client';
import { Building2, MapPin, Calendar, ExternalLink, CheckCircle } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { formatDate } from '@/lib/utils';
import { employmentTypeLabels, locationTypeLabels } from '@/lib/validations/experience';
import type { WorkExperience } from '@/types/database';
interface ExperienceCardProps {
experience: WorkExperience;
showActions?: boolean;
onEdit?: () => void;
onDelete?: () => void;
}
export function ExperienceCard({
experience,
showActions = false,
onEdit,
onDelete,
}: ExperienceCardProps) {
const startDate = new Date(experience.start_date);
const endDate = experience.end_date ? new Date(experience.end_date) : null;
const duration = calculateDuration(startDate, endDate, experience.is_current);
return (
<div className="relative rounded-lg border bg-card p-4 transition-colors hover:bg-muted/30">
{/* Actions overlay */}
{showActions && (
<div className="absolute right-2 top-2 flex gap-2 opacity-0 transition-opacity group-hover:opacity-100">
{onEdit && (
<button
onClick={onEdit}
className="rounded bg-muted px-2 py-1 text-xs hover:bg-muted/80"
>
Edit
</button>
)}
{onDelete && (
<button
onClick={onDelete}
className="rounded bg-destructive/10 px-2 py-1 text-xs text-destructive hover:bg-destructive/20"
>
Delete
</button>
)}
</div>
)}
<div className="flex gap-4">
{/* Company Logo */}
<div className="flex-shrink-0">
{experience.company_logo_url ? (
<img
src={experience.company_logo_url}
alt={experience.company_name}
className="h-12 w-12 rounded-lg object-cover"
/>
) : (
<div className="flex h-12 w-12 items-center justify-center rounded-lg bg-muted">
<Building2 className="h-6 w-6 text-muted-foreground" />
</div>
)}
</div>
{/* Content */}
<div className="min-w-0 flex-1">
{/* Header */}
<div className="flex items-start justify-between gap-2">
<div>
<h3 className="font-semibold leading-tight">{experience.role_title}</h3>
<div className="flex items-center gap-1 text-sm text-muted-foreground">
<span>{experience.company_name}</span>
{experience.company_website && (
<a
href={experience.company_website}
target="_blank"
rel="noopener noreferrer"
className="hover:text-primary"
>
<ExternalLink className="h-3 w-3" />
</a>
)}
</div>
</div>
{experience.verification_status !== 'unverified' && (
<div className="flex items-center gap-1 text-xs text-green-600">
<CheckCircle className="h-3.5 w-3.5" />
<span>Verified</span>
</div>
)}
</div>
{/* Meta */}
<div className="mt-2 flex flex-wrap items-center gap-3 text-sm text-muted-foreground">
<div className="flex items-center gap-1">
<Calendar className="h-3.5 w-3.5" />
<span>
{formatDate(startDate.toISOString())} -{' '}
{experience.is_current ? 'Present' : formatDate(endDate?.toISOString() || '')}
</span>
<span className="text-muted-foreground/60">({duration})</span>
</div>
{experience.location && (
<div className="flex items-center gap-1">
<MapPin className="h-3.5 w-3.5" />
<span>{experience.location}</span>
</div>
)}
</div>
{/* Badges */}
<div className="mt-2 flex flex-wrap gap-2">
<Badge variant="secondary" className="text-xs">
{employmentTypeLabels[experience.employment_type]}
</Badge>
<Badge variant="outline" className="text-xs">
{locationTypeLabels[experience.location_type]}
</Badge>
</div>
{/* Description */}
{experience.description && (
<p className="mt-3 line-clamp-3 text-sm text-muted-foreground">
{experience.description}
</p>
)}
{/* Achievements */}
{experience.achievements && experience.achievements.length > 0 && (
<ul className="mt-3 space-y-1 text-sm">
{experience.achievements.slice(0, 3).map((achievement, i) => (
<li key={i} className="flex items-start gap-2">
<span className="text-primary">•</span>
<span>{achievement}</span>
</li>
))}
{experience.achievements.length > 3 && (
<li className="text-xs text-muted-foreground">
+{experience.achievements.length - 3} more
</li>
)}
</ul>
)}
{/* Skills */}
{experience.skills && experience.skills.length > 0 && (
<div className="mt-3 flex flex-wrap gap-1">
{experience.skills.slice(0, 5).map((skill) => (
<Badge key={skill} variant="outline" className="text-xs font-normal">
{skill}
</Badge>
))}
{experience.skills.length > 5 && (
<Badge variant="outline" className="text-xs font-normal text-muted-foreground">
+{experience.skills.length - 5}
</Badge>
)}
</div>
)}
</div>
</div>
</div>
);
}
function calculateDuration(startDate: Date, endDate: Date | null, isCurrent: boolean): string {
const end = isCurrent ? new Date() : endDate || new Date();
const months =
(end.getFullYear() - startDate.getFullYear()) * 12 + (end.getMonth() - startDate.getMonth());
const years = Math.floor(months / 12);
const remainingMonths = months % 12;
if (years === 0) {
return remainingMonths === 1 ? '1 mo' : `${remainingMonths} mos`;
}
if (remainingMonths === 0) {
return years === 1 ? '1 yr' : `${years} yrs`;
}
return `${years} yr${years > 1 ? 's' : ''} ${remainingMonths} mo${remainingMonths > 1 ? 's' : ''}`;
}
|