import {createSlice} from "@reduxjs/toolkit";
import {buildReqReducer, reqGameActivity} from "@features/api";
import {REQ_STATUS} from "@api/config";
const reducerActivity=(state,action,arg)=>{
    let payload=action.payload;
    if (payload&&payload.code===200){
        let data=payload.data;
        if (data&&data.list!=null){
            let list=data.list;
            let arr=[];
            for (let i = 0; i < list.length; i++) {
                let item=list[i];
                // if (item&&item.state===1)arr.push(item);
                arr.push(item);
            }
            state.list=arr;
        }
    }
}
const activityStatus=(state,status,arg)=>{
    state.status=status;
}
const activitySlice = createSlice({
    name: "activity",
    initialState:{
        list:[],
        status:REQ_STATUS.NONE
    },
    reducers:{

    },
    extraReducers: (builder) => {
        buildReqReducer(builder,reqGameActivity,reducerActivity,activityStatus);
    }
})
export const {}=activitySlice.actions;
export const getActivityList=(state)=>{
    return state.activity.list;
}
export const getActivityStatus=(state)=>{
    return state.activity.status;
}
export default activitySlice.reducer;