Well let's head over back to court context and then after increased amount we have the decrease amount.
However I also failed to mention that not only we're looking for the idea we're gonna need the amount.
So we're going to say I.D. and the amount and the reason for that is because if impound is going to
be less than one or in fact equal to one then instead of just setting the amount equal to zero so decreasing
the item I'm in fact going to remove the item totally from the card.
That's the reason why we're going to get two things from our cart item.
And remember both of them we had access to the I.D. as well as the amount.
So instead of just passing in the 80 in this case we're also going to pass in the amount and the functionality
is going to be following where again we're getting both the I.D. and amount.
And now we want to check if the amount is equal to 1 then I would want to remove the item altogether.
How can we remove the item.
Well we already have the functionality correct.
So I can just say in here and say remove item and then pass the 80.
And also I would want to right away return.
So that would be the case if the amount is equal to 1.
There is no point for us to decrease even more if the amount is already 1.
There is no point for us to decrease to zero right away and just remove the item.
Then we also can have setup else if of course the amount is not equal to one.
What we would want to do then.
And in that case we're going to do exactly the same thing but instead of the last one we're going to
have a minus one.
So we're gonna decrease by one.
And you're looking at near like okay if that is the same functionality we could have set up some kind
of a helper function.
And that is true.
You could set up the helper function.
My issue with that is that that helper function essentially comes out longer than just copy and pasted
in this case.
So even though I'm not a fan of just copying pasting some kind of functionality because inevitably it
does lead to bugs.
In this case setting up the toggle functionality whether we are increasing or decreasing amount just
seemed too much of work.
So in this case I'm just gonna grab whatever functionality what he had here.
We're gonna set this up again instead of plus one.
That was our functionality for increasing the item.
I'm just gonna go with decreasing the item and then of course since we have the new card I also want
to use a set card is gonna be equal to a new card.
So let me make sure that I'm still within the LS largest right set card is equal to my new card.
So we're going to update our state value of work card.
Now who would want to test it out.
We're gonna have to head over to a card item and instead of increase amount we're going to import decrease
amount decrease mound and then where we have the angle down instead of console logging we're going to
run decrease amount increased amount of we're going to pass on to things we're going to pass in the
80 as well as the amount let's say it.
And now let's try it out.
So if we remove the item notice our amount goes down by 1 and then eventually once our amount is equal
to 1 then we just remove the item from the card altogether.