And while we're still on topic in the current context, I would want to set up my function, add to
cart now remember where we invoke this function.
I'm not only in single product.
So if you navigate into a single product, remember, we have that add to cart, which just never gets
to the cart page.
And of course, this is where we'll add that functionality.
Now, here's the thing.
Since my API has that property of stock, since I'm checking how many items I am going to stock, there
is going to be more functionality to this add to cart function.
And normally I just grab the idea, I just find the product and I just add it to the card.
But since we always, always want to double check with that stock, since this functionality is a little
bit more complicated in this add to cart will have to pass in more values.
So if you have watched my previous e-commerce, you know that we simply grab the idea and we were in
good shape in this case.
There's going to be more data coming in because we always, always want to double check our values to
our stock because I don't want the amount to be bigger than the amount of items I have in a stock.
So say here, add to cart.
And we have gone to court function and all right away, pass it down just so I don't forget about it
and I'll say at court and in here we'll be looking for the ID.
And remember, we still need to go back to the single product and pass those things in and of course,
invoke the function.
It's there and we're going to go with color amount and then the product.
So we're passing in four things into this function.
Now, as far as the functionality where we'll dispatch an action that is coming from my actions, jazz
and the action type is ad on the score to card and then in the payload that will pass in all of our
values that are coming as parameters.
So passing the color amount amount and the product that I'm using, the six thing where I don't need
to set them equal to each other if the names match.
So save and I would want to go back to the single product.
And of course, first I would want to get my function and then I would want to pass these values down
and keep in mind that the moment, of course, will set up everything.
We also need to worry about the coproducer, but we'll do that at the very, very end.
So in the single court or I'm sorry, in the single product once navigated back there, remember, we
were not done, even though we're nicely set up everything.
And you know what, my apologies.
Not in a single product.
Single product was good, actually.
We need to do that in the apple cart.
My apologies.
I forgot that we set up everything in the component.
So my bad not single product false alert.
We're going to add to cart component.
And we already importing used car context, so we already have access to the context and below or above
the product doesn't really matter.
I would want to grab my ATM card function from use card context so we go with CONSED and then add to
cart function.
By the way, naming is not correct here, I need to go to court and not all be equal two years and minecart
and of course the context.
So we save it and then we'll scroll down.
And of course, once we click on the button at the court, I would want to pass in those values.
So let's do it.
We're going to scroll down and then I have to card button.
And now, of course, our two want to set up my own click and invoke my add to cart.
Now, in this case, I do want to set up the arrow function because we'll have to pass in the arguments.
So let's go with Add to CART.
And then I remember what values we were looking for in the card context.
I would want to get the ID, I would want to get the color.
Now this is the main color.
Remember in add card we were setting up these values in the state.
We had the main color.
So the color that the user picked as well as the amount so amount of items.
And then of course we were checking.
So it is not bigger than the stock.
So in the card context, we are looking for ID, we're looking for that main color and the amount of
items we would want to add to the card.
So always back down.
And nothing serious, but where I have to court, first of all, I would want to pass in the area and
remember, we are the structuring that already from the product, so that still stays the same.
Then I would want to pass in the main color again.
That's the color that I would want to add to my cart and the amount.
So these are two state values.
And lastly, since I always would want to double check with my stock values, I also need to pass in
the product.
So in the context, remember, ID color amount and product.
So those are the things, of course, that we're passing in, in the add to CART Jayesh component and
we should be in good shape.
We need to go to court producer and of course handle that action.