All right.
So I just want to clean up the cart slice file a little bit.
So for one, this add decimals, this utility function.
I'm going to put this in a separate, separate file.
So let's cut that and then in front end source.
So in the source folder, I'm going to create a folder called utils.
And then in utils let's create a file called cart utils dot js.
And then we'll paste in the Add decimals, except I'm just going to export so that we can import it
if we need to into other files.
And then in the add to cart right here in this function I'm going to take.
Everything from where we get the items price or set the items price down to the local storage set item.
I'm going to cut that and then we're going to create a function here.
Called update card.
And that's going to be an arrow function it's going to take in state.
Oops.
And then we'll just go ahead and paste in what I just cut and just return.
State.
Okay, now we don't have to bring add decimals into cart slice because we're no longer using it in here.
We're only using it in this stuff.
So we don't need to bring that in.
And if we needed to use it in another file, we could because we're exporting it.
But we do want the update cart.
So let's.
Bring that in and we'll say import and we want to bring in update cart.
Okay.
And then we're just going to simply return.
So down at the bottom here, we're going to return.
Update cart and pass in state.
So everything should still work the same.
Now if you want to clear your your your cart, obviously we don't have that in the UI, but you can
clear it from local storage and that should also clear it from your state.
So if we go to application and then here local storage and you see cart.
We can.
I'm just going to clear everything.
Some of this stuff is from some other projects, so I'm just going to clear everything.
And now if I reload.
And we look at our redux state.
And we look at the cart.
You can see that all we have is an empty array in cart items and we should be able to add to cart.
Obviously this doesn't work, but it does get added or it should get added.
To our state.
So now we have carte items.
We have one item.
We have our price.
Good.
All right.
So now that we've we've cleaned that up a little bit.
The next thing that I want to do is, is in the header here where it says card.
I want it to show the number of items that we have currently in our cart.
So we're going to work on that next.