WIP Feature / General & Users & Sidebar

This commit is contained in:
elforjani3
2020-04-20 16:52:25 +02:00
parent ff0a26a790
commit aaa370b9c3
21 changed files with 658 additions and 380 deletions

View File

@@ -2,5 +2,6 @@ export default {
ITEMS_CATEGORY_LIST_SET: 'ITEMS_CATEGORY_LIST_SET',
ITEMS_CATEGORY_DATA_TABLE: 'ITEMS_CATEGORY_DATA_TABLE',
CATEGORY_DELETE: 'CATEGORY_DELETE',
CLEAR_CATEGORY_FORM_ERRORS: 'CLEAR_CATEGORY_FORM_ERRORS'
CLEAR_CATEGORY_FORM_ERRORS: 'CLEAR_CATEGORY_FORM_ERRORS',
CATEGORY_COUNTER:'CATEGORY_COUNTER'
};

View File

@@ -0,0 +1,25 @@
import ApiService from 'services/ApiService';
import t from 'store/types';
export const submitOptions = ({ form }) => {
return (dispatch) => {
return ApiService.post('options', form);
};
};
export const FetchOptions = ({ form }) => {
return (dispatch) =>
new Promise((resolve, reject) => {
ApiService.get('options')
.then((response) => {
dispatch({
type: t.SETTING_SET,
options: response.data.options,
});
resolve(response);
})
.catch((error) => {
reject(error);
});
});
};

View File

@@ -1,16 +1,16 @@
import { createReducer } from '@reduxjs/toolkit';
import t from 'store/types';
import { optionsArrayToMap } from 'utils';
const initialState = {
data: {
organization: {
name: 'Bigcapital, Limited Liabilities',
},
organization: {},
},
};
export default createReducer(initialState, {
['asdfas']: (state, action) => {
[t.SETTING_SET]: (state, action) => {
const { options } = action;
state.data.organization = optionsArrayToMap(options);
},
});
});

View File

@@ -1,5 +1,5 @@
export default {
};
SETTING_LIST_SET: 'SETTING_LIST_SET',
CLEAR_OPTIONS_FORM_ERRORS: 'CLEAR_OPTIONS_FORM_ERRORS',
SETTING_SET: 'SETTING_SET',
};

View File

@@ -1,8 +1,10 @@
import { createReducer } from "@reduxjs/toolkit";
import { createReducer } from '@reduxjs/toolkit';
import t from 'store/types';
const initialState = {
list: {},
list: {
results: [],
},
userById: {},
};
@@ -14,13 +16,13 @@ export default createReducer(initialState, {
[t.USER_DETAILS_SET]: (state, action) => {
state.userById[action.user.id] = action.user;
},
})
});
/**
* Retrieve the user details of the given user id,
* @param {Object} state
* @param {Numeric} id
* @param {Object} state
* @param {Numeric} id
*/
export const getUserDetails = (state, id) => {
return state.users.userById[id];
};
};