Newer
Older
import { ActionReducerMapBuilder } from '@reduxjs/toolkit';
import { getAllPlugins } from './plugins.thunks';
import { PluginsState } from './plugins.types';
export const getAllPluginsReducer = (builder: ActionReducerMapBuilder<PluginsState>): void => {
builder.addCase(getAllPlugins.pending, state => {
state.list.loading = 'pending';
});
builder.addCase(getAllPlugins.fulfilled, (state, action) => {
state.list.data = action.payload || [];
state.list.loading = 'succeeded';
});
builder.addCase(getAllPlugins.rejected, state => {
state.list.loading = 'failed';
// TODO to discuss manage state of failure
});
};