import {createSlice} from "@reduxjs/toolkit";
import {REQ_STATUS} from "@api/config";
import {buildReqReducer, reqGameList, reqPageModules} from "@features/api";

const reducerGameList=(state,action)=>{
    let json=action.payload;
    if (json&&json.code===0){

    }
}
const gameListStatus=(state,status,arg)=>{
    if (arg){
        const {mkey}=arg;
        state.fetchStatus[mkey]=status;
    }
}

export const GameList=createSlice({
    name: 'gamelist',
    initialState: {
        fetchStatus:{}
    },
    reducers: {
    },
    extraReducers: (builder) => {
        buildReqReducer(builder,reqGameList,reducerGameList,gameListStatus);
    },
})
export const {} = GameList.actions;
export const getGameListStatus=(mkey)=>(state)=>{
    let fetchStatus=state.gamelist.fetchStatus;
    let status=fetchStatus[mkey]==undefined?REQ_STATUS.NONE:fetchStatus[mkey];
    return status;
}

export default GameList.reducer;
