1
00:00:00,450 --> 00:00:00,840
All right.

2
00:00:01,110 --> 00:00:08,250
And now it's set up the entire functionality, and this is going to be the case since there's so many

3
00:00:08,250 --> 00:00:08,970
similarities.

4
00:00:09,480 --> 00:00:10,980
There will be copying, purchasing.

5
00:00:11,190 --> 00:00:15,420
I really don't see the point of setting up everything from scratch.

6
00:00:15,840 --> 00:00:19,980
If you take a look at the register of the register, use their function.

7
00:00:20,340 --> 00:00:29,070
You'll notice that the only difference is the dispatch type, meaning in there we use a register and

8
00:00:29,070 --> 00:00:36,780
then the URL and the same is going to be in the reducer where instead of action type register, we go

9
00:00:36,780 --> 00:00:37,620
with a login.

10
00:00:38,220 --> 00:00:42,690
And then when it comes to the user, we just change here the alert text.

11
00:00:42,930 --> 00:00:48,270
And I really don't see the point of typing everything from scratch because I do believe that when we

12
00:00:48,270 --> 00:00:54,540
were setting up register, I spent quite enough time on explaining every small detail.

13
00:00:54,840 --> 00:01:00,480
So let's go to our app context and we simply want to grab this register one.

14
00:01:00,930 --> 00:01:05,340
And you're not just going to grab everything that I have inside of the function body.

15
00:01:05,790 --> 00:01:08,160
So I want to do any renaming here.

16
00:01:08,160 --> 00:01:10,070
So I'm going to copy and paste.

17
00:01:10,080 --> 00:01:13,770
And again, we are looking for these three dispatchers.

18
00:01:14,070 --> 00:01:20,430
And again, I'm going to do that using my cursor, and we're just going to look for a log in one.

19
00:01:20,760 --> 00:01:21,840
That's step number one.

20
00:01:22,330 --> 00:01:25,800
Van, we want to change this one around where it's not going to be a register.

21
00:01:26,100 --> 00:01:27,420
It's going to be a login.

22
00:01:27,810 --> 00:01:29,550
We're still passing in the current user.

23
00:01:29,910 --> 00:01:35,610
So it is still post request and it's going through our backend that stays the same.

24
00:01:36,000 --> 00:01:40,440
And here, though, we already know that there's a giant object and I'm just looking for the data,

25
00:01:40,590 --> 00:01:41,000
correct?

26
00:01:41,010 --> 00:01:42,450
So I don't need to go with that response.

27
00:01:42,780 --> 00:01:43,950
Now, I also don't want to log it.

28
00:01:43,950 --> 00:01:47,760
Like I said, that was just with our initial request.

29
00:01:48,150 --> 00:01:53,610
I pull out user token and location, and I want to dispatch login user success.

30
00:01:53,700 --> 00:01:54,570
And what is the payload?

31
00:01:54,810 --> 00:01:57,800
Same user token and location.

32
00:01:58,800 --> 00:02:07,590
I want to add it right away to a local storage because it's important for me when it comes to a page

33
00:02:07,590 --> 00:02:08,130
refresh.

34
00:02:08,580 --> 00:02:12,180
So I want to access those values and I don't want a logged response here.

35
00:02:12,660 --> 00:02:15,960
That said, again, we did that with our first request.

36
00:02:16,320 --> 00:02:20,730
And then when it comes to payload, we go to message and again, the arrow is going to be sitting in

37
00:02:21,030 --> 00:02:23,670
our response data and message.

38
00:02:23,700 --> 00:02:27,060
No, well, test out some error responses as well.

39
00:02:27,420 --> 00:02:28,030
Clear alert.

40
00:02:28,050 --> 00:02:28,440
Why?

41
00:02:28,530 --> 00:02:33,060
Well, because we set up the alert and it's my preference to remove it.

42
00:02:33,420 --> 00:02:37,920
Let's save this and I'll go to our producer.

43
00:02:38,430 --> 00:02:43,860
Let's keep on scrolling where we have registered user begin and error.

44
00:02:44,340 --> 00:02:46,270
Let's copy and paste all three of them.

45
00:02:46,290 --> 00:02:50,070
And don't worry, the future functionality is not going to be just copying thing.

46
00:02:50,070 --> 00:02:54,630
But this is the case where I definitely don't see the point of setting up everything from scratch.

47
00:02:54,630 --> 00:02:57,460
So let's select all three of them.

48
00:02:57,480 --> 00:02:58,380
What are we looking for?

49
00:02:58,740 --> 00:03:00,990
We're looking for a log in one, correct?

50
00:03:01,380 --> 00:03:04,140
Now, when we start fetching, what do we do?

51
00:03:04,500 --> 00:03:04,880
We go.

52
00:03:04,950 --> 00:03:05,530
Is loading.

53
00:03:05,550 --> 00:03:05,850
True.

54
00:03:06,570 --> 00:03:08,070
We set up the loading ramp.

55
00:03:08,070 --> 00:03:09,780
If we're successful, what are we doing?

56
00:03:10,140 --> 00:03:10,980
Is loading false?

57
00:03:11,430 --> 00:03:14,100
One token user user location, driver location.

58
00:03:14,460 --> 00:03:16,800
They get the same values.

59
00:03:17,520 --> 00:03:18,720
Charlotte is true.

60
00:03:18,870 --> 00:03:19,920
So we're successful.

61
00:03:20,220 --> 00:03:22,770
The only thing that we can change is the string here.

62
00:03:22,920 --> 00:03:23,340
Correct.

63
00:03:23,880 --> 00:03:27,570
And I believe I went with log in, successful excel.

64
00:03:28,020 --> 00:03:32,910
So if you want, you're going to retype it in my case or saved myself a little bit of time and copy

65
00:03:32,910 --> 00:03:33,390
and paste.

66
00:03:33,900 --> 00:03:41,400
So again, I'm still saying redirecting because the user will be redirected to the dashboard.

67
00:03:41,430 --> 00:03:41,910
Why?

68
00:03:42,300 --> 00:03:43,590
Because we set up the user.

69
00:03:43,980 --> 00:03:48,470
Initially, there's going to be no user and then we add it to the state and remember user fact.

70
00:03:48,750 --> 00:03:50,850
Well, we were checking for that user, correct.

71
00:03:51,210 --> 00:03:52,410
And as far as the error?

72
00:03:52,650 --> 00:03:55,110
Well, same deal as lowering false color.

73
00:03:55,110 --> 00:03:59,880
True and then alert type will be danger instead of the success.

74
00:04:00,300 --> 00:04:01,410
So let's try it out.

75
00:04:01,560 --> 00:04:06,600
I mean, everything should work because we already tested everything in a manner.

76
00:04:06,960 --> 00:04:08,100
So let me navigate here.

77
00:04:08,130 --> 00:04:12,630
Let me make sure that there's nothing in the local storage.

78
00:04:12,840 --> 00:04:14,550
So we start from scratch here.

79
00:04:14,940 --> 00:04:16,589
Yep, there are no values over there.

80
00:04:16,860 --> 00:04:20,640
And then let's go then some type of user that you already have.

81
00:04:20,640 --> 00:04:21,750
In my case, not as John.

82
00:04:22,110 --> 00:04:24,540
And then I'm going to go with my secret one.

83
00:04:24,840 --> 00:04:31,140
So once I added notice how everything is correct, so we add that to the local storage.

84
00:04:31,350 --> 00:04:35,430
We also add the user to our context.

85
00:04:35,850 --> 00:04:38,520
So now I have the user token and all that.

86
00:04:38,730 --> 00:04:44,350
In this case, yeah, we do have a few more properties, but it's not a big deal, as well as user location

87
00:04:44,350 --> 00:04:45,120
and geolocation.

88
00:04:45,510 --> 00:04:49,440
And then because of our user effect, we check for the user.

89
00:04:49,590 --> 00:04:54,300
And if the user exists, then beautiful, we navigate to a dashboard page.

90
00:04:54,630 --> 00:04:57,360
Now let's also test out the error.

91
00:04:58,140 --> 00:04:59,850
So in my case, when I go back to.

92
00:04:59,920 --> 00:05:04,550
Application, again, I want to remove it, because remember, we have to set up enregistre if there

93
00:05:04,550 --> 00:05:06,490
is a user will navigate away.

94
00:05:06,920 --> 00:05:07,730
That's our setup.

95
00:05:07,760 --> 00:05:13,400
And therefore, since we don't have to log on functionality yet, I'm going to remove it from my local

96
00:05:13,400 --> 00:05:13,970
storage.

97
00:05:14,570 --> 00:05:18,230
Basically, refresher so I don't have anything in the state as well.

98
00:05:18,530 --> 00:05:21,980
And then let's go back to the register and let's try out the error.

99
00:05:22,310 --> 00:05:27,680
So let's go here with John at gmail.com and I'm going to mess up my password.

100
00:05:28,100 --> 00:05:34,220
So let's say I'll add one extra character and what do I c order invalid credentials?

101
00:05:34,280 --> 00:05:40,220
Now, if I'll fix the error and I'll provide the correct password, then we should see logging successful

102
00:05:40,250 --> 00:05:40,940
redirecting.

103
00:05:41,240 --> 00:05:46,640
And then again, in whatever seconds, we'll get to the dashboard page and that's how we can set up

104
00:05:46,880 --> 00:05:49,970
log in functionality in our application.

