Hi, I'm a Redux maintainer.
You can simplify this code considerably by using our official Redux Toolkit package. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once.
It also has a createAsyncThunk API that automatically dispatches pending/fulfilled/rejected actions based on a promise, and createSlice now offers "matcher" reducers that match against arbitrary actions (such as "any action whose type ends with /pending").
We specifically recommend using RTK as the default way to write Redux logic, and I just published a brand-new "Redux Essentials" core docs tutorial, which teaches beginners "how to use Redux, the right way", using our latest recommended tools and practices. I'd encourage you to check it out: