67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
export function formatStudioDate(value?: string | null) {
|
|
if (!value) {
|
|
return 'Just now';
|
|
}
|
|
|
|
const date = new Date(value);
|
|
if (Number.isNaN(date.getTime())) {
|
|
return 'Recently';
|
|
}
|
|
|
|
return date.toLocaleString(undefined, {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
year: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
});
|
|
}
|
|
|
|
export function formatPercent(value?: number | null) {
|
|
const safeValue = typeof value === 'number' ? value : 0;
|
|
return `${Math.round(safeValue * 100)}%`;
|
|
}
|
|
|
|
export function getRevealTone(resultType?: string | null) {
|
|
switch (resultType) {
|
|
case 'match':
|
|
return 'border-emerald-400/60 bg-emerald-500/10 text-emerald-200';
|
|
case 'possible_match':
|
|
return 'border-amber-400/60 bg-amber-500/10 text-amber-100';
|
|
case 'error':
|
|
return 'border-rose-400/60 bg-rose-500/10 text-rose-100';
|
|
default:
|
|
return 'border-slate-400/40 bg-slate-500/10 text-slate-100';
|
|
}
|
|
}
|
|
|
|
export function getRevealLabel(resultType?: string | null) {
|
|
switch (resultType) {
|
|
case 'match':
|
|
return 'Verified match';
|
|
case 'possible_match':
|
|
return 'Possible match';
|
|
case 'error':
|
|
return 'Review needed';
|
|
default:
|
|
return 'No strong match';
|
|
}
|
|
}
|
|
|
|
export function getWorkTypeLabel(workType?: string | null) {
|
|
if (!workType) {
|
|
return 'Unknown';
|
|
}
|
|
|
|
return `${workType.charAt(0).toUpperCase()}${workType.slice(1)}`;
|
|
}
|
|
|
|
export function getPersonName(person?: {
|
|
firstName?: string | null;
|
|
lastName?: string | null;
|
|
email?: string | null;
|
|
} | null) {
|
|
const fullName = [person?.firstName, person?.lastName].filter(Boolean).join(' ');
|
|
return fullName || person?.email || 'Unknown';
|
|
}
|