export const formatCurrency = (amount: number | string | undefined | null, market_type: string = 'FOR_MONEY'): string => { const prefix = market_type === 'FOR_MONEY' ? '$' : 'E'; const num = Number(amount) || 0; return `${prefix}${num.toFixed(2)}`; }; export const formatPlace = (place: number): string => { if (place <= 0) return '-'; const suffixes = ['th', 'st', 'nd', 'rd']; const v = place % 100; return place + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]); }; export const getStatusLabel = (status: string): string => { switch (status) { case 'pending': return 'Pending'; case 'scheduled': return 'Scheduled'; case 'auction_open': return 'Auction Open'; case 'auction_closed': return 'Auction Closed'; case 'inprogress': return 'In Progress'; case 'closed': return 'Closed'; case 'not_started': return 'Not Started'; case 'in_progress': return 'In Progress'; case 'active': return 'Active'; case 'sold': return 'Sold'; case 'unsold': return 'Unsold'; case 'eliminated': return 'Eliminated'; case 'advanced': return 'Advanced'; case 'won': return 'Won'; case 'placed': return 'Placed'; case 'outbid': return 'Outbid'; case 'cancelled': return 'Cancelled'; default: return status; } }; export const getItemStatusColor = (status: string): string => { switch (status) { case 'active': return '#3B82F6'; case 'sold': return '#10B981'; case 'unsold': return '#6B7280'; case 'eliminated': return '#EF4444'; case 'pending': return '#F59E0B'; default: return '#6B7280'; } }; /** Unwrap possibly double-wrapped image: { url: string } or { url: { url, secure_url, ... } } */ export const resolveItemImageUrl = (item_image?: { url: any }): string | undefined => { if (!item_image) return undefined; const raw = item_image.url; if (typeof raw === 'string') return raw; if (raw && typeof raw === 'object') return raw.secure_url || raw.url; return undefined; }; export const getBidStatusColor = (status: string): string => { switch (status) { case 'active': return '#3B82F6'; case 'won': return '#10B981'; case 'outbid': return '#EF4444'; case 'cancelled': return '#6B7280'; default: return '#6B7280'; } };