For clearing the cart,
that's simple,
we are dispatching this add order
action in the end.
Now of course, this action is currently handled in our orders reducer but we're not limited to handing
it there,
it's important to understand that every Redux action you dispatch reaches every reducer because how would
the action know to which reducer it belongs?
As I explained earlier, it's the reducer that simply tells which actions it cares about and which actions
should not be handled.
So the add order action can also be handled in the cart reducer,
alternatively you could dispatch a separate clear cart action if you wanted to but if you don't need
that anywhere else, there's not really a strong reason to create a separate action. So I will just handle
the already existing add order action here in my cart reducer and there after handling the remove case,
I'll handle the add order action and for that, you just need to make sure you import this add order action
from the actions folder and there, from the orders file and now in that case down there, we need to clear
the cart and that's super simple,
we just need to return our initial state again because initial state in here is of course this object
with an empty cart and a total amount of zero.
So I just want to reset this,
hence this is what I return here.
The result of this is that if I add items to a cart here, let's say two red shirts and one blue carpet
and I click order
now, the cart is cleared and now we see the order here still,
that's our order.
So that's how we can clear the cart,
let's now make sure the order looks nicer.