import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { StoryByUser } from '../../types/GetStoryByUser'; // adjust path if needed

interface StoryState {
  currentStory: StoryByUser | null;
}

const initialState: StoryState = {
  currentStory: null,
};

const currentStorySlice = createSlice({
  name: 'currentStory',
  initialState,
  reducers: {
    setCurrentStory(state, action: PayloadAction<StoryByUser>) {
      state.currentStory = action.payload;
    },
    clearCurrentStory(state) {
      state.currentStory = null;
    },
  },
});

export const { setCurrentStory, clearCurrentStory } = currentStorySlice.actions;
export default currentStorySlice.reducer;
