Browse Source

[redux-toolkit] crtfyhpSlice 생성

master
junh_eee(이준희) 7 months ago
parent
commit
735080f636
  1. 48
      src/redux/features/comn/crtfyhp/crtfyhpSlice.ts
  2. 2
      src/redux/rootReducer.ts

48
src/redux/features/comn/crtfyhp/crtfyhpSlice.ts

@ -0,0 +1,48 @@
import { createSlice } from '@reduxjs/toolkit';
const initCrtfyhp = {
isRunning: false,
isCrtfyhp: false,
sendCount: 0,
counter: {
min: '03',
sec: '00'
}
};
const crtfyhpSlice = createSlice({
name: 'crtfyhpSlice',
initialState: initCrtfyhp,
reducers: {
isStartTimer: (state, action) => {
state.isRunning = action.payload as boolean;
},
isSendCrtfyhp: (state, action) => {
state.isCrtfyhp = action.payload as boolean;
},
setSendCount: (state, action) => {
state.sendCount = state.sendCount + 1;
},
setCounter: (state, action) => {
state.counter = action.payload as {
min: string;
sec: string;
};
},
resetTimer: (state, action) => {
state.isRunning = false;
state.isCrtfyhp = false;
state.counter = { min: '03', sec: '00' };
}
}
});
export const {
isStartTimer,
isSendCrtfyhp,
setSendCount,
setCounter,
resetTimer
} = crtfyhpSlice.actions;
export const crtfyhpReducer = crtfyhpSlice.reducer;

2
src/redux/rootReducer.ts

@ -20,12 +20,14 @@ import { controlGpLogReducer } from './features/control/gp/gpSlice';
import { controlGpHisReducer } from './features/control/gp/gpSlice'; import { controlGpHisReducer } from './features/control/gp/gpSlice';
import { controlGpDtlReducer } from './features/control/gp/gpSlice'; import { controlGpDtlReducer } from './features/control/gp/gpSlice';
import { controlGpCountReducer } from './features/control/gp/gpSlice'; import { controlGpCountReducer } from './features/control/gp/gpSlice';
import { crtfyhpReducer } from './features/comn/crtfyhp/crtfyhpSlice';
const rootReducer = (state: any, action: any) => { const rootReducer = (state: any, action: any) => {
const combineReducer = combineReducers({ const combineReducer = combineReducers({
// common // common
layoutState: layoutReducer, layoutState: layoutReducer,
messageState: messageReducer, messageState: messageReducer,
crtfyhpState: crtfyhpReducer,
// account // account
authState: authReducer, authState: authReducer,
findState: findReducer, findState: findReducer,

Loading…
Cancel
Save