// 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,
        viewCategory: null,
    },
    reducers: {
        setSession: (state, action) => {
            state.session = action.payload;
        },
        setReloadCalendar: (state, action) => {
            state.reloadCalendar = action.payload;
        },
        setViewCategory: (state, action) => {
            state.viewCategory = action.payload;
        },
    },
} );

export const { setSession } = dataStore.actions;
export const { setReloadCalendar } = dataStore.actions;
export const { setViewCategory } = dataStore.actions;

export default dataStore.reducer;
