// /redux/slices/webservice/gisLinesStatusSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { fetchGisLinesStatusThunk } from "../../thunks/webservice/fetchGisLinesStatusThunk";

const initialState = {
  data: [],
  status: "idle",
  error: null,
};

export const gisLinesStatusSlice = createSlice({
  name: "gisLinesStatusFromWebservice",
  initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(fetchGisLinesStatusThunk.pending, (state) => {
        state.status = "loading";
      })
      .addCase(fetchGisLinesStatusThunk.fulfilled, (state, action) => {
        state.status = "succeeded";
        state.data = action.payload;
      })
      .addCase(fetchGisLinesStatusThunk.rejected, (state, action) => {
        state.status = "failed";
        state.error = action.payload;
      });
  },
});

export default gisLinesStatusSlice.reducer;

export const selectGisLinesStatusFromWebservice = (state) => state.gisLinesStatusFromWebservice;
