Refactor to store
This commit is contained in:
parent
e3a2251898
commit
b619fe34f8
9 changed files with 177 additions and 70 deletions
38
store/dataStore.tsx
Normal file
38
store/dataStore.tsx
Normal file
|
@ -0,0 +1,38 @@
|
|||
// dataStore.js
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const dataStore = createSlice( {
|
||||
name: 'data',
|
||||
initialState: {
|
||||
session: {
|
||||
token: '',
|
||||
name: '',
|
||||
device: '',
|
||||
address: {
|
||||
id: 0,
|
||||
zipcode: '',
|
||||
houseNumber: '',
|
||||
street: '',
|
||||
city: '',
|
||||
},
|
||||
coordinates: {
|
||||
latitude: '',
|
||||
longitude: '',
|
||||
},
|
||||
},
|
||||
reloadCalendar: true,
|
||||
},
|
||||
reducers: {
|
||||
setSession: (state, action) => {
|
||||
state.session = action.payload;
|
||||
},
|
||||
setReloadCalendar: (state, action) => {
|
||||
state.reloadCalendar = action.payload;
|
||||
},
|
||||
},
|
||||
} );
|
||||
|
||||
export const { setSession } = dataStore.actions;
|
||||
export const { setReloadCalendar } = dataStore.actions;
|
||||
|
||||
export default dataStore.reducer;
|
8
store/store.tsx
Normal file
8
store/store.tsx
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import dataReducer from './dataStore';
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
data: dataReducer,
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue