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


interface HealthState {
    windows: any;
    fast_with_sleep: any;
    long_fast: any;
    mode: string;
    selTab: number;
    refreshs: any; //刷新数据时间点
    title: string;
    eatArchived: any;
    activeArchived: any;
    eatArchivedTotal: number;
    activeArchivedTotal: number;
    showActionCircadian: boolean;
    isCompleted: boolean;
    schedules: any;
    footer: any;
    finish_setup: boolean;
    first_eat_id: any;
    eat_journal_tip: boolean;
    first_active_id: any;
    active_journal_tip: boolean;
}

const initialState: HealthState = {
    windows: null,
    fast_with_sleep: null,
    long_fast: null,
    mode: '',
    selTab: 0,
    refreshs: [],
    title: '',
    eatArchived: null,
    activeArchived: null,
    eatArchivedTotal: 0,
    activeArchivedTotal: 0,
    showActionCircadian: false,
    isCompleted: false,
    schedules: [],
    footer: null,
    finish_setup: false,

    //tip
    first_eat_id: '',
    first_active_id: '',
    eat_journal_tip: false,
    active_journal_tip: false,

    
}

const healthSlice = createSlice({
    name: 'health',
    initialState,
    reducers: {

        setWindows(state, action) {
            state.windows = action.payload
        },
        setFastWithSleep(state, action) {
            state.fast_with_sleep = action.payload
        },
        setLongFast(state, action) {
            state.long_fast = action.payload
        },
        setMode(state, action) {
            state.mode = action.payload
        },
        setTab(state, action) {
            state.selTab = action.payload
        },
        setRefreshs(state, action) {
            state.refreshs = action.payload
        },
        setTitle(state, action) {
            state.title = action.payload
        },
        setEatArchived(state, action) {
            state.eatArchived = action.payload
        },
        setActiveArchived(state, action) {
            state.activeArchived = action.payload
        },
        setEatArchivedTotal(state, action) {
            state.eatArchivedTotal = action.payload
        },
        setActiveArchivedTotal(state, action) {
            state.activeArchivedTotal = action.payload
        },
        setShowActionTip(state, action) {
            const { isShow, isCompleted } = action.payload
            state.showActionCircadian = isShow
            state.isCompleted = isCompleted
        },
        setSchedules(state, action) {
            debugger
            state.schedules = action.payload
        },
        setFooter(state, action) {
            state.footer = action.payload
        },
        setFinishSetup(state, action) {
            state.finish_setup = action.payload
        },

        setFirstEatId(state, action) {
            state.first_eat_id = action.payload
        },
        setFirstActiveId(state, action) {
            state.first_active_id = action.payload
        },
        setEatTip(state, action) {
            state.eat_journal_tip = action.payload
        },
        setActiveTip(state, action) {
            state.active_journal_tip = action.payload
        }

    }
})




export const { setWindows,
    setMode, setTab, setRefreshs,
    setTitle, setEatArchived, setActiveArchived,
    setEatArchivedTotal, setActiveArchivedTotal,
    setShowActionTip, setFastWithSleep, setLongFast,
    setSchedules, setFooter, setFinishSetup,
    setFirstEatId, setFirstActiveId,
    setEatTip, setActiveTip
} = healthSlice.actions;
export default healthSlice.reducer;