import React from 'react'; import { ActiveExperiment, ExperimentStatus } from '../types'; import { getExperimentStatusColor, getExperimentTypeColor, getExperimentIcon } from '../services/experiments'; interface ExperimentBadgeProps { experiments: ActiveExperiment[]; onClick?: (experimentId: string) => void; } const getStatusBadge = (status: ExperimentStatus) => { switch (status) { case 'active': return '🟢'; case 'planned': return '🟡'; case 'completed': return '⚪'; case 'paused': return '⏸️'; } }; export const ExperimentBadge: React.FC = ({ experiments, onClick }) => { if (!experiments || experiments.length === 0) return null; const activeExp = experiments.find(e => e.status === 'active'); const plannedExp = experiments.find(e => e.status === 'planned'); // Priority: active > planned > past const displayExp = activeExp || plannedExp || experiments[0]; const daysText = displayExp.days_remaining !== undefined ? displayExp.days_remaining > 0 ? `${displayExp.days_remaining}d left` : 'Ending soon' : ''; return (
{experiments.length > 1 && ( +{experiments.length} )}
); }; interface ExperimentStatusBadgeProps { status: ExperimentStatus; size?: 'sm' | 'md' | 'lg'; } export const ExperimentStatusBadge: React.FC = ({ status, size = 'md' }) => { const sizeClasses = { sm: 'px-1.5 py-0.5 text-[9px]', md: 'px-2 py-1 text-xs', lg: 'px-3 py-1.5 text-sm', }; const statusLabels = { active: 'Active', planned: 'Planned', completed: 'Completed', paused: 'Paused', }; return ( {getStatusBadge(status)} {statusLabels[status]} ); }; interface ExperimentTypeBadgeProps { type: string; size?: 'sm' | 'md' | 'lg'; } export const ExperimentTypeBadge: React.FC = ({ type, size = 'md' }) => { const sizeClasses = { sm: 'px-1.5 py-0.5 text-[9px]', md: 'px-2 py-1 text-xs', lg: 'px-3 py-1.5 text-sm', }; const typeLabels = { pricing: 'Pricing', advertising: 'Advertising', content: 'Content', promotion: 'Promotion', }; return ( {getExperimentIcon(type as any)} {typeLabels[type as keyof typeof typeLabels] || type} ); };