import { create } from 'zustand';

interface PaymentState {
  paymentIntentId: string | null;
  paymentStatus: 'PENDING' | 'PROCESSING' | 'REQUIRES_ACTION' | 'SUCCEEDED' | 'FAILED' | null;
  selectedCurrency: 'ETB' | 'DJF' | 'USD';
  
  setPaymentIntent: (id: string) => void;
  updateStatus: (status: 'PENDING' | 'PROCESSING' | 'REQUIRES_ACTION' | 'SUCCEEDED' | 'FAILED') => void;
  setCurrency: (currency: 'ETB' | 'DJF' | 'USD') => void;
  clearPayment: () => void;
}

export const usePaymentStore = create<PaymentState>((set) => ({
  paymentIntentId: null,
  paymentStatus: null,
  selectedCurrency: 'ETB',

  setPaymentIntent: (id) => set({ paymentIntentId: id }),
  updateStatus: (status) => set({ paymentStatus: status }),
  setCurrency: (currency) => set({ selectedCurrency: currency }),
  clearPayment: () => set({
    paymentIntentId: null,
    paymentStatus: null,
    selectedCurrency: 'ETB',
  }),
}));
