And as far as the functionality, I think I'm going to start by setting up, removing them and then
clearing the cart because I'm just going to be faster than the Torgau as well as counting the totals.
And I'll start by closing all the open files.
And we're looking for a court context, of course.
And here I have the placeholders, but I would want to set up my dispatches.
So Remove Item was looking for the idea which we passed then and then clear court is just going to dispatch
the action by itself without any kind of parameters.
And of course, the same is going to be in removing them.
But we'll have to pass in as a payload our ID.
So we're looking for two actions that remove card item and then clear the card.
So we dispatch again, both of the actions are coming from the actions.
Jarius, I'm not going to do the whole spiel.
You already know what is happening.
So remove card item.
And then as far as the payload, I'm just setting up the idee and then in the clear cart, I'll do the
same thing.
Also this patch and then we pass in type.
And of course, the type is not clear filters, so.
Type is clear and then on the score card, so those are the actions that are coming from my actions.
So we save it and our next step, of course, is setting up our card reducer.
So make sure that we handle all those actions over there as well.
And it is simpler than you think.
So we navigate to a card reducer.
I have my first section of the card and I just keep on scrolling and once I'm done with this one, so
make sure that you don't place it inside.
It's kind of easy here because we have so many curly braces.
Now, of course, I would want to check for a remove item.
We're going to go with action type and if it is equal to remove card item, then I would want to filter
my card.
And if the ID doesn't match to whatever I'm passing in, then of course I will leave that item in the
card if it does match and our remove it from my card.
So set up temporary card, so time card array and then we just filter our state card and then we of
course are on filter and every item I'll name it as an item.
And also if the item ID, if the card ID doesn't match to whatever I'm passing in then I will return
it.
Why?
Well, because I know that that is not the item that I clicked on.
So say, if it doesn't match the action, that payload, since that's where the idea is, then I'm going
to return.
And as far as the return from the function is going to say that that state so I want to get all my state
properties and then card will be equal to my trump card.
So so I save and now we're sure should have the functionality where once we click, check it out.
Now of course we can remove the items and once I remove the second one, there it is.
Now we have your card is empty.
Why?
Because in the card page we handle that.
We say if the card is empty, then this is what we are turning.
And we should also be able to see once we refresh in the local storage that our cart powers are empty
here as well, because remember, we run that dispatch.
Correct.
So let's try it out one more time.
I'm going to go with the shelf.
It has this green color that's my default value.
And now, of course, I can see that item in the page in the local storage, but I still have this option
of clearing my item from the card.
And the clear card is even easier because the only thing we need to do is just return card as a empty.
All right.
So if action and that type is equal to clear court action, then we just return now to that state and
then court will be are empty.
All right.
We save it now.
Of course we refresh.
Now we can see our court item.
And I'm just going to add one more item.
So let's click on continue shopping.
Double check if this works and we navigate here.
We're going to add a few more items to the cart, and now if I want to clear and just clear the shopping
part and again, we have your card is empty because we handled that in the card page as we're done setting
up these two functionalities.
Now let's tackle the toggled card.