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

export interface ScanModalState {
    isVisible: boolean;
    scannedData?: string
}

const initialState: ScanModalState = {
    isVisible: false,
    scannedData: undefined
}

export const scanModalSlice = createSlice({
    name: 'scanModal',
    initialState,
    reducers: {
        openScanModal: (state) => {
            state.isVisible = true
        },
        closeScanModal: (state) => {
            state.isVisible = false
        },
        setScannedData: (state, action) => {
            state.scannedData = action.payload;
        }
    }
})

export const {openScanModal, closeScanModal, setScannedData} = scanModalSlice.actions;
export default scanModalSlice.reducer;