'use client';

import { Badge } from '@/components/ui/badge';
import { Icons } from '@/components/icons';

export function ApprovalStatusBadge({ status }: { status: string }) {
  const normalized = status.toLowerCase();
  const labelMap: Record<string, string> = {
    pending: 'รออนุมัติ',
    approved: 'อนุมัติแล้ว',
    rejected: 'ไม่อนุมัติ',
    returned: 'ตีกลับ',
    cancelled: 'ยกเลิก'
  };
  const variant =
    normalized === 'approved'
      ? 'default'
      : normalized === 'pending'
        ? 'secondary'
        : normalized === 'rejected'
          ? 'destructive'
          : 'outline';
  const Icon =
    normalized === 'approved'
      ? Icons.circleCheck
      : normalized === 'rejected'
        ? Icons.warning
        : normalized === 'returned'
          ? Icons.chevronLeft
          : Icons.clock;

  return (
    <Badge variant={variant} className='capitalize'>
      <Icon className='h-3 w-3' />
      {labelMap[normalized] ?? status.replaceAll('_', ' ')}
    </Badge>
  );
}
