BlazorStart/Start/Client/Store/Features/CurrentContainer/CurrentContainerReducers.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2021-12-04 00:44:02 +00:00
using Fluxor;
using Start.Client.Store.State;
namespace Start.Client.Store.Features.CurrentContainer {
public static class CurrentContainerReducers {
[ReducerMethod(typeof(FetchCurrentContainerAction))]
public static RootState FetchCurrentContainer(RootState state) {
return state with {
CurrentContainerState = state.CurrentContainerState with {
Container = null,
IsLoadingCurrentContainer = true,
ErrorMessage = null
}
};
}
[ReducerMethod]
public static RootState ReceivedCurrentContainer(RootState state,
ReceivedCurrentContainerAction action) {
return state with {
CurrentContainerState = state.CurrentContainerState with {
Container = action.BookmarkContainer,
IsLoadingCurrentContainer = false,
ErrorMessage = null
}
};
}
[ReducerMethod]
public static RootState ErrorFetchingCurrentContainer(RootState state,
ErrorFetchingCurrentContainerAction action) {
return state with {
CurrentContainerState = state.CurrentContainerState with {
Container = null,
IsLoadingCurrentContainer = false,
ErrorMessage = action.ErrorMessage
}
};
}
}
}