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 | 1x 1x 23x 2x 2x 21x 21x 21x 21x 21x 21x 21x 22x 22x 22x 22x 22x 22x 21x 21x 21x 22x 22x 22x 22x 22x 22x 22x 22x 21x 21x 21x 21x 21x 1x 1x 1x 22x 22x 22x 22x 22x 22x 22x 22x 21x 21x 21x 21x 21x 21x 21x 22x 22x 22x 21x 21x 21x 21x 22x 22x 22x 22x 22x 22x 22x 22x 21x 21x 21x 21x 21x 21x 21x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 21x 22x 21x 21x 42x 42x 42x 42x 21x 21x 22x 21x 21x 63x 63x 63x 21x 21x 22x 22x 22x 43x 43x 43x 43x 22x 22x 22x 22x 22x 22x 22x 3x 3x 22x 2x 2x 22x 22x | 'use client';
import { Building2, MapPin, ExternalLink, CheckCircle } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { employmentTypeLabels, locationTypeLabels } from '@/lib/validations/experience';
import type { WorkExperience } from '@/types/database';
interface ExperienceTimelineProps {
experiences: WorkExperience[];
}
export function ExperienceTimeline({ experiences }: ExperienceTimelineProps) {
if (!experiences || experiences.length === 0) {
return null;
}
// Sort by start date descending (most recent first)
const sortedExperiences = [...experiences].sort(
(a, b) => new Date(b.start_date).getTime() - new Date(a.start_date).getTime()
);
return (
<div className="relative space-y-0">
{/* Timeline line */}
<div className="absolute bottom-8 left-6 top-8 w-px bg-border" />
{sortedExperiences.map((experience, index) => (
<ExperienceTimelineItem
key={experience.id}
experience={experience}
isFirst={index === 0}
isLast={index === sortedExperiences.length - 1}
/>
))}
</div>
);
}
interface ExperienceTimelineItemProps {
experience: WorkExperience;
isFirst: boolean;
isLast: boolean;
}
function ExperienceTimelineItem({ experience }: ExperienceTimelineItemProps) {
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 flex gap-4 pb-8 last:pb-0">
{/* Timeline dot */}
<div className="relative z-10 flex-shrink-0">
{experience.company_logo_url ? (
<img
src={experience.company_logo_url}
alt={experience.company_name}
className="h-12 w-12 rounded-full border-4 border-background object-cover"
/>
) : (
<div className="flex h-12 w-12 items-center justify-center rounded-full border-4 border-background bg-muted">
<Building2 className="h-5 w-5 text-muted-foreground" />
</div>
)}
</div>
{/* Content */}
<div className="flex-1 pt-1">
<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 rounded-full bg-green-100 px-2 py-0.5 text-xs text-green-700 dark:bg-green-900/30 dark:text-green-400">
<CheckCircle className="h-3 w-3" />
<span>Verified</span>
</div>
)}
</div>
{/* Meta */}
<div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground">
<span>
{formatMonthYear(startDate)} -{' '}
{experience.is_current ? 'Present' : formatMonthYear(endDate)}
</span>
<span className="text-muted-foreground/60">({duration})</span>
{experience.location && (
<>
<span className="hidden sm:inline">•</span>
<span className="flex items-center gap-1">
<MapPin className="h-3.5 w-3.5" />
{experience.location}
</span>
</>
)}
</div>
{/* Tags */}
<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 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.map((achievement, i) => (
<li key={i} className="flex items-start gap-2">
<span className="mt-1 text-primary">•</span>
<span>{achievement}</span>
</li>
))}
</ul>
)}
{/* Skills */}
{experience.skills && experience.skills.length > 0 && (
<div className="mt-3 flex flex-wrap gap-1">
{experience.skills.map((skill) => (
<Badge key={skill} variant="outline" className="text-xs font-normal">
{skill}
</Badge>
))}
</div>
)}
</div>
</div>
);
}
function formatMonthYear(date: Date | null): string {
if (!date) return '';
return date.toLocaleDateString('en-US', { month: 'short', year: 'numeric' });
}
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' : ''}`;
}
|