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: {
        setWXFollow(state, action) {
            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 { setWXFollow, setPushAllow, setStepAllow, setCameraAllow, setAlbumAllow, setPhotoAllow,setAddToMini} = permissionSlice.actions;