// ===== 결제 상태 타입 =====
export type PaymentStatus = 'pending' | 'completed' | 'failed' | 'cancelled' | 'refunded';

// ===== 결제 수단 라벨 =====
export const PAYMENT_METHOD_LABELS: Record<string, string> = {
  card: '카드',
  bank_transfer: '계좌이체',
  virtual_account: '가상계좌',
  cash: '현금',
};

// ===== API 응답 타입 =====
export interface PaymentApiData {
  id: number;
  tenant_id: number;
  subscription_id: number;
  amount: number | string;
  payment_method: string;
  status: string;
  transaction_id: string | null;
  paid_at: string | null;
  memo: string | null;
  created_at: string;
  updated_at: string;
  subscription?: {
    id: number;
    plan_id: number;
    started_at: string | null;
    ended_at: string | null;
    status: string;
    plan?: {
      id: number;
      name: string;
      code: string;
      price: number;
    };
  };
}

// ===== 결제 내역 타입 (Frontend) =====
export interface PaymentHistory {
  id: string;
  paymentDate: string;      // 결제일
  subscriptionName: string; // 구독명
  paymentMethod: string;    // 결제 수단
  subscriptionPeriod: {     // 구독 기간
    start: string;
    end: string;
  };
  amount: number;           // 금액
  status?: PaymentStatus;   // 결제 상태
  canViewInvoice: boolean;  // 거래명세서 조회 가능 여부
  createdAt: string;
  updatedAt: string;
}

// ===== 정렬 옵션 =====
export type SortOption = 'latest' | 'oldest' | 'amountHigh' | 'amountLow';

export const SORT_OPTIONS: { value: SortOption; label: string }[] = [
  { value: 'latest', label: '최신순' },
  { value: 'oldest', label: '오래된순' },
  { value: 'amountHigh', label: '금액 높은순' },
  { value: 'amountLow', label: '금액 낮은순' },
];