'use client'; import React, { type ReactNode } from 'react'; import { ArrowUpRight, ArrowDownRight, ChevronDown } from 'lucide-react'; import { cn } from '@/lib/utils'; export const CARD = 'bg-card crm-radius-section border border-border shadow-[0_1px_3px_rgba(16,24,40,0.06)] min-w-0'; export const PIPELINE = [ { key: 'pending', label: 'Pending', color: '#5BA4C7' }, { key: 'processing', label: 'Processing', color: '#3B82F6' }, { key: 'shipped', label: 'Shipped', color: '#7C3AED' }, { key: 'delivered', label: 'Delivered', color: '#01B574' }, ] as const; export const OVERVIEW = [ { key: 'delivered', label: 'Successful orders', color: '#01B574' }, { key: 'pending', label: 'Pending orders', color: '#5BA4C7' }, { key: 'cancelled', label: 'Cancelled', color: '#7C3AED' }, { key: 'shipped', label: 'In transit', color: '#3B82F6' }, ] as const; export const DONUT_COLORS: Record = { delivered: '#01B574', shipped: '#3B82F6', processing: '#5BA4C7', pending: '#7C3AED', }; export const PAYMENT_TAG: Record = { paid: 'border-[#01B574] text-[#01B574] bg-[#01B574]/8', unpaid: 'border-[#5BA4C7] text-[#5BA4C7] bg-[#5BA4C7]/10', refunded: 'border-primary text-primary bg-primary/8', }; export const PRODUCT_TONES = ['#5BA4C7', '#3B82F6', '#01B574', '#1B2559', '#7C3AED']; export function formatCompact(val: number) { if (val >= 1_000_000) return `₹${(val / 1_000_000).toFixed(2)}M`; if (val >= 1_000) return `₹${(val / 1_000).toFixed(val >= 10_000 ? 0 : 1)}K`; return `₹${val.toFixed(0)}`; } export function formatInr(val: number) { return new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR', maximumFractionDigits: 0, }).format(val); } export function initials(name: string) { const parts = name.trim().split(/\s+/).filter(Boolean); return ((parts[0]?.[0] ?? '') + (parts[1]?.[0] ?? '')).toUpperCase() || '•'; } export function samplePoints(items: T[], count: number) { if (items.length <= count) return items; const step = (items.length - 1) / (count - 1); return Array.from({ length: count }, (_, i) => items[Math.round(i * step)]); } export function deltaFromWeek(week: number, month: number) { if (!month) return 2.5; const actual = week / month; const expected = 7 / 30; return ((actual - expected) / expected) * 100; } export function CardTitle({ children }: { children: ReactNode }) { return (

{children}

); } export function PeriodPills({ value, onChange, }: { value: 'weekly' | 'monthly' | 'yearly'; onChange: (next: 'weekly' | 'monthly' | 'yearly') => void; }) { return (
{(['weekly', 'monthly', 'yearly'] as const).map((mode) => ( ))}
); } export function GhostSelect({ label }: { label: string }) { return ( {label} ); } export function DeltaPill({ value }: { value: number }) { const up = value >= 0; return ( {up ? : } {up ? '+' : ''} {Math.abs(value).toFixed(1)}% ); } export function StatusDonut({ slices, }: { slices: Array<{ label: string; value: number; color: string }>; }) { const total = slices.reduce((sum, slice) => sum + slice.value, 0) || 1; const cx = 90; const cy = 90; const r = 58; const stroke = 26; const circ = 2 * Math.PI * r; let offset = 0; return ( {slices.map((slice) => { const pct = slice.value / total; const dash = Math.max(pct * circ, 0); const gap = Math.max(circ - dash, 0); const currentOffset = offset; offset += dash; return ( ); })} ); }