import { Horoscope } from "@/components/BestiesHoroscopeSlider";
import { createSlice, createSelector } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";

const initialState: Horoscope[] = []

const compatibilitiesSlice = createSlice({
  name: "compatibilities",
  initialState,
  reducers: {
    update(state, action: PayloadAction<Horoscope>) {
      return [ ...initialState, ...state, action.payload ];
    },
  },
  extraReducers: (builder) => builder.addCase("reset", () => initialState),
});

export const { actions } = compatibilitiesSlice;
export const selectCompatibilities = createSelector(
  (state: { compatibilities: Horoscope[] }) => state.compatibilities,
  (compatibilities) => compatibilities
);
export default compatibilitiesSlice.reducer;
