// modalReducer.ts

import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface ModalState {
  isOpen: boolean;
  title: string;
  content: string;
}

const initialState: ModalState = {
  isOpen: false,
  title: '',
  content: '',
};

const modalSlice = createSlice({
  name: 'modal',
  initialState,
  reducers: {
    showModal: (state, action: PayloadAction<{ title: string; content: string }>) => {
      state.isOpen = true;
      state.title = action.payload.title;
      state.content = action.payload.content;
    },
    hideModal: (state) => {
      state.isOpen = false;
      state.title = '';
      state.content = '';
    },
  },
});

export const { showModal, hideModal } = modalSlice.actions;
export default modalSlice.reducer;