import useSWR from 'swr';
import { getTariffs } from '@/api/tariff';
import type { GetTariffsResponse, Tariff } from '@frontend/kitui';

export const useTariffs = () => {
  const { data, error, isLoading } = useSWR<Tariff[]>('tariffs', async () => {
    const [response] = await getTariffs();
    if (response?.tariffs) {
      return response.tariffs;
    }
    return [];
  });

  return {
    data,
    error,
    isLoading
  };
}; 