1 00:00:00,360 --> 00:00:07,890 Awesome, and once we can successfully clear Hocutt, the next easiest functionality is going to be 2 00:00:07,890 --> 00:00:11,220 removing a single item from the cart. 3 00:00:11,670 --> 00:00:19,250 So we're going to navigate back to context jazz and we're going to come up with some kind of name. 4 00:00:19,800 --> 00:00:21,060 We're going to say, you know what? 5 00:00:21,300 --> 00:00:25,020 The function name will be removed right after clear. 6 00:00:25,380 --> 00:00:27,250 We're going to go with Consed and then remove. 7 00:00:27,570 --> 00:00:32,520 Now, in this case, though, we are looking for the idea that is important in this case, because, 8 00:00:32,520 --> 00:00:37,850 of course, when we want to remove the item, we need to know, well, which item are we actually removed? 9 00:00:37,870 --> 00:00:38,320 Correct. 10 00:00:38,670 --> 00:00:40,200 So we go with this patch again. 11 00:00:40,410 --> 00:00:45,900 We passing the object now type in this case is going to be removed again. 12 00:00:46,350 --> 00:00:47,430 Common convention. 13 00:00:47,460 --> 00:00:51,230 We set up everything uppercase and then we need to pass in that idea. 14 00:00:51,480 --> 00:00:56,850 And then again, Common Convention is calling this bailout, but you can call it Bugs Bunny, you can 15 00:00:56,850 --> 00:00:58,260 call it taco and burrito. 16 00:00:58,470 --> 00:00:59,250 Doesn't really matter. 17 00:00:59,250 --> 00:01:01,530 But in my case, I'm going to call this bailout. 18 00:01:01,560 --> 00:01:05,580 And of course, I'll set it equal to the idee we save. 19 00:01:05,850 --> 00:01:08,880 And of course, we would want to pass that function down. 20 00:01:09,180 --> 00:01:15,540 And I can tell right away that as far as next functions, all of them will end up in one place. 21 00:01:15,780 --> 00:01:21,150 And that is the card item, because in this current item, I would want to remove the item from the 22 00:01:21,150 --> 00:01:21,570 cart. 23 00:01:21,600 --> 00:01:24,020 I would want to increase or decrease. 24 00:01:24,240 --> 00:01:25,170 So we navigate that. 25 00:01:25,170 --> 00:01:27,510 We navigate to the cart item. 26 00:01:27,510 --> 00:01:34,220 Of course, I'll close my sidebar and then I already have the use global context and I simply say Consed 27 00:01:34,230 --> 00:01:39,740 and I have the structure and function and that is coming from my U.S. global context. 28 00:01:39,750 --> 00:01:47,370 Of course I invoke it and this is the part where I do need to set up my inline function because I want 29 00:01:47,370 --> 00:01:54,540 to personally remember when I showed you the overview of the setup, I said, yeah, we have the idea, 30 00:01:54,540 --> 00:02:01,740 but at the moment we're not using our we will use it when we start hooking up everything as far as the 31 00:02:01,740 --> 00:02:03,120 contact is concerned. 32 00:02:03,510 --> 00:02:07,820 And in this case, I'll pass and my function remove and I'll pass in that. 33 00:02:08,400 --> 00:02:15,260 So that will be that specific ID that is unique for every item that I have in the car. 34 00:02:15,570 --> 00:02:18,660 And of course, the last thing, again, we just need to deal with that. 35 00:02:18,870 --> 00:02:20,980 And the producer, again, we have. 36 00:02:22,160 --> 00:02:29,720 And we would want to come up with the functionality and it's going to be a condition again, so if that 37 00:02:29,720 --> 00:02:38,060 action and type and if it is equal to remove what I would want to do, well, again, let's think about 38 00:02:38,060 --> 00:02:38,170 it. 39 00:02:38,600 --> 00:02:40,600 I would want to return the old state. 40 00:02:40,850 --> 00:02:45,890 Of course, I would still want to preserve my loadings, my totals and then my amounts. 41 00:02:45,890 --> 00:02:47,720 But I would want to change the. 42 00:02:48,470 --> 00:02:53,780 Now, if you want, you can set up a separate variable and undo the functionality here. 43 00:02:54,030 --> 00:02:55,310 That is definitely the case. 44 00:02:55,670 --> 00:03:01,430 But since I feel like a rebel, I'm going to do somewhat similar where I'm going to return to state 45 00:03:01,640 --> 00:03:05,930 and then I'll do my functionality right here in the object. 46 00:03:06,080 --> 00:03:06,900 But you don't have to. 47 00:03:07,070 --> 00:03:09,190 You can set it up separately as well. 48 00:03:09,440 --> 00:03:11,570 So we'll go with the return standard. 49 00:03:11,570 --> 00:03:17,150 And then, of course, we're returning a state then again court and I'm looking for state. 50 00:03:17,480 --> 00:03:19,100 So state before update. 51 00:03:19,310 --> 00:03:24,110 There is a court array and I can just filter correct. 52 00:03:24,110 --> 00:03:32,630 And something that we have already done over the projects and I would want to say 50 times is to grab 53 00:03:32,630 --> 00:03:37,580 the values, the items whose IDs do not match. 54 00:03:37,940 --> 00:03:42,710 So I'm passing in the payload theory of the item that I would want to remove. 55 00:03:43,010 --> 00:03:44,990 And I'm just going to say cart item. 56 00:03:45,260 --> 00:03:46,930 That is every item in my. 57 00:03:47,420 --> 00:03:55,670 And if the cart item ID does not match the idea that I'm passing in the payload, beautiful, then that 58 00:03:55,670 --> 00:03:56,830 item will be returned. 59 00:03:57,080 --> 00:04:00,380 So we go and action and then payload luxo. 60 00:04:00,710 --> 00:04:05,550 However, if the item rematches then of course that is the item that I would want to remove. 61 00:04:05,870 --> 00:04:08,030 So it is not going to be in my car. 62 00:04:08,810 --> 00:04:12,410 And there is now I can just simply say, yep, this item is gone. 63 00:04:12,440 --> 00:04:14,750 This item is gone as well as this one. 64 00:04:14,900 --> 00:04:17,880 So now, of course, we go back to the empty car. 65 00:04:18,170 --> 00:04:23,360 Now, if you want, of course, you can navigate to the bigger screen and take a look at the components 66 00:04:23,360 --> 00:04:23,700 left. 67 00:04:24,230 --> 00:04:28,460 But in my case, we'll move on to our next piece of functionality.