All files / src/store ObjectHoverSlice.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                33x               13x 13x     512x 512x         33x    
import { SimulationObjectRead } from "@/api/apiStore.gen";
import { createSlice } from "@reduxjs/toolkit";
 
interface ObjectHoverState {
  simulationObject?: SimulationObjectRead;
  state: boolean;
}
 
const hoverSlice = createSlice({
  name: "objectHover",
  initialState: {
    simulationObject: undefined,
    state: false,
  } as ObjectHoverState,
  reducers: {
    setHoveredObject: (state, action) => {
      state.simulationObject = action.payload.simulationObject;
      state.state = true;
    },
    clearHoveredObject: (state) => {
      state.simulationObject = undefined;
      state.state = false;
    },
  },
});
 
export const { setHoveredObject, clearHoveredObject } = hoverSlice.actions;
export default hoverSlice.reducer;