import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import loadingSlice from "../loading/loadingSlice";
import { Area } from "../../services/product/type";

const areaSlice = createSlice({
  name: "areas",
  initialState: {
    areas: [] as Area[],
  },
  reducers: {
    setAreas: (state, action: PayloadAction<Area[]>) => {
      console.log("Setting areas state to: ", action.payload);
      return {
        ...state,
        areas: action.payload,
      };
    },
  },
});

export const { setAreas } = areaSlice.actions;
export default areaSlice.reducer;
