import { useState, useEffect } from 'react'; import { apiService } from '@/services/api'; import type { IApiCurrency } from '../types'; import type { TMerchant } from '@/config/api'; export function useCurrencies(merchant?: TMerchant) { const [currencies, setCurrencies] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchCurrencies = async () => { try { setLoading(true); setError(null); const data = await apiService.getCurrencies(merchant); setCurrencies(data); } catch (err) { setError(err instanceof Error ? err : new Error('Failed to fetch currencies')); } finally { setLoading(false); } }; fetchCurrencies(); }, [merchant]); return { currencies, loading, error }; }