import type { Currency } from "../lib/formatters";
import { useSetting } from "./useSettings";

const VALID_CURRENCIES: Currency[] = ["USD", "EUR", "GBP", "JPY", "CAD", "AUD"];

export function useCurrency(): Currency {
	const { data } = useSetting("currency");
	if (data && VALID_CURRENCIES.includes(data as Currency)) {
		return data as Currency;
	}
	return "USD";
}
