refactoring
This commit is contained in:
33
redux/slices/database/pois/poiIconsDataSlice.js
Normal file
33
redux/slices/database/pois/poiIconsDataSlice.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// /redux/slices/database/poiIconsDataSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchPoiIconsDataThunk } from "../../../thunks/database/pois/fetchPoiIconsDataThunk";
|
||||
|
||||
const initialState = {
|
||||
data: [],
|
||||
status: "idle",
|
||||
error: null,
|
||||
};
|
||||
|
||||
const poiIconsDataSlice = createSlice({
|
||||
name: "poiIconsData",
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchPoiIconsDataThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchPoiIconsDataThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchPoiIconsDataThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.payload;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default poiIconsDataSlice.reducer;
|
||||
export const selectPoiIconsData = (state) => state.poiIconsData.data;
|
||||
export const selectPoiIconsStatus = (state) => state.poiIconsData.status;
|
||||
Reference in New Issue
Block a user