import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import type { MappedReel } from "@/services/reelsListService";

interface ReelQueueState {
  queue: MappedReel[];
  startId: string | null;
}

const initialState: ReelQueueState = { queue: [], startId: null };

const reelQueueSlice = createSlice({
  name: "reelQueue",
  initialState,
  reducers: {
    setReelQueue: (
      state,
      action: PayloadAction<{ queue: MappedReel[]; startId: string }>,
    ) => {
      state.queue = action.payload.queue;
      state.startId = action.payload.startId;
    },
    clearReelQueue: (state) => {
      state.queue = [];
      state.startId = null;
    },
  },
});

export const { setReelQueue, clearReelQueue } = reelQueueSlice.actions;
export default reelQueueSlice.reducer;
