mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat: register pages routes guards.
feat: retrieve all organizations details to authenticated user. feat: redux organization reducers and actions.
This commit is contained in:
25
client/src/store/organizations/organizations.reducers.js
Normal file
25
client/src/store/organizations/organizations.reducers.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
data: {},
|
||||
byOrganizationId: {},
|
||||
};
|
||||
|
||||
const reducer = createReducer(initialState, {
|
||||
|
||||
[t.ORGANIZATIONS_LIST_SET]: (state, action) => {
|
||||
const { organizations } = action.payload;
|
||||
const _data = {};
|
||||
const _dataByOrganizationId = {};
|
||||
|
||||
organizations.forEach((organization) => {
|
||||
_data[organization.id] = organization;
|
||||
_dataByOrganizationId[organization.organization_id] = organization.id;
|
||||
});
|
||||
state.data = _data;
|
||||
state.byOrganizationId = _dataByOrganizationId;
|
||||
},
|
||||
})
|
||||
|
||||
export default reducer;
|
||||
Reference in New Issue
Block a user