1
00:00:00,120 --> 00:00:04,980
So let's try to set everything up again, this video might be a little bit longer, but I have full

2
00:00:04,980 --> 00:00:11,370
confidence that we are already familiar with the setup, so we have the function of that is nice.

3
00:00:11,670 --> 00:00:15,780
Now I just want to grab all the imports, so we go back to the lead me.

4
00:00:16,790 --> 00:00:19,160
And then we go to the register, I'm sorry.

5
00:00:19,190 --> 00:00:20,490
Not registered profile.

6
00:00:20,510 --> 00:00:21,200
My apologies.

7
00:00:21,590 --> 00:00:24,260
So we go to the profile, we get all the imports.

8
00:00:24,410 --> 00:00:25,460
That's the first step.

9
00:00:25,820 --> 00:00:29,870
And now let's set up our import from the AMP context.

10
00:00:29,870 --> 00:00:33,350
So close the sidebar and then let's go here with the user.

11
00:00:33,920 --> 00:00:40,580
So we're going to be looking for user ID and we also want to good show alert that also display alert.

12
00:00:41,560 --> 00:00:46,060
So Charlotte is going to be the condition and display alert is going to be a function.

13
00:00:46,510 --> 00:00:51,460
And we also want to go and update user function that reduce just set up ease.

14
00:00:51,460 --> 00:00:56,050
Loading, Of course, and then all of that is equal to use app context.

15
00:00:56,140 --> 00:00:56,980
We invoke it.

16
00:00:57,270 --> 00:00:58,060
That's the first step.

17
00:00:58,360 --> 00:01:01,150
And now it's set up those state values one by one.

18
00:01:01,450 --> 00:01:07,900
So we have name, email, last name and locations of consent, and we're looking for a name when the

19
00:01:07,900 --> 00:01:12,400
function name will be set name and then that will be equal to use state.

20
00:01:12,820 --> 00:01:14,500
And then let's look for user.

21
00:01:14,710 --> 00:01:16,960
If the user exists, then we'll go the name.

22
00:01:17,560 --> 00:01:17,920
That's it.

23
00:01:17,920 --> 00:01:19,510
That's going to be our default.

24
00:01:19,540 --> 00:01:21,280
And then, if not, that is going to be undefined.

25
00:01:21,460 --> 00:01:27,130
Now, keep in mind that the only time when the user will be know is when we haven't logged in yet.

26
00:01:27,400 --> 00:01:27,730
Correct.

27
00:01:28,120 --> 00:01:34,990
So let's copy and paste this one, and this one will be equal to an email version of the function.

28
00:01:34,990 --> 00:01:36,610
Name also will be equal to an email.

29
00:01:37,300 --> 00:01:39,490
And then lastly, we're not looking for a name.

30
00:01:39,730 --> 00:01:43,020
We're looking for email and let's copy and paste.

31
00:01:43,030 --> 00:01:51,290
And here we're going to go with a last name, last name, and then the function name also will be the

32
00:01:51,310 --> 00:01:51,880
last name.

33
00:01:52,690 --> 00:01:54,610
And then lastly, what is the property?

34
00:01:54,970 --> 00:01:56,590
It's also the last name, correct?

35
00:01:56,890 --> 00:02:03,670
And again, you can go to the state and you'll clearly see that those are all the properties on our

36
00:02:03,670 --> 00:02:04,390
user object.

37
00:02:04,480 --> 00:02:06,430
And then lastly, we have the location.

38
00:02:07,500 --> 00:02:09,090
So this is not going to be a last name.

39
00:02:09,570 --> 00:02:13,620
We're going to go with location and here also go to location.

40
00:02:14,810 --> 00:02:22,340
And as far as our user, dot will also look for location property, then let's set up the handle submit

41
00:02:23,030 --> 00:02:24,350
and for the time being.

42
00:02:24,770 --> 00:02:28,430
We're going to maybe log submitted the form or whatever.

43
00:02:28,850 --> 00:02:30,770
Let's worry about this one at the very, very end.

44
00:02:31,160 --> 00:02:33,800
So pranced and then handles submit.

45
00:02:34,640 --> 00:02:41,710
Now we do want to right away grab the event object and we want to go with event and then prevent and

46
00:02:41,710 --> 00:02:42,440
then default.

47
00:02:42,620 --> 00:02:43,310
Let's invoke it.

48
00:02:43,550 --> 00:02:44,840
Let's say update.

49
00:02:45,260 --> 00:02:46,140
Here's our lecture.

50
00:02:46,370 --> 00:02:47,090
That's our handle.

51
00:02:47,090 --> 00:02:47,390
Submit.

52
00:02:47,660 --> 00:02:53,180
So now let's worry about the return where I'm going to grab the wrapper again, which is coming from

53
00:02:53,180 --> 00:02:55,550
where from the dashboard form page.

54
00:02:57,250 --> 00:03:03,280
So go here with rapper and man inside of the rapper, let's set up our form.

55
00:03:04,220 --> 00:03:09,050
So it's cohere with form as far as the action, while there's going to be no action here.

56
00:03:09,410 --> 00:03:11,210
But I do want the class name.

57
00:03:11,420 --> 00:03:12,980
It's going to be equal to a form.

58
00:03:14,160 --> 00:03:22,560
And then we want to go on, submit and pass in our panel, submit that in inside of the form.

59
00:03:22,840 --> 00:03:24,030
Let's go with Hank three.

60
00:03:24,810 --> 00:03:28,920
And let's just say here profile and now it's right away.

61
00:03:28,930 --> 00:03:30,030
Set up that alert.

62
00:03:30,630 --> 00:03:37,620
So let's say here, Charlotte, and if it is true, then we want to go with our alert component, correct?

63
00:03:38,070 --> 00:03:45,630
So we have here this alert component, and I want to showcase if the show alert is true again, you'll

64
00:03:45,630 --> 00:03:51,600
probably hear me saying this a lot, just like we did in the register and then we want to start setting

65
00:03:51,600 --> 00:03:53,080
up those form rules.

66
00:03:53,670 --> 00:04:02,100
So let's go here with Dave with a class of form center and we want to go with our former all component

67
00:04:02,400 --> 00:04:04,020
and remember what we were looking for.

68
00:04:04,350 --> 00:04:07,550
We're looking for type, which is going to be equal to it next, right?

69
00:04:07,560 --> 00:04:08,790
And we want to go with name.

70
00:04:09,120 --> 00:04:10,890
And in this case, what does it equal to?

71
00:04:11,810 --> 00:04:16,279
Well, this actually equals to my state, right, which is name.

72
00:04:16,790 --> 00:04:23,090
So therefore, I need to pass here a name and a quick Senate since in this case are set up is different

73
00:04:23,390 --> 00:04:27,170
since we are passing for different functions in house change.

74
00:04:27,590 --> 00:04:30,980
I don't like the register where we passed in the single function.

75
00:04:31,370 --> 00:04:38,330
We actually won't use name attribute value when we set the state ballot, so we're adding name attribute

76
00:04:38,540 --> 00:04:39,950
just for consistency.

77
00:04:40,130 --> 00:04:41,240
Please keep that in mind.

78
00:04:41,720 --> 00:04:43,520
Then we want to go with value.

79
00:04:43,670 --> 00:04:46,580
It's going to be again equal to name, right?

80
00:04:46,850 --> 00:04:50,090
So now in this case, I'm actually selecting the state value.

81
00:04:50,510 --> 00:04:52,490
So when I was setting up the name equal to the name.

82
00:04:52,820 --> 00:04:55,880
Well, that was the name of my state property.

83
00:04:56,150 --> 00:04:59,120
In this case, I'm looking for a value of the state property.

84
00:04:59,390 --> 00:05:03,590
Hopefully this is clear and you'll definitely see that with, for example, email.

85
00:05:04,010 --> 00:05:06,830
And we want to go here with handle change, like I said.

86
00:05:07,130 --> 00:05:13,130
And then remember, we don't want to invoke it right away, but we do want to get the event target value.

87
00:05:13,460 --> 00:05:21,140
So when I go here with my oral function and line, I'll pass in my set and name function and here let's

88
00:05:21,140 --> 00:05:23,900
pass in around that target.

89
00:05:24,200 --> 00:05:25,670
And then we're looking for the value.

90
00:05:25,770 --> 00:05:30,380
Now I definitely want to grab here the Iran and what is going to happen in our setup.

91
00:05:31,510 --> 00:05:36,280
As we start typing out the form filled well, the value will be updated.

92
00:05:36,580 --> 00:05:42,280
Now let me right away set up the last name and then I'll talk about the form text.

93
00:05:42,640 --> 00:05:49,000
So let me grab here this form one more here, and let's set up same thing for the last name right away,

94
00:05:49,000 --> 00:05:51,130
and then we'll take a look at it in the browser.

95
00:05:51,490 --> 00:05:54,400
Now what is going to be the type that will be taxed?

96
00:05:54,730 --> 00:05:56,200
Now what is going to be the name?

97
00:05:56,470 --> 00:05:59,320
We're going to go here with the last name, correct?

98
00:05:59,350 --> 00:05:59,590
Why?

99
00:05:59,620 --> 00:06:01,290
Well, because that is my state, right?

100
00:06:01,810 --> 00:06:03,280
We're going to do the same thing over here.

101
00:06:03,430 --> 00:06:05,380
Let's say last name.

102
00:06:05,620 --> 00:06:10,780
And when it comes to a handle change, set of set name will go with set last name.

103
00:06:11,110 --> 00:06:16,360
Now, once we save and once I navigate to the bigger browser window, I mean, all of this looks nice,

104
00:06:16,810 --> 00:06:19,300
but don't you think it would be better?

105
00:06:20,480 --> 00:06:25,850
If, for example, we would nicely this last name, because at the moment, notice our label.

106
00:06:26,240 --> 00:06:27,260
And why is that happening?

107
00:06:27,300 --> 00:06:32,120
Well, because if we take a look at our components and then more specifically form Rome, which you'll

108
00:06:32,120 --> 00:06:38,720
notice that I have the name that I'm passing in, and if there is no label text, then I'm using the

109
00:06:38,720 --> 00:06:38,990
name.

110
00:06:39,590 --> 00:06:46,070
And again, if you have a different functionality, as far as if you're not using this approach, then

111
00:06:46,070 --> 00:06:50,940
it is important that the name matches to your state value.

112
00:06:51,350 --> 00:06:55,730
So this will be a name for your state value and this will be a value for your state.

113
00:06:56,330 --> 00:07:00,500
And yes, technically in this case, you can make an argument that we're actually not using this name.

114
00:07:00,920 --> 00:07:05,000
But since this is not the only approach that you can do like, we're doing that over here.

115
00:07:05,330 --> 00:07:08,000
That's why I set it up right away correctly here.

116
00:07:08,300 --> 00:07:12,440
Everything as far as the name is concerned and where I'm going with this.

117
00:07:12,440 --> 00:07:16,190
Remember, we have this label text so we can simply go with a label text.

118
00:07:16,360 --> 00:07:17,410
What do we want to pass in?

119
00:07:17,750 --> 00:07:22,530
Well, what I want in the label, I think we're going to go with this one last name.

120
00:07:22,610 --> 00:07:25,260
So once I serve, now notice how everything is correct.

121
00:07:25,280 --> 00:07:31,940
And again, this is coming from our global state, from our user object, and all the properties are

122
00:07:31,940 --> 00:07:32,930
located over that.

123
00:07:33,290 --> 00:07:38,180
So then let's do the same thing for email and location.

124
00:07:38,570 --> 00:07:40,280
And I think I'm going to go with email first.

125
00:07:40,580 --> 00:07:42,400
So type in this case will be email.

126
00:07:43,520 --> 00:07:46,880
There's no label text because it's going to be pretty much the same.

127
00:07:47,270 --> 00:07:52,520
So instead of name, I'm going to go with email here and and the value will be also email.

128
00:07:53,000 --> 00:07:56,390
And now I just want to change here the function.

129
00:07:56,660 --> 00:07:57,920
It's not going to be a last name.

130
00:07:58,190 --> 00:07:59,600
It's going to be equal to an email.

131
00:07:59,960 --> 00:08:03,940
And then lastly, let's do the same thing with location.

132
00:08:03,950 --> 00:08:06,770
So type will be equal to what it will be equal to a text.

133
00:08:07,290 --> 00:08:10,040
That name will be equal to creation.

134
00:08:10,960 --> 00:08:16,750
And then lastly, the state now also is going to be here equal to location, and the function that I

135
00:08:16,750 --> 00:08:22,570
want to invoke is also going to be set location, then still inside of the form center.

136
00:08:22,570 --> 00:08:24,940
Do I want to set up my submit button?

137
00:08:25,570 --> 00:08:30,490
And here we will be looking for the class names of beaten and then beaten block.

138
00:08:31,030 --> 00:08:33,309
And then let's add a type of submit.

139
00:08:34,950 --> 00:08:39,659
Type of cement, and then let's disable it if we are in the middle of the request.

140
00:08:40,049 --> 00:08:41,010
Now when is that going to be?

141
00:08:41,070 --> 00:08:47,610
Well, when we're making the request back to our server, so let's say you're disabled and not will

142
00:08:47,610 --> 00:08:50,010
be set equal to you, is loading.

143
00:08:50,160 --> 00:08:53,940
So if the loading is true, then of course the button will be disabled.

144
00:08:54,030 --> 00:08:56,940
And yes, the functionality is still coming up.

145
00:08:57,240 --> 00:09:01,260
So if is loading is true, then what text do I want to display?

146
00:09:01,740 --> 00:09:06,140
In this case, I'm going to go with please and then wait, and I'm or not.

147
00:09:06,150 --> 00:09:12,810
And if we're not loading, then we'll just say save and changes, and we're almost almost done.

148
00:09:13,200 --> 00:09:19,470
We just want to set up the basic functionality where if one of these powers is missing when we display

149
00:09:19,470 --> 00:09:26,820
the alert, if not, then we initialize our issue Typekit request, which at the moment is not in our

150
00:09:27,030 --> 00:09:27,930
update user.

151
00:09:28,170 --> 00:09:29,490
So let's scroll up.

152
00:09:29,910 --> 00:09:31,560
We're looking for the handle.

153
00:09:31,560 --> 00:09:32,610
Submit correct?

154
00:09:32,880 --> 00:09:33,620
Prevent default.

155
00:09:33,630 --> 00:09:33,900
Yep.

156
00:09:34,230 --> 00:09:35,340
All of that is nice.

157
00:09:35,370 --> 00:09:40,800
Now we're just want to go with if and then basically if one of the values is missing, if there's no

158
00:09:40,800 --> 00:09:46,320
name, if there is no email, if there is no last name or.

159
00:09:46,410 --> 00:09:47,820
And then last name.

160
00:09:48,090 --> 00:09:56,430
And if there is no location, so no location, if any of them are missing, then basically we want to

161
00:09:56,430 --> 00:10:00,930
go and display an alert and that's the function we don't pass anything in.

162
00:10:01,230 --> 00:10:05,550
So this is going to be the case where again, we just display that hardcoded one, please provide on

163
00:10:05,550 --> 00:10:06,420
values and all that.

164
00:10:06,750 --> 00:10:08,580
And right after we call display alert.

165
00:10:08,940 --> 00:10:13,210
I also want to go with the return because I don't want to run my update user correct.

166
00:10:13,260 --> 00:10:19,590
And then right on top, I'm going to set up a comment remove while testing, which essentially just

167
00:10:19,590 --> 00:10:20,910
means that outcome.

168
00:10:20,910 --> 00:10:25,290
And this one out, while we're setting everything up again, the goal here is following that.

169
00:10:25,740 --> 00:10:30,030
While we're working on a functionality, there's going to be some instances where I want to showcase

170
00:10:30,270 --> 00:10:35,400
the errors that we're getting back from the server, and I cannot display those errors if I'm already

171
00:10:35,400 --> 00:10:37,960
checking, for example, these values on a frontend.

172
00:10:37,980 --> 00:10:43,650
Yes, eventually we'll do that in both places, but not at the moment.

173
00:10:44,040 --> 00:10:49,910
So let's go here, update and then user and then I want to set up my object where I'm going to go with

174
00:10:49,940 --> 00:10:55,770
name that email last name and I also want to pass in the location.

175
00:10:56,100 --> 00:11:02,100
So I pass all of them in and I'll just take a look so we can navigate to my browser.

176
00:11:03,120 --> 00:11:08,340
No, with Inspect and then if everything is correct, I should see that in a console.

177
00:11:08,360 --> 00:11:13,430
But if I'm going to exclude the last name, you'll notice that will have.

178
00:11:13,700 --> 00:11:20,120
Please provide all values, which means that our functionality works as expected and once everything's

179
00:11:20,120 --> 00:11:25,970
in place, I want to swing back to the profile and temporarily comment this one out.

180
00:11:26,390 --> 00:11:32,180
And once we have all of this in place now, we can start setting up the update user functionality.

