mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
Fix : Preferences
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
// @flow
|
||||
import { createSelector } from 'reselect';
|
||||
import { getItemById } from 'store/selectors';
|
||||
|
||||
const currenciesItemsSelector = state => state.currencies.data;
|
||||
const currenciesItemsSelector = (state) => state.currencies.data;
|
||||
const currenciesCodePropSelector = (state, props) => props.currencyId;
|
||||
|
||||
export const getCurrenciesList = createSelector(
|
||||
currenciesItemsSelector,
|
||||
(currencies) => {
|
||||
return Object.values(currencies);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const getCurrencyById = (currencies: Object, id: Integer) => {
|
||||
return Object.values(currencies).find(c => c.id == id) || null;
|
||||
};
|
||||
export const getCurrencyByCode = createSelector(
|
||||
currenciesItemsSelector,
|
||||
currenciesCodePropSelector,
|
||||
(currencies, currencyCode) => {
|
||||
return getItemById(currencies, currencyCode);
|
||||
},
|
||||
);
|
||||
|
||||
export const getCurrencyByCode = (currencies: Object, currencyCode: String) => {
|
||||
return currencies[currencyCode] || null;
|
||||
};
|
||||
Reference in New Issue
Block a user