mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Config With Seacrh
This commit is contained in:
@@ -2,7 +2,7 @@ import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const submitItemCategory = ({ form }) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post('item_categories', { ...form });
|
||||
};
|
||||
};
|
||||
@@ -11,53 +11,53 @@ export const fetchItemCategories = () => {
|
||||
return (dispatch, getState) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.get('item_categories')
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEMS_CATEGORY_LIST_SET,
|
||||
categories: response.data.categories
|
||||
categories: response.data.categories,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const editItemCategory = (id, form) => {
|
||||
return dispatch =>
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.post(`item_categories/${id}`, form)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS });
|
||||
if (errors) {
|
||||
dispatch({ type: t.CATEGORY_FORM_ERRORS, errors });
|
||||
dispatch({ type: t.CLEAR_CATEGORY_FORM_ERRORS, errors });
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteItemCategory = id => {
|
||||
return dispatch =>
|
||||
export const deleteItemCategory = (id) => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
ApiService.delete(`item_categories/${id}`)
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.CATEGORY_DELETE,
|
||||
id
|
||||
id,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import financialStatements from './financialStatement/financialStatements.reduce
|
||||
import itemCategories from './itemCategories/itemsCategory.reducer';
|
||||
import settings from './settings/settings.reducer';
|
||||
import manualJournals from './manualJournals/manualJournals.reducers';
|
||||
import search from './search/search.reducer';
|
||||
|
||||
export default combineReducers({
|
||||
authentication,
|
||||
@@ -30,4 +31,5 @@ export default combineReducers({
|
||||
items,
|
||||
itemCategories,
|
||||
settings,
|
||||
search,
|
||||
});
|
||||
|
||||
8
client/src/store/search/search.actions.js
Normal file
8
client/src/store/search/search.actions.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export function generalSearch(name, result) {
|
||||
return {
|
||||
type: t.SEARCH_SUCCESS,
|
||||
result,
|
||||
};
|
||||
}
|
||||
33
client/src/store/search/search.reducer.js
Normal file
33
client/src/store/search/search.reducer.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import t from 'store/types';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
|
||||
const initialState = {
|
||||
searches: {},
|
||||
searchTitle: 'Title',
|
||||
isOpen: false,
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
[t.SEARCH_SUCCESS]: (state, action) => {
|
||||
const _result = {};
|
||||
|
||||
action.searches.forEach((search) => {
|
||||
_result[search.id] = search;
|
||||
});
|
||||
|
||||
state.searches = {
|
||||
...state.searches,
|
||||
..._result,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// return state = action.result;
|
||||
// if (typeof state === 'undefined') {
|
||||
// return initialState;
|
||||
// }
|
||||
|
||||
// state.search[action.name] = {
|
||||
// isOpen: true,
|
||||
// payload: action.payload || {},
|
||||
// };
|
||||
5
client/src/store/search/search.type.js
Normal file
5
client/src/store/search/search.type.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
SEARCH_SUCCESS: 'SEARCH_SUCCESS',
|
||||
SEARCH_FAILURE: 'SEARCH_FAILURE',
|
||||
SEARCH_REQUEST: 'SEARCH_REQUEST',
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import authentication from './authentication/authentication.types';
|
||||
import accounts from './accounts/accounts.types';
|
||||
import accounting from './manualJournals/manualJournals.types'
|
||||
import accounting from './manualJournals/manualJournals.types';
|
||||
import currencies from './currencies/currencies.types';
|
||||
import customFields from './customFields/customFields.types';
|
||||
import customViews from './customViews/customViews.types';
|
||||
@@ -13,7 +13,7 @@ import users from './users/users.types';
|
||||
import financialStatements from './financialStatement/financialStatements.types';
|
||||
import itemCategories from './itemCategories/itemsCategory.type';
|
||||
import settings from './settings/settings.type';
|
||||
|
||||
import search from './search/search.type';
|
||||
export default {
|
||||
...authentication,
|
||||
...accounts,
|
||||
@@ -30,4 +30,5 @@ export default {
|
||||
...itemCategories,
|
||||
...settings,
|
||||
...accounting,
|
||||
...search,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user