import { useLocalStorage } from "./useLocalStorage";

import {
    COUNTRIES_USING_EUR_GBP,
    CURRENCY_LABELS,
    getChangedCurrencies,
    UsdToEurGbpProps
} from "../../constants/currency_pricing";

export const useCurrencyPricing = (props: UsdToEurGbpProps) => {
    const { pricesUSD } = props;
    const { pageValue } = useLocalStorage({ key: 'utm_country', defaultValue: '' });

    //@ts-ignore
    const currency = COUNTRIES_USING_EUR_GBP[pageValue] || 'USD';
    //@ts-ignore
    const currencyLabel = CURRENCY_LABELS[currency] || '$';
    const changedUSD = getChangedCurrencies(props);

    //@ts-ignore
    const changedPrices = changedUSD[currency];

    return {
        basicPrices: pricesUSD,
        changedPrices,
        currencyLabel,
        currency
    }
}