import {createSlice, PayloadAction} from "@reduxjs/toolkit";
import {startAssembly} from "../assembly/assemblySlice";
import assemblyApi from "../../api/assemblyApi";

export interface CancelAssemblyModalState {
    isVisible: boolean;
    message: string;
    assemblyId?: number;
}

const initialState: CancelAssemblyModalState = {
    isVisible: false,
    message: ""
}

export const cancelAssemblyModalSlice = createSlice({
    name: 'cancelAssemblyModal',
    initialState,
    reducers: {
        openCancelAssemblyModal: (state, action: PayloadAction<{ assemblyId: number, message: string }>) => {
            state.isVisible = true;
            state.assemblyId = action.payload.assemblyId;
            state.message = action.payload.message;
        },
        closeCancelAssemblyModal: (state) => {
            state.isVisible = false
        },
    }
})
export const {openCancelAssemblyModal, closeCancelAssemblyModal} = cancelAssemblyModalSlice.actions

export default cancelAssemblyModalSlice.reducer;