‫Next up, let's get our Thunks back.
‫So basically to get back the functionality
‫of converting currencies.
‫Now, in order to create Thunks in Redux Toolkit,
‫we can use the createAsyncThunk function
‫that Redux Toolkit provides us.
‫However, using this function is,
‫in my opinion, a lot of extra work,
‫when there is an easier solution,
‫which is to simply use the action creator function
‫that we already used before.
‫So we can basically just reuse that function right here.
‫And so let's do that.
‫Now, if you are really interested
‫in the createAsyncThunk function,
‫so basically in the Redux Toolkit way of doing things,
‫we will use it in a future project,
‫but for now, we will just do it in the easy way.
‫So let's come here and copy this function right here,
‫and paste it here.
‫And this will then actually automatically work
‫out of the box.
‫And so that's because Thunks
‫are automatically provided in Redux Toolkit,
‫so we don't have to install anything,
‫and this will simply already work.
‫So no setup required.
‫The only thing that we need to do
‫is to then no longer export this action creator
‫that we automatically get.
‫So remove that from here.
‫And so again, for deposit,
‫we now are going to use our own one.
‫Just make sure that it has exactly the same name,
‫and that the type,
‫so the action type has exactly this shape.
‫So again, that's the name of the slice,
‫and then slash, the name of the reducer.
‫So it's important that this follows this same convention.
‫And with that, Redux is then smart enough to figure out
‫that this is the action creator for that reducer.
‫All right?
‫And so all we have to do is to now also create a reducer
‫for this converting currency.
‫So let's copy that, paste that here,
‫then here, actually all we need is the state.
‫So this one doesn't depend on the action,
‫and pay loan also doesn't,
‫so it doesn't receive any payload.
‫So here, all that's gonna happen is state.loading
‫will become true,
‫and then in the end,
‫basically, after the deposit,
‫state.isloading will get back to false.
‫And this should already be it.
‫Now, for some reason, I keep getting this problem,
‫so it's somehow related to the React developer tools.
‫Maybe they don't play along nicely with Redux Toolkit.
‫So let's try a hard reload this time,
‫and okay, that actually works.
‫All right, so let's just test that
‫again to Euros,
‫and we have a problem.
‫But I remember the reason for that problem,
‫which is that here we changed our code.
‫So we want to get this back,
‫and let's even delete that one there.
‫And so let's try that again.
‫So 100 to Euro,
‫let's reload,
‫and probably getting that error again.
‫Well, not this time.
‫So
‫100
‫to Euro.
‫And there we go.
‫Nice.
‫So now, we also implemented a Thunk here
‫in this Redux Toolkit logic.
‫However, again, we did not really do it
‫in the React Toolkit way,
‫but this is actually completely fine as well.
‫So here we did then not use the automatic action creator
‫that has been created by createSlice but we used our own.
‫All right.
‫And again, later in the next project,
‫we will then also look at that other way
‫of doing the exact same thing.
‫And now, just to finish,
‫all we have to do is to also convert
‫our customer slice.
‫And so that will be the topic of our final video
‫in the section.