1
00:00:00,150 --> 00:00:01,890
So let's get cracking.

2
00:00:02,460 --> 00:00:07,230
And first, I want to navigate through the actions, want to grab all three.

3
00:00:08,340 --> 00:00:12,810
Because remember, we essentially just want to add a different word in front of it.

4
00:00:13,410 --> 00:00:19,680
So let me set up properly all my courses before I won't mess this up.

5
00:00:20,260 --> 00:00:24,330
Then let's delete and we're just going to go here with Update.

6
00:00:24,870 --> 00:00:27,360
Then we want to set up the imports.

7
00:00:27,780 --> 00:00:31,380
So let's go to the app context and learn one by one.

8
00:00:31,380 --> 00:00:38,400
We're looking for update user updates, success and update an error as well.

9
00:00:38,670 --> 00:00:39,480
Let's say about one.

10
00:00:39,890 --> 00:00:46,980
And before we do anything further in the app context, I also want to import them right away in my.

11
00:00:47,940 --> 00:00:49,680
Just so that one is out of the way.

12
00:00:50,660 --> 00:00:56,570
Then we want to do is go back to the Arab context, and again, the set up is going to be extremely,

13
00:00:56,570 --> 00:00:59,150
extremely, extremely similar to set up user.

14
00:00:59,630 --> 00:01:05,870
And before you ask, no, we cannot use the same function simply because, well, we're going to be

15
00:01:05,870 --> 00:01:06,590
using off.

16
00:01:06,920 --> 00:01:07,250
Correct.

17
00:01:07,460 --> 00:01:09,290
And that is a good enough reason.

18
00:01:09,590 --> 00:01:13,220
Now, can you somehow, someway make it as a one function?

19
00:01:13,520 --> 00:01:14,780
Well, technically you can.

20
00:01:15,240 --> 00:01:17,480
Again, the endpoint changes a little bit.

21
00:01:17,750 --> 00:01:22,520
The user will be still the same, though, and as far as the alert text they are, technically you can

22
00:01:22,520 --> 00:01:23,360
passing that data.

23
00:01:23,630 --> 00:01:28,610
But this is going to be the case where I will set up new function, even though in the reducer.

24
00:01:28,960 --> 00:01:32,330
Yes, a lot of the functionality is going to be exactly the same.

25
00:01:32,570 --> 00:01:34,160
So first, I want to set up that loading.

26
00:01:34,160 --> 00:01:34,520
Correct?

27
00:01:35,390 --> 00:01:36,770
So we're going to go here with this patch.

28
00:01:37,160 --> 00:01:41,930
We will set up a type and I want to go with update user and not error.

29
00:01:42,380 --> 00:01:43,820
We'll go with Begin.

30
00:01:44,180 --> 00:01:45,710
Let's start at one.

31
00:01:45,710 --> 00:01:51,050
I know I'll get back my data and I'm not going to showcase this because we already have covered this

32
00:01:51,050 --> 00:01:55,430
before, but I know that there is user location and token correct.

33
00:01:55,760 --> 00:02:03,230
So let's go here with Konst user location and then token one is coming from the data.

34
00:02:03,620 --> 00:02:07,250
Then I want to dispatch and pass those things to the reducer.

35
00:02:07,790 --> 00:02:08,720
So what do we want to do?

36
00:02:08,720 --> 00:02:16,270
What we want to go with this patch vinyl pressing type now in this case, type will be update user and

37
00:02:16,490 --> 00:02:20,000
success, and let's pass in the payload and say payload.

38
00:02:20,280 --> 00:02:21,410
Now that is an object.

39
00:02:21,410 --> 00:02:26,600
And what do we want a passing user location and then token now?

40
00:02:27,460 --> 00:02:33,940
We will add some code over here eventually, but for the time being, I simply want to dispatch the

41
00:02:33,940 --> 00:02:34,270
error.

42
00:02:34,420 --> 00:02:39,490
Actually, you're not for I forget, we also want to add that to the local storage, so add user to

43
00:02:39,490 --> 00:02:45,640
the local storage and then let's pass in user location and the token as well.

44
00:02:46,030 --> 00:02:49,240
So that's pretty much the same as the payload door here.

45
00:02:49,570 --> 00:02:54,670
And then let's deal with that error where again, we wanted this patch something and that something

46
00:02:54,670 --> 00:02:56,020
is going to be our error.

47
00:02:56,380 --> 00:03:02,650
So type a mine, we want to go with update user and not success.

48
00:03:03,040 --> 00:03:06,820
We actually want to go for the error one and not as far as the payload well.

49
00:03:07,120 --> 00:03:10,090
Remember, we won't be sending back the error message, correct?

50
00:03:10,420 --> 00:03:12,580
So this is the case where again, we can go with message.

51
00:03:13,020 --> 00:03:16,270
No one is equal to error, then a response.

52
00:03:16,420 --> 00:03:17,740
So that's the actual thing.

53
00:03:18,070 --> 00:03:25,870
And then we have data and then message and at the very, very end since I'll set up the alerts.

54
00:03:25,990 --> 00:03:27,070
I also want to clear them.

55
00:03:27,340 --> 00:03:30,550
So let's go here with clear alert and let's hear it.

56
00:03:31,000 --> 00:03:37,510
Now, once we have a list in place, let's navigate to the reducer and set up the functionality.

57
00:03:37,870 --> 00:03:39,160
So we already have the actions.

58
00:03:39,430 --> 00:03:40,270
Let's keep scrolling.

59
00:03:40,690 --> 00:03:47,170
And again, this is going to be the case where we literally can copy and paste because I mean, most

60
00:03:47,170 --> 00:03:49,030
of it is going to be exactly the same.

61
00:03:49,300 --> 00:03:56,110
And yes, you can technically make this into a one function and then somehow in some way, combine it.

62
00:03:56,110 --> 00:04:02,530
But I'm kind of very skeptical of that type of approach because in my opinion, that's just overcomplicating

63
00:04:02,530 --> 00:04:02,950
something.

64
00:04:03,160 --> 00:04:10,150
So let me take right now, the set up user begin essentially all the way to a set up user error.

65
00:04:10,630 --> 00:04:11,620
Let's copy this one.

66
00:04:11,770 --> 00:04:15,220
Let's keep scrolling and an almost copy and paste.

67
00:04:15,250 --> 00:04:17,019
And essentially, again, same thing.

68
00:04:17,410 --> 00:04:19,779
I just want to change this program.

69
00:04:19,839 --> 00:04:25,060
That's all we have to do, because if we take a look at the read me effectively, the setup is going

70
00:04:25,060 --> 00:04:26,050
to be exactly the same.

71
00:04:26,380 --> 00:04:31,750
So instead of setup, we're going to go with update and then user, and that's it.

72
00:04:32,050 --> 00:04:34,540
And once we say again, what happens over here?

73
00:04:34,550 --> 00:04:38,860
Well before we send the request, we set loading to true.

74
00:04:39,490 --> 00:04:42,850
Then once we're successful, we go update user success.

75
00:04:43,300 --> 00:04:49,960
And in this case, what we can do, though, is just change the text where this is not going to be provided,

76
00:04:50,140 --> 00:04:51,820
which show from the function.

77
00:04:52,150 --> 00:04:53,860
In this case, I'll just add code.

78
00:04:54,160 --> 00:05:00,160
I'll say alert type will be success and then also user profile and updated.

79
00:05:00,850 --> 00:05:07,680
And when it comes to token user and user location geolocation, yes, we are setting them again from

80
00:05:07,690 --> 00:05:15,850
scratch because we set up the new token and we possibly might have a new user data, correct?

81
00:05:16,180 --> 00:05:21,460
And then when it comes to error, while the same deal update user error, and then I'm just looking

82
00:05:21,790 --> 00:05:28,620
for the message that is in action, payload and message, and we're almost ready to take it out for

83
00:05:28,630 --> 00:05:29,230
test drive.

84
00:05:29,530 --> 00:05:34,870
Now one thing we need to remember, though, in the interceptors, more specifically in the request

85
00:05:34,870 --> 00:05:38,650
one, we remove the authorization header.

86
00:05:38,920 --> 00:05:39,280
Correct.

87
00:05:39,700 --> 00:05:45,730
So we need to add that one back up otherwise well, we'll have unsuccessful requests.

88
00:05:46,120 --> 00:05:47,500
So let's save this one.

89
00:05:47,860 --> 00:05:49,750
And now let's navigate to the profile page.

90
00:05:50,500 --> 00:05:56,020
And here I just want to change some values around where at the moment, notice this is my John user.

91
00:05:56,500 --> 00:06:02,800
So why don't we change some things around where I want to go here with Susan, right?

92
00:06:02,810 --> 00:06:05,470
And let's pass in the I don't know, Smith.

93
00:06:05,470 --> 00:06:09,670
Maybe then I also probably want to change the email.

94
00:06:09,970 --> 00:06:11,740
So in this case, I'm going to go with Susan now.

95
00:06:11,740 --> 00:06:17,530
I might delete the user and then set it up from scratch in between the videos, then that is irrelevant.

96
00:06:17,860 --> 00:06:23,800
And when it comes to location, let's go over here with Mexico, so let's save this.

97
00:06:24,280 --> 00:06:27,640
And notice how we successfully updated the profile.

98
00:06:28,090 --> 00:06:34,210
And then since we're updating the state, keep in mind that these are going to be our values correct?

99
00:06:34,480 --> 00:06:34,840
Why?

100
00:06:34,870 --> 00:06:42,100
Well, because if I go to the profile page, what is the value on here when there's a user email, last

101
00:06:42,100 --> 00:06:43,300
name and location?

102
00:06:43,750 --> 00:06:44,920
So that is correct.

103
00:06:45,250 --> 00:06:51,520
And that also if I take a look at my database and effectively, I would just have to refresh in order

104
00:06:51,520 --> 00:06:52,720
to see the latest changes.

105
00:06:53,080 --> 00:06:59,230
What I also notice is right away the user, John, which right now has all of these values.

106
00:06:59,710 --> 00:07:02,410
So now I can see that our functionality works.

107
00:07:02,620 --> 00:07:08,770
We're successfully attaching the token when we're sending requests with our auth instance.

108
00:07:09,010 --> 00:07:15,400
And if one of the values is missing, for example, the last name which you'll notice is the arrow that

109
00:07:15,400 --> 00:07:16,870
is coming back from the server.

110
00:07:17,230 --> 00:07:21,640
So this is not different than there because we did comment this one out temporarily.

111
00:07:21,970 --> 00:07:25,900
This is coming back from the server and once we have.

112
00:07:26,220 --> 00:07:29,190
All of this in place now, we can move on to the next step.

