import React from 'react';
import { Tag } from 'antd';
import type { LeadRequestStatus } from '../interface';

const LABELS: Record<LeadRequestStatus, string> = {
  pending: 'Pending',
  approved: 'Approved',
  rejected: 'Rejected',
  failed: 'Failed',
  stopped: 'Stopped',
};

// Pending is yellow, approved green, rejected red and stopped black with white text.
const StatusTag: React.FC<{ status: LeadRequestStatus }> = ({ status }) => {
  if (status === 'stopped') {
    return <Tag style={{ background: '#000', borderColor: '#000', color: '#fff' }}>{LABELS[status]}</Tag>;
  }
  const colors: Record<Exclude<LeadRequestStatus, 'stopped'>, string> = {
    pending: 'gold',
    approved: 'green',
    rejected: 'red',
    failed: 'volcano',
  };
  return <Tag color={colors[status]}>{LABELS[status] ?? status}</Tag>;
};

export default StatusTag;
