From 735080f636bc1233b2264228d96b8bd47ff6bd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Mon, 26 Feb 2024 19:06:41 +0900 Subject: [PATCH] =?UTF-8?q?[redux-toolkit]=20crtfyhpSlice=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/comn/crtfyhp/crtfyhpSlice.ts | 48 +++++++++++++++++++ src/redux/rootReducer.ts | 2 + 2 files changed, 50 insertions(+) create mode 100644 src/redux/features/comn/crtfyhp/crtfyhpSlice.ts diff --git a/src/redux/features/comn/crtfyhp/crtfyhpSlice.ts b/src/redux/features/comn/crtfyhp/crtfyhpSlice.ts new file mode 100644 index 00000000..8fe43245 --- /dev/null +++ b/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; diff --git a/src/redux/rootReducer.ts b/src/redux/rootReducer.ts index 19467907..bb217d0a 100644 --- a/src/redux/rootReducer.ts +++ b/src/redux/rootReducer.ts @@ -20,12 +20,14 @@ import { controlGpLogReducer } from './features/control/gp/gpSlice'; import { controlGpHisReducer } from './features/control/gp/gpSlice'; import { controlGpDtlReducer } 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 combineReducer = combineReducers({ // common layoutState: layoutReducer, messageState: messageReducer, + crtfyhpState: crtfyhpReducer, // account authState: authReducer, findState: findReducer,