|
@@ -1,5 +1,4 @@
|
|
|
import { createSlice } from "@reduxjs/toolkit"
|
|
|
-import {store} from "../App";
|
|
|
|
|
|
const frontEndReducerSlice = createSlice({ //promiseReducer
|
|
|
name: 'frontend', //префикс типа наподобие AUTH_
|
|
@@ -10,44 +9,31 @@ const frontEndReducerSlice = createSlice({ //promiseReducer
|
|
|
return state;
|
|
|
},
|
|
|
setOrdersPaging(state, action) {
|
|
|
- state.ordersPaging = { fromPage: action.page.fromPage, pageSize: action.page.pageSize };
|
|
|
+ state.ordersPaging = { fromPage: action.payload.page.fromPage, pageSize: action.payload.page.pageSize };
|
|
|
return state;
|
|
|
},
|
|
|
setOrdersSearch(state, action) {
|
|
|
- state.ordersSearchStr = action.searchStr;
|
|
|
+ state.ordersSearchStr = action.payload.searchStr;
|
|
|
return state;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
let frontEndReducer = frontEndReducerSlice.reducer;
|
|
|
-let actionSetSidebar = open =>
|
|
|
+let actionSetSidebar = open =>
|
|
|
async dispatch => {
|
|
|
dispatch(frontEndReducerSlice.actions.setSidebar({ open }))
|
|
|
}
|
|
|
|
|
|
-let actionSetOrdersPaging = frontEndReducerSlice.actions.setOrdersPaging;
|
|
|
-let actionSetOrderSearch = frontEndReducerSlice.actions.setOrdersSearch;
|
|
|
-export { frontEndReducer, actionSetSidebar, actionSetOrdersPaging, actionSetOrderSearch };
|
|
|
-
|
|
|
+let actionSetOrdersPaging = ({ fromPage, pageSize }) =>
|
|
|
+ async dispatch => {
|
|
|
+ dispatch(frontEndReducerSlice.actions.setOrdersPaging({ page: { fromPage, pageSize } }))
|
|
|
+ }
|
|
|
|
|
|
-/*
|
|
|
-export function frontEndReducer(state = { sidebar: {}, ordersPaging: { fromPage: 0, pageSize: 5 } }, action) { // диспетчер обработки login
|
|
|
- if (action) {
|
|
|
- if (action.type === 'SET_SIDE_BAR') {
|
|
|
- return { ...state, sidebar: { opened: action.open } };
|
|
|
- }
|
|
|
- if (action.type === 'SET_ORDERS_PAGING') {
|
|
|
- return { ...state, ordersPaging: { fromPage: action.page.fromPage, pageSize: action.page.pageSize } };
|
|
|
- }
|
|
|
- if (action.type === 'SET_ORDERS_SEARCH') {
|
|
|
- return { ...state, ordersSearchStr: action.searchStr };
|
|
|
- }
|
|
|
+let actionSetOrderSearch = ({ searchStr }) =>
|
|
|
+ async dispatch => {
|
|
|
+ dispatch(frontEndReducerSlice.actions.setOrdersPaging({ searchStr }))
|
|
|
}
|
|
|
- return state;
|
|
|
-}
|
|
|
-export const actionSetSidebar = open => ({ type: 'SET_SIDE_BAR', open });
|
|
|
|
|
|
-export const actionSetOrdersPaging = (page = { fromPage: 0, pageSize: 5 }) => ({ type: 'SET_ORDERS_PAGING', page });
|
|
|
-export const actionSetOrderSearch = searchStr => ({ type: 'SET_ORDERS_SEARCH', searchStr });
|
|
|
-*/
|
|
|
+
|
|
|
+export { frontEndReducer, actionSetSidebar, actionSetOrdersPaging, actionSetOrderSearch };
|