fix: move sleep-timer to separate reducer
This commit is contained in:
23
src/store/sleep-timer/index.ts
Normal file
23
src/store/sleep-timer/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
export interface State {
|
||||
date: number | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
date: null,
|
||||
};
|
||||
|
||||
const sleepTimer = createSlice({
|
||||
name: 'sleep-timer',
|
||||
initialState,
|
||||
reducers: {
|
||||
setTimerDate(state, action: PayloadAction<Date | null>) {
|
||||
state.date = action.payload?.getTime() || null;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const { setTimerDate } = sleepTimer.actions;
|
||||
|
||||
export default sleepTimer;
|
||||
Reference in New Issue
Block a user