/**
 * 狀態徽章元件（統一灰色線框樣式）
 */

import { Badge } from "../ui/badge";
import type { PurchaseOrderStatus } from "../../types/purchase-order";
import { STATUS_CONFIG } from "../../constants/purchase-order";

interface StatusBadgeProps {
  status: PurchaseOrderStatus;
}

export function StatusBadge({ status }: StatusBadgeProps) {
  // 安全檢查：處理 undefined 或無效的 status
  if (!status || !STATUS_CONFIG[status]) {
    return (
      <Badge variant="outline">
        未知狀態
      </Badge>
    );
  }
  
  const config = STATUS_CONFIG[status];
  
  return (
    <Badge variant={config.variant}>
      {config.label}
    </Badge>
  );
}