'use client'; import Link from 'next/link'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui'; import { Badge } from '@/components/ui'; import { getGravatarUrl } from '@/lib/gravatar'; import type { OKR, KeyResult, OKRStatus, KeyResultStatus } from '@/lib/types'; import { OKR_STATUS_LABELS, KEY_RESULT_STATUS_LABELS } from '@/lib/types'; // Helper functions for status colors function getOKRStatusColor(status: OKRStatus): { bg: string; color: string } { switch (status) { case 'NOT_STARTED': return { bg: 'color-mix(in srgb, #6b7280 15%, transparent)', // gray-500 color: '#6b7280', }; case 'IN_PROGRESS': return { bg: 'color-mix(in srgb, #3b82f6 15%, transparent)', // blue-500 color: '#3b82f6', }; case 'COMPLETED': return { bg: 'color-mix(in srgb, #10b981 15%, transparent)', // green-500 (success) color: '#10b981', }; case 'CANCELLED': return { bg: 'color-mix(in srgb, #ef4444 15%, transparent)', // red-500 (destructive) color: '#ef4444', }; default: return { bg: 'color-mix(in srgb, #6b7280 15%, transparent)', color: '#6b7280', }; } } function getKeyResultStatusColor(status: KeyResultStatus): { bg: string; color: string } { switch (status) { case 'NOT_STARTED': return { bg: 'color-mix(in srgb, #6b7280 12%, transparent)', // gray-500 color: '#6b7280', }; case 'IN_PROGRESS': return { bg: 'color-mix(in srgb, #3b82f6 12%, transparent)', // blue-500 color: '#3b82f6', }; case 'COMPLETED': return { bg: 'color-mix(in srgb, #10b981 12%, transparent)', // green-500 color: '#10b981', }; case 'AT_RISK': return { bg: 'color-mix(in srgb, #f59e0b 12%, transparent)', // amber-500 (orange/yellow) color: '#f59e0b', }; default: return { bg: 'color-mix(in srgb, #6b7280 12%, transparent)', color: '#6b7280', }; } } interface OKRCardProps { okr: OKR & { teamMember?: { user: { id: string; email: string; name: string | null } } }; teamId: string; } export function OKRCard({ okr, teamId }: OKRCardProps) { const progress = okr.progress || 0; const progressColor = progress >= 75 ? 'var(--success)' : progress >= 25 ? 'var(--accent)' : 'var(--destructive)'; return (
🎯 {okr.objective} {okr.teamMember && (
{/* eslint-disable-next-line @next/next/no-img-element */} {okr.teamMember.user.name {okr.teamMember.user.name || okr.teamMember.user.email}
)}
{okr.period}
{/* Progress Bar */}
Progression {progress}%
{/* Status */}
Statut: {OKR_STATUS_LABELS[okr.status]}
{/* Key Results List */} {okr.keyResults && okr.keyResults.length > 0 && (
Key Results ({okr.keyResults.length})
{okr.keyResults .sort((a, b) => a.order - b.order) .map((kr: KeyResult) => { const krProgress = kr.targetValue > 0 ? (kr.currentValue / kr.targetValue) * 100 : 0; const krProgressColor = krProgress >= 100 ? 'var(--success)' : krProgress >= 50 ? 'var(--accent)' : 'var(--destructive)'; return (
{kr.title} {KEY_RESULT_STATUS_LABELS[kr.status]}
{kr.currentValue} / {kr.targetValue} {kr.unit} {Math.round(krProgress)}%
); })}
)}
); }