/**
 *
 * @description Theme system state handler
 * * source : https://redux-toolkit.js.org/api/createslice
 */

import { createSlice , PayloadAction } from "@reduxjs/toolkit";

type IinitialState = {
    value : {
        themeType : 'light'|'dark',
    }
}

const initialState = {
    value : {
        themeType : 'light'
    }
} as IinitialState

export const themeType = createSlice({
    name: "theme",
    initialState,
    reducers : {
        setThemeType : (state , action : PayloadAction<'light'|'dark'>) => {
            localStorage.setItem('theme' , action.payload)
            return {
                value : {
                    themeType : action.payload
                }
            }
        }
    }
})

export const { setThemeType } = themeType.actions;
export default themeType.reducer;