// /redux/slices/database/polylines/updatePolylineCoordinatesSlice.js
// Du brauchst diesen Slice nur, wenn du Ladezustand oder Fehler anzeigen möchtest (z. B. Ladeindikator).
import { createSlice } from "@reduxjs/toolkit";
import { updatePolylineCoordinatesThunk } from "../../../thunks/database/polylines/updatePolylineCoordinatesThunk";

const slice = createSlice({
  name: "updatePolylineCoordinates",
  initialState: {
    status: "idle",
    error: null,
  },
  reducers: {
    resetUpdateStatus: (state) => {
      state.status = "idle";
      state.error = null;
    },
  },
  extraReducers: (builder) => {
    builder
      .addCase(updatePolylineCoordinatesThunk.pending, (state) => {
        state.status = "loading";
      })
      .addCase(updatePolylineCoordinatesThunk.fulfilled, (state) => {
        state.status = "succeeded";
      })
      .addCase(updatePolylineCoordinatesThunk.rejected, (state, action) => {
        state.status = "failed";
        state.error = action.error.message;
      });
  },
});

export const { resetUpdateStatus } = slice.actions;
export default slice.reducer;
