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


interface PermissionState {
    wxPubFollow?: boolean | false; //weapp
    pushAllow?: boolean | false;    //rn
    stepAllow?: boolean | false;
    albumAllow?: boolean | false;   //rn
    cameraAllow?: boolean | false;  //rn
    photoAllow?: boolean | false;   //weapp
    addToMini?: boolean | false;    //weapp     是否已经添加到我的小程序
}

const initialState: PermissionState = {
    wxPubFollow: false,
    pushAllow: false,
    stepAllow: false,
    albumAllow: false,
    cameraAllow: false,
    photoAllow: false,
    addToMini: false,
}

const permissionSlice = createSlice({
    name: 'permission',
    initialState,
    reducers: {
        setWXPubFollow(state, action) {
            state.wxPubFollow = true//action?true:false;
            // state.wxPubFollow = action.payload;
        },
        setPushAllow(state, action) {
            state.pushAllow = action.payload;
        },
        setStepAllow(state, action) {
            state.stepAllow = action.payload;
        },
        setAlbumAllow(state, action) {
            state.albumAllow = action.payload;
        },
        setCameraAllow(state, action) {
            state.cameraAllow = action.payload;
        },
        setPhotoAllow(state, action) {
            state.photoAllow = action.payload;
        },
        setAddToMini(state, action) {
            state.addToMini = action.payload;
        }
    }
});

export default permissionSlice.reducer;
export const { setWXPubFollow, setPushAllow, setStepAllow, setCameraAllow, setAlbumAllow, setPhotoAllow,setAddToMini} = permissionSlice.actions;