// /redux/slices/webService/gisSystemStaticSlice.js

import { createSlice } from "@reduxjs/toolkit";

import { fetchGisSystemStaticThunk } from "../../thunks/webservice/fetchGisSystemStaticThunk";

const slice = createSlice({
  name: "gisSystemStatic",
  initialState: {
    data: [],
    status: "idle",
    error: null,
  },
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(fetchGisSystemStaticThunk.pending, (state) => {
        state.status = "loading";
      })
      .addCase(fetchGisSystemStaticThunk.fulfilled, (state, action) => {
        state.status = "succeeded";
        state.data = action.payload;
      })
      .addCase(fetchGisSystemStaticThunk.rejected, (state, action) => {
        state.status = "failed";
        state.error = action.error.message;
      });
  },
});

export default slice.reducer;
export const selectGisSystemStatic = (state) => state.gisSystemStatic.data;
