mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +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;
|
||||
};
|
||||
@@ -4,12 +4,21 @@ import t from 'store/types';
|
||||
export const fetchUsers = () => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.USERS_TABLE_LOADING,
|
||||
payload: { loading: true },
|
||||
});
|
||||
|
||||
ApiService.get(`users`)
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.USERS_LIST_SET,
|
||||
users: response.data.users,
|
||||
});
|
||||
dispatch({
|
||||
type: t.USERS_TABLE_LOADING,
|
||||
payload: { loading: false },
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -2,10 +2,9 @@ import { createReducer } from '@reduxjs/toolkit';
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
list: {
|
||||
results: [],
|
||||
},
|
||||
list: {},
|
||||
userById: {},
|
||||
loading: false,
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
@@ -16,6 +15,11 @@ export default createReducer(initialState, {
|
||||
[t.USER_DETAILS_SET]: (state, action) => {
|
||||
state.userById[action.user.id] = action.user;
|
||||
},
|
||||
|
||||
[t.USERS_TABLE_LOADING]: (state, action) => {
|
||||
const { loading } = action.payload;
|
||||
state.loading = !!loading;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
export default {
|
||||
USERS_LIST_SET: 'USERS_LIST_SET',
|
||||
USERS_TABLE_LOADING: 'USERS_TABLE_LOADING',
|
||||
USER_DETAILS_SET: 'USER_DETAILS_SET',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user