import { createSlice , PayloadAction } from '@reduxjs/toolkit' ; import { selectedTypes } from '../../../types' ; interface selectedState { selectedData : selectedTypes [ ] ; } const initialState = { selectedData : [ ] , } ; export const selectedSlice = createSlice ( { name : 'selected' , initialState , reducers : { setSelected : ( state , action ) => { state . selectedData = action . payload ; } , addSelected : ( state , action ) => { state . selectedData . push ( action . payload ) ; } , } , } ) ; export const { setSelected , addSelected } = selectedSlice . actions ; const selectedReducer = selectedSlice . reducer ; export default selectedReducer ;