1
00:00:00,380 --> 00:00:00,710
All right.

2
00:00:00,710 --> 00:00:04,460
So I just want to clean up the cart slice file a little bit.

3
00:00:04,460 --> 00:00:08,150
So for one, this add decimals, this utility function.

4
00:00:08,150 --> 00:00:11,240
I'm going to put this in a separate, separate file.

5
00:00:11,240 --> 00:00:15,170
So let's cut that and then in front end source.

6
00:00:15,170 --> 00:00:19,490
So in the source folder, I'm going to create a folder called utils.

7
00:00:20,210 --> 00:00:27,020
And then in utils let's create a file called cart utils dot js.

8
00:00:28,120 --> 00:00:33,640
And then we'll paste in the Add decimals, except I'm just going to export so that we can import it

9
00:00:34,090 --> 00:00:36,580
if we need to into other files.

10
00:00:36,940 --> 00:00:42,790
And then in the add to cart right here in this function I'm going to take.

11
00:00:43,610 --> 00:00:51,980
Everything from where we get the items price or set the items price down to the local storage set item.

12
00:00:51,980 --> 00:00:56,480
I'm going to cut that and then we're going to create a function here.

13
00:00:57,350 --> 00:00:59,040
Called update card.

14
00:01:00,500 --> 00:01:05,810
And that's going to be an arrow function it's going to take in state.

15
00:01:07,310 --> 00:01:07,760
Oops.

16
00:01:07,790 --> 00:01:13,970
And then we'll just go ahead and paste in what I just cut and just return.

17
00:01:14,660 --> 00:01:15,680
State.

18
00:01:17,520 --> 00:01:24,350
Okay, now we don't have to bring add decimals into cart slice because we're no longer using it in here.

19
00:01:24,360 --> 00:01:26,820
We're only using it in this stuff.

20
00:01:26,820 --> 00:01:29,280
So we don't need to bring that in.

21
00:01:29,820 --> 00:01:33,990
And if we needed to use it in another file, we could because we're exporting it.

22
00:01:33,990 --> 00:01:35,820
But we do want the update cart.

23
00:01:35,820 --> 00:01:36,660
So let's.

24
00:01:37,770 --> 00:01:43,110
Bring that in and we'll say import and we want to bring in update cart.

25
00:01:44,900 --> 00:01:45,560
Okay.

26
00:01:45,560 --> 00:01:48,800
And then we're just going to simply return.

27
00:01:48,800 --> 00:01:51,350
So down at the bottom here, we're going to return.

28
00:01:52,210 --> 00:01:55,990
Update cart and pass in state.

29
00:01:56,320 --> 00:01:58,940
So everything should still work the same.

30
00:01:58,960 --> 00:02:06,640
Now if you want to clear your your your cart, obviously we don't have that in the UI, but you can

31
00:02:06,640 --> 00:02:11,080
clear it from local storage and that should also clear it from your state.

32
00:02:11,080 --> 00:02:18,430
So if we go to application and then here local storage and you see cart.

33
00:02:19,360 --> 00:02:19,950
We can.

34
00:02:19,960 --> 00:02:21,430
I'm just going to clear everything.

35
00:02:21,430 --> 00:02:26,320
Some of this stuff is from some other projects, so I'm just going to clear everything.

36
00:02:26,320 --> 00:02:28,570
And now if I reload.

37
00:02:29,220 --> 00:02:31,440
And we look at our redux state.

38
00:02:33,640 --> 00:02:34,930
And we look at the cart.

39
00:02:34,960 --> 00:02:41,560
You can see that all we have is an empty array in cart items and we should be able to add to cart.

40
00:02:41,650 --> 00:02:46,660
Obviously this doesn't work, but it does get added or it should get added.

41
00:02:47,240 --> 00:02:48,170
To our state.

42
00:02:48,170 --> 00:02:49,640
So now we have carte items.

43
00:02:49,640 --> 00:02:50,960
We have one item.

44
00:02:50,960 --> 00:02:52,610
We have our price.

45
00:02:52,820 --> 00:02:53,540
Good.

46
00:02:55,250 --> 00:02:55,580
All right.

47
00:02:55,580 --> 00:02:58,610
So now that we've we've cleaned that up a little bit.

48
00:02:58,730 --> 00:03:03,440
The next thing that I want to do is, is in the header here where it says card.

49
00:03:03,440 --> 00:03:08,120
I want it to show the number of items that we have currently in our cart.

50
00:03:08,120 --> 00:03:09,620
So we're going to work on that next.

