/*
 * File: dicomSlice.ts
 * Description: Redux slice for DICOM image state management
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

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

interface DICOMState {
  images: string[];
  currentIndex: number;
  loading: boolean;
}

const initialState: DICOMState = {
  images: [],
  currentIndex: 0,
  loading: false,
};

/**
 * dicomSlice for managing DICOM images and navigation
 */
const dicomSlice = createSlice({
  name: 'dicom',
  initialState,
  reducers: {
    setImages(state, action: PayloadAction<string[]>) {
      state.images = action.payload;
      state.currentIndex = 0;
    },
    setCurrentIndex(state, action: PayloadAction<number>) {
      state.currentIndex = action.payload;
    },
    setLoading(state, action: PayloadAction<boolean>) {
      state.loading = action.payload;
    },
    clearImages(state) {
      state.images = [];
      state.currentIndex = 0;
    },
  },
});

export const {
  setImages,
  setCurrentIndex,
  setLoading,
  clearImages,
} = dicomSlice.actions;

export default dicomSlice.reducer;

/*
 * End of File: dicomSlice.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 