// store/Slice/AddPostSlice.ts
import { createSlice, PayloadAction } from '@reduxjs/toolkit';

export type PostType = "image" | "video" | "feed" | null;

interface AddPostState {
  isOpen: boolean;
  postType: PostType;
}

const initialState: AddPostState = {
  isOpen: false,
  postType: null,
};

const addPostSlice = createSlice({
  name: 'addPost',
  initialState,
  reducers: {
    openAddPostModal: (state, action: PayloadAction<PostType>) => {
      state.isOpen = true;
      state.postType = action.payload;
    },
    closeAddPostModal: (state) => {
      state.isOpen = false;
      state.postType = null;
    },
    setPostType: (state, action: PayloadAction<PostType>) => {
      state.postType = action.payload;
    },
  },
});

export const { openAddPostModal, closeAddPostModal, setPostType } = addPostSlice.actions;
export default addPostSlice.reducer;