text: import { createStore } from "vuex";
  
  import actions from "./actions";
  import mutations from "./mutations";
  
  export default createStore({
    actions,
    mutations,
    state() {
      return {
        exchangeRates: {}
      };
    },
    getters: {
      sortedCurrencyCodes(state) {
        return Object.keys(state.exchangeRates).sort();
      },
  
      getConvertedCurrencyValue: state => (
        baseValue,
        baseCurrency,
        targetCurrency
      ) => {
        const plnValue = baseValue * state.exchangeRates[baseCurrency];
        return (plnValue / state.exchangeRates[targetCurrency]).toFixed(2);
      },
  
      getConvertedCurrenciesObj: (state, getters) => (
        baseValue,
        baseCurrency,
        targetCurrencies
      ) => {
        let convertedCurrenciesObj = {};
  
        for (const code of targetCurrencies.sort()) {
          convertedCurrenciesObj[code] = getters.getConvertedCurrencyValue(
            baseValue,
            baseCurrency,
            code
          );
        }
  
        return convertedCurrenciesObj;
      }
    }
  });
  