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

const initialState: ApprovalParams = {
	isVisible: false,
	approvalType: "permit2",
	isApprovalGiven: false,
};

const approvalSlice = createSlice({
	name: "approval",
	initialState,
	reducers: {
		setApprovalData: (state, action) => {
			state.isVisible = action.payload.isVisible;
			state.approvalType = action.payload.approvalType;
			state.isApprovalGiven = action.payload.isApprovalGiven;
		},
	},
});

export interface ApprovalParams {
	isVisible: boolean;
	approvalType: "permit2" | "permit";
	isApprovalGiven: boolean;
}

export const { setApprovalData } = approvalSlice.actions;
export default approvalSlice.reducer;
