// /redux/slices/database/pois/poiTypesSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { fetchPoiTypThunk } from "../../../thunks/database/pois/fetchPoiTypThunk";

const poiTypesSlice = createSlice({
  name: "poiTypes",
  initialState: {
    data: [],
    status: "idle",
    error: null,
  },
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(fetchPoiTypThunk.pending, (state) => {
        state.status = "loading";
      })
      .addCase(fetchPoiTypThunk.fulfilled, (state, action) => {
        state.data = action.payload;
        state.status = "succeeded";
      })
      .addCase(fetchPoiTypThunk.rejected, (state, action) => {
        state.status = "failed";
        state.error = action.payload || "Unbekannter Fehler";
      });
  },
});

export default poiTypesSlice.reducer;
