All right.
And once we're done with submit BTN functionality.
Now let's set up a test user.
So essentially I want to create a functionality where someone can come to the application and take it
for a test drive without creating the account.
Now of course you can use whichever values you feel comfortable with.
Just make sure that you remember them because we'll have to use them on the front end.
But if you're interested, you'll find some options that I generated with ChatGPT in the Readme.
And in my case, I'm going to go with this one.
Now, of course we can use the front end in order to create that user, but I think in order to speed
this up, I'll go with Thunderclan.
So author Routes Register User.
And essentially I just want to use these values.
So name is going to be Zippy.
Then I have test at Test.com, then secret one, two, three, last name, shake and bake and the location
is going to be a code wheel.
So we create the user.
That's awesome.
Now we want to go to a front end and effectively remember where we have that Explore the app button.
Once we click the button, we want to send a request to login the user.
So let's try that one out.
We're going to go to client source then.
We're looking for two pages.
More specifically, a login one.
And then, like I said, we have here this explore the app button.
So now in the component I want to set up the functionality where once we click on a button, we send
a request to a login one and of course we provide the correct values.
So in my case test that this.com and then secret one, two, three.
Now since in this case we're going to navigate in the actual function.
We'll also need to use, use, navigate instead of the redirect.
So again, when we're talking about redirect, we're using it in the action or in the loader.
But when it comes to the component we want to use navigate.
So for starters, let's create the instance.
I'm going to call this navigate.
And let's set it equal to use.
Navigate.
Let's invoke that.
I believe I'm importing that.
Yep, that's correct.
And now let's set up the function.
In my case, I'm going to call this login demo or test user.
It's going to be async function.
And inside of it we'll set up the try and catch.
Now above the try block, let's create the data.
So this is what we're going to be sending.
And remember, when it comes to login, what are the two values that we want to provide?
The email and a password?
Correct?
So I'll set up here an object.
First value will be email test at test.com.
And again, they need to match whatever you set up over here, otherwise it's not going to make sense.
And then the second one will be password.
Now if you're wondering how safe it is to set it up on the front end, well, keep in mind that in following
video, we'll restrict access to this demo user so this user can view the application only so he won't
be able to delete the job or mess with the profile or anything like that.
So let's set up over here proper password in my case, secret.
One, two, three.
So I have my data in place and then we pretty much want to repeat the logic.
So again, it's going to be custom fetch post and we'll provide data over here.
If we're successful, we want to set up post and if there is an error, same deal we'll have post and
error.
Now here's the gotcha again.
We don't want to use redirect.
We want to use navigate.
So in order to speed this up, let me take these lines of code again.
Same deal custom fetch post to a login one.
This doesn't change if we're successful.
Maybe let's change the message.
Let's say take a test drive or test the application, whatever you feel like it.
And then as far as navigate, we want to invoke it and then forward slash and then dashboard.
Now if there is an error, let's scroll up, let's select this and then let's pass it in the catch block.
Let's save it here and then where we have the button.
We want to set up the on click and we want to set it equal to login demo user.
And now let's navigate to the front end.
I'll log out.
And then click on the login page.
And essentially once I click on Explore the app, I'm able to access my application as the test user.