mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
WIP optimize connect with redux state in preferences pages.
This commit is contained in:
@@ -2,9 +2,7 @@ import { createReducer } from '@reduxjs/toolkit';
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
preferences: {
|
||||
currencies: [],
|
||||
},
|
||||
data: {},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
@@ -14,8 +12,8 @@ export default createReducer(initialState, {
|
||||
action.currencies.forEach((currency) => {
|
||||
_currencies[currency.currency_code] = currency;
|
||||
});
|
||||
state.preferences.currencies = {
|
||||
...state.preferences.currencies,
|
||||
state.data = {
|
||||
...state.data,
|
||||
..._currencies,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
export const getCurrencyById = (items, id) => {
|
||||
return items[id] || null;
|
||||
// @flow
|
||||
|
||||
export const getCurrencyById = (currencies: Object, id: Integer) => {
|
||||
return Object.values(currencies).find(c => c.id == id) || null;
|
||||
};
|
||||
|
||||
export const getCurrencyByCode = (currencies: Object, currencyCode: String) => {
|
||||
return currencies[currencyCode] || null;
|
||||
};
|
||||
Reference in New Issue
Block a user