import { useQuery } from '@tanstack/react-query';
import { api } from '../lib/api';
import type { ApiResponse } from '../lib/api';

export interface PaymentGatewayInfo {
  name: string;
  label: string;
}

interface PaymentConfig {
  test_mode: boolean;
  appointment_fee_rials: number;
  gateways: PaymentGatewayInfo[];
}

export function usePaymentConfig() {
  const { data } = useQuery<ApiResponse<PaymentConfig>>({
    queryKey: ['payment-config'],
    queryFn: () => api.get('/api/v1/payment/config'),
    staleTime: 5 * 60 * 1000,
  });
  return {
    isTestMode: data?.data?.test_mode ?? false,
    gateways: data?.data?.gateways ?? [],
  };
}
