import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import Taro from '@tarojs/taro';
interface TimeState {
    scenario: string | null;
    status: string | null;
    fast: any | null;
    sleep: any | null;
    last_real_check_time: number | null;
}

const initialState: TimeState = {
    fast: null,
    sleep: null,
    scenario: '',
    status: '',
    last_real_check_time:null
}

const timeSlice = createSlice({
    name: 'time',
    initialState,
    reducers: {
        updateScenario(state, action: PayloadAction<any>) {
            const { fast, sleep, status, scenario,last_real_check_time } = action.payload;
            state.fast = fast
            state.sleep = sleep
            state.status = status
            state.scenario = scenario
            state.last_real_check_time = last_real_check_time
        },
        fastStartSuccess(state, action: PayloadAction<any>) {
            const { fast, sleep, status, scenario,last_real_check_time } = action.payload;
            state.fast = fast
            state.sleep = sleep
            state.status = status
            state.scenario = scenario
            state.last_real_check_time = last_real_check_time
        },
        fastEndSuccess(state, action: PayloadAction<any>) {
            const { fast, sleep, status, scenario,last_real_check_time } = action.payload;
            state.fast = fast
            state.sleep = sleep
            state.status = status
            state.scenario = scenario
            state.last_real_check_time = last_real_check_time
        },
        sleepStartSuccess(state, action: PayloadAction<any>) {
            const { fast, sleep, status, scenario,last_real_check_time } = action.payload;
            state.fast = fast
            state.sleep = sleep
            state.status = status
            state.scenario = scenario
            state.last_real_check_time = last_real_check_time
        },
        sleepEndSuccess(state, action: PayloadAction<any>) {
            const { fast, sleep, status, scenario,last_real_check_time } = action.payload;
            state.fast = fast
            state.sleep = sleep
            state.status = status
            state.scenario = scenario
            state.last_real_check_time = last_real_check_time
        },
    },
});

export const { fastStartSuccess, fastEndSuccess, sleepStartSuccess, sleepEndSuccess, updateScenario } = timeSlice.actions;
export default timeSlice.reducer;
