"use client";

import { useEffect, useState } from "react";
import { CurrencyCode, getUserCurrency, DEFAULT_CURRENCY } from "@/lib/geo";

export function useCurrency() {
  const [currency, setCurrency] = useState<CurrencyCode>(DEFAULT_CURRENCY);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    getUserCurrency()
      .then(setCurrency)
      .finally(() => setLoading(false));
  }, []);

  return { currency, loading };
}
