Browse Source

src/redux(action,reducer) 폴더 제거

master
김장현 8 months ago
parent
commit
adcfeddea5
  1. 4
      src/@core/layouts/components/layout-wrapper/index.js
  2. 26
      src/redux/actions/navbar/Index.js
  3. 45
      src/redux/reducers/navbar/index.js
  4. 3
      src/redux/reducers/rootReducer.ts

4
src/@core/layouts/components/layout-wrapper/index.js

@ -23,7 +23,7 @@ const LayoutWrapper = props => {
// ** Store Vars
const dispatch = useDispatch();
const store = useSelector(state => state);
const navbarStore = store.navbar;
// const navbarStore = store.navbar;
const contentWidth = store.layoutState.contentWidth;
//** Vars
@ -64,7 +64,7 @@ const LayoutWrapper = props => {
<div
className={classnames('app-content content overflow-hidden', {
[wrapperClass]: wrapperClass,
'show-overlay': navbarStore.query.length
'show-overlay': ''
})}
>
<div className='content-overlay'></div>

26
src/redux/actions/navbar/Index.js

@ -1,26 +0,0 @@
import axios from 'axios'
// ** Get Bookmarks Array from @fakeDB
export const getBookmarks = () => {
return dispatch => {
return axios.get('/api/bookmarks/data').then(response => {
dispatch({
type: 'GET_BOOKMARKS',
data: response.data.suggestions,
bookmarks: response.data.bookmarks
})
})
}
}
// ** Update & Get Updated Bookmarks Array
export const updateBookmarked = id => {
return dispatch => {
return axios.post('/api/bookmarks/update', { id }).then(() => {
dispatch({ type: 'UPDATE_BOOKMARKED', id })
})
}
}
// ** Handle Bookmarks & Main Search Queries
export const handleSearchQuery = val => dispatch => dispatch({ type: 'HANDLE_SEARCH_QUERY', val })

45
src/redux/reducers/navbar/index.js

@ -1,45 +0,0 @@
// ** Initial State
const initialState = {
suggestions: [],
bookmarks: [],
query: '',
headerMenu: 'basis'
};
const navbarReducer = (state = initialState, action) => {
switch (action.type) {
case 'HANDLE_SEARCH_QUERY':
return { ...state, query: action.val };
case 'GET_BOOKMARKS':
return {
...state,
suggestions: action.data,
bookmarks: action.bookmarks
};
case 'UPDATE_BOOKMARKED':
let objectToUpdate;
// ** find & update object
state.suggestions.find(item => {
if (item.id === action.id) {
item.isBookmarked = !item.isBookmarked;
objectToUpdate = item;
}
});
case 'CLICK_HEADER_MENU':
// ** Get index to add or remove bookmark from array
const bookmarkIndex = state.bookmarks.findIndex(x => x.id === action.id);
if (bookmarkIndex === -1) {
state.bookmarks.push(objectToUpdate);
} else {
state.bookmarks.splice(bookmarkIndex, 1);
}
return { ...state };
default:
return state;
}
};
export default navbarReducer;

3
src/redux/reducers/rootReducer.ts

@ -3,8 +3,6 @@ import { combineReducers } from 'redux';
import { all, fork } from 'redux-saga/effects';
// ** Reducers, Sagas Imports
import navbar from './navbar';
import { findSaga, findReducer } from '../../modules/account/find';
import {
authSaga,
@ -59,7 +57,6 @@ export function* saga() {
}
const rootReducer = combineReducers({
navbar,
controlMapReducer,
mainDashState: mainDahReducer,
messageState: messageReducer,

Loading…
Cancel
Save