34 lines
939 B
JavaScript
34 lines
939 B
JavaScript
// /redux/slices/database/pois/poiTypSlice.js
|
|
import { createSlice } from "@reduxjs/toolkit";
|
|
import { fetchPoiTypThunk } from "../../../thunks/database/pois/fetchPoiTypThunk";
|
|
|
|
const initialState = {
|
|
data: [],
|
|
status: "idle",
|
|
error: null,
|
|
};
|
|
|
|
const poiTypSlice = createSlice({
|
|
name: "poiTyp",
|
|
initialState,
|
|
reducers: {},
|
|
extraReducers: (builder) => {
|
|
builder
|
|
.addCase(fetchPoiTypThunk.pending, (state) => {
|
|
state.status = "loading";
|
|
})
|
|
.addCase(fetchPoiTypThunk.fulfilled, (state, action) => {
|
|
state.status = "succeeded";
|
|
state.data = action.payload;
|
|
})
|
|
.addCase(fetchPoiTypThunk.rejected, (state, action) => {
|
|
state.status = "failed";
|
|
state.error = action.payload;
|
|
});
|
|
},
|
|
});
|
|
|
|
export default poiTypSlice.reducer;
|
|
export const selectPoiTypData = (state) => state.poiTyp.data;
|
|
export const selectPoiTypStatus = (state) => state.poiTyp.status;
|