Welcome back.
In this video, let's see how we can create a function to register.
So back to the context that is a C component.
And then inside the context and the of context and this is what we want.
So here we are going to create a function for registration.
Before we continue, let's require the action type for register sex and then register field.
So here we go.
Let's require the register sex and then the register field.
Now let's close the action types.
All right.
Right.
So now back here.
So what we are going to do is that we are going to follow the same format for logging in so we can even
copy this one and make some changes.
And that is all.
So here, let's copy this one.
And down here, let's paste it here and let's change this one to register user action.
Great.
And the same thing I'm passing in the config by the end point.
Going to be forced slash register.
Do you remember under API development?
In case you are confused, this the end point.
Let me show you at the back end here and the collections users and then register its forward slash register.
So here we are dispatching what is called register sex.
And down here we add this patch in the.
Register felt.
So I think for logging in let's provide the constant log in field.
Yeah.
And that is it guys and that is it.
So let's send this one to the component as register user action.
The last step is we need to handle the reducer and the same way we did for logging in the same thing
for register also so we can copy from case success and then case field and that is it.
So the register must come first before logging in.
So I'll paste it here and here.
I'm going to make it as register and here is going to be register sex.
And down here is going to be register filled.
I'm not going to look in the user automatically, so I'm going to remove this one from here.
Great.
So here, let's look at it.
State here.
Everything is correct and everything is correct.
Everything is correct.
And for fail to, everything is correct.
Now we are all set.
The last thing is I need to dispatch this action.
So back to the register component.
Make sure that you have the register action.
So after success, I want to redirect the user.
So I will change this one to log in.
And that is it.
Lower case log in.
So let's have a look.
Moment of truth inside the register.
Component forms and register.
So here let's bring the of context and then the use context.
And here we go.
So now inside the register, let's create instance of that.
Let's bring the youth context and they pass in the off context and what comes back.
What I want is the.
Registered user.
Let me check the name again, which is this one.
And I also need the error also.
So I'm going to grab the register action and then the arrow and that is it equal to that.
So inside the submit this word, I'm going to dispatch the action.
So let me bring this one here and down here.
Let me call the register user action and pass in the fourth data, which is my form states.
And that is it, guys.
So let's check it out.
Registration is coming.
Provide this one as cc.
Full name cc and password.
One, two, three, four, five.
Register.
And you can see that it has been heart rate directed.
And if I check the storage, let's see.
Well, there is no talking here because I'm not saving the talking in the storage.
If I log in with see, see, let's see, see, see.
X gmail.com.
Password.
One, two, three, four, five.
And you can see that I have no account being added and that is it.
So what we want to work on is this one, let's see that it is that don't have any accounts, you don't
want to show this one and you want to calculate the total income expenses if the person have an account
as we did for the individual account.
So that is it.
So what has left is about able to create an account, right?
So let's get into that in the next video.