All right.
And once we have the functionality in place on the backend.
Now let's start patching those that's on the frontend.
First, we want to set up the actions in this case.
Again, we'll go with begin and success because we do want to pass the data to the state.
But if again, we have we're a one or 500 or right away log out the user.
I'm not going to repeat why that is my preference.
We also want to add stats and monthly applications in the initial state.
So don't forget about that when we'll create a show starts function.
This is where we'll set up the loading.
We'll go with a weight off fetch and remember, if we don't pass any method, then automatically, this
is Geth, and that's where I will go here with jobs and stats.
So that's the root run.
If everything is correct, we want to go with dispatch and show that success as far as the payload,
passing stats and monthly applications.
And you can probably already guess that in the reduced year, we'll just set those values in the state.
Now, if there is an error for time being, log it and eventually I'll have log out the user and eventually
it will clearly alert just in case you have some kind of setup where the alert is present again, in
our case, it's not going to be the case, and fact will also make sure that we hide the alert once
we start loading.
But again, you might have a different set up where there is an alert, so it's a good case to always
hide it.
So go ahead with clear alert, which in this case is optional.
I will pass in the value the show starts and not in the reducer show stats begin.
We set up the loading and not as far as the success we go with stats, monthly applications and not
as equal to action, payload and both of those failures.
So let's navigate to the client.
I guess let's start by setting up everything in the actions.
So I'll start with show starts begin as well as the success one.
So let me comment this one where I'm sorry, let me copy this one, and let's move it down a little
bit.
Select both of them over here, and let's go to show start.
And let's set it up as begin.
Copy and paste.
And this won't be a success, one of responded correctly.
So now let's set up the imports.
I think I'm going to go with apt context first.
So when I would here.
And right after at a job, let's copy and paste this one, and then we'll go with success.
Then let's also right away set up those two things in a state.
So that's going to be our default one starts.
And then we also want monthly applications, which will stay as our monthly applications.
And this will be set to an empty array.
And let's keep on scrolling.
Navigate here.
And then let's set up that show starts one.
So let's go with Khan's show.
What's the function?
Let's remember to set it up as a sink.
All right away at it or here, just in case I forgot to do that later.
So show starts beautiful.
And then as far as the functionality.
Let's start by dispatching the begin one.
So type will be equal to show stats and not success.
We're actually looking for again and then try and catch.
And let's right away clear of values, because I might forget about that as well.
And then let's go.
Here it comes.
Data is equal to.
And we're going to go with a weight.
Like I said, we have another option here where effectively, if we go with off fashion, I know that
it is a get request.
I can omit the get one.
You can always add it.
But if you don't have it, then by default it's going to be a get request went as far as the URL.
Well, we go with API version one, which is already set up in the north, which has a base value.
The base URL go here with jobs and then stats or that's the round.
Awesome.
And knowledge dispatch it.
So first, let's set up our type, not begin.
Say it's always recommending the other one.
So we'll go here with payload and as far as the payload is going to be an object and then we go, it
starts.
That is equal to data.
And as you can see, in this case, I'm not structuring it.
I just think that it's easier.
Remember, this is defaults.
That's not stats and the comma and we're going to go with the monthly applications is equal to data
and then monthly applications.
So that is going to be exactly the same thing.
Let's save it for now where we have the catch that's logged temporarily both error.
And a response.
And then finally, that's also the log out user for the time being, I'll just comment this one out
with this in place.
Now again, let me navigate it up.
I'll grab both of them right away the success and begin.
And back in the user, I'm sorry, reducer.
I want to go here.
Both of them.
Copy and paste one.
Let's navigate down where we have the error, and I'll set up the functionality where again, we'll
have begin, where we hide the alert and set up the loading and then show that's success.
So let me see.
I think we're going to go over here.
I'm going to grab these runs now, but it's going to be some changes.
But a lot of the things that are going to be exactly the same.
Copy and paste action type.
It's not going to be edit job again.
We're going to go with our show and then stance begin is loading true again?
Optionally, I'll add this show alert and false just in case.
And then also where I have the success one, we want to make some changes where the type will be show
that success is loading will be false, but we're not going to be displaying any kind of alert.
We're just going to go here would start an action payload and then stats and the same thing we want
to do with monthly application.
This is going to be a doozy for me to spell some monthly applications here, not as equal to stats,
worms or action, action, payload, payload and monthly applications.
Now we're not going to invoke it because I want to do that in the actual stats page.
And since we don't have it right now, I really don't see the point of setting up the use effect and
all that stuff.
So in the next video, we will set up some basics as far as our stats, and that's when we will invoke
it.