init
This commit is contained in:
24
worklenz-frontend/src/features/date/dateSlice.ts
Normal file
24
worklenz-frontend/src/features/date/dateSlice.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
type DateSliceState = {
|
||||
date: Dayjs;
|
||||
};
|
||||
|
||||
const initialState: DateSliceState = {
|
||||
date: dayjs(),
|
||||
};
|
||||
|
||||
const dateSlice = createSlice({
|
||||
name: 'dateReducer',
|
||||
initialState,
|
||||
reducers: {
|
||||
selectedDate: (state, action: PayloadAction<Dayjs>) => {
|
||||
state.date = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { selectedDate } = dateSlice.actions;
|
||||
export default dateSlice.reducer;
|
||||
Reference in New Issue
Block a user