And once we have both the added job as well as the lead job functionalities on the server.
Well, let's implement them on the frontline because at the moment have the buttons and I can clearly
see that I'm getting the the job as well as the idea.
And the same goes for the added one, where we navigate Julie and John Page, but I mean, there's not
much more functionality.
And the way it's going to look like if we go to the read me or say the first thing, we want to create
the action and yes, I'll start with delete because it's going to be a bit more straightforward and
the action name will be delete and jump again.
And yes, I'll talk about it.
Well, why don't we have the success as well as the Iran one in the context where I have the function?
First, I want to start with the lead job again, and it's probably not going to be the surprise that
when it comes to begin one, we'll just start with loading.
So I want to display that loading spinner since we'll set up the request, then we want to go with a
wait and notice how we're not getting any data back because again, when it comes to deletion, I mean,
we're really not looking for any data.
We just want to know whether it worked or not.
So if we're successful, we'll keep reading the code effectively, will invoke, get jobs and I'll talk
about it in a second.
If not, then we'll go to the error.
So therefore, we're not looking for any data not assigning it to any variable or nothing like that.
I just go off fetch.
Now the method is delete, because that is what the server is looking for.
And then what is the path?
It is jobs.
And then I grabbed a job I.T..
That's why we were passing this in.
Now why we need get jobs.
Well, when I'm declining.
I'm not deleting from the local state.
The one that I have here in the components where I'm deleting the jobs from, from the database.
So I don't want this to be out of sync.
So essentially, once I believe the job on a database, I actually want to make another request where
I get the latest jobs and therefore we go here, we get jobs function, which we already have in context.
Hopefully that makes sense because that's the function we invoke once we navigate to the old jobs.
Now, when it comes to error again, we don't have here any kind of alert.
So I didn't really see the point of updating the alert if there is an error, if I'm not showcasing
the alert.
What is really the point?
And again, it comes down to the fact what do you want to do if you have 500 or let's say, 401?
Again, we're handling 401 already here with the interceptor, but in my opinion, there's really no
point to, I don't know, showed the alert with 500 error, in my opinion.
Then we might as well rather log out the user and then I'll come on this one and why we're working because
it can get a little bit annoying if you're get logged out while you're testing stuff.
But eventually, yes, this will be in place.
And therefore we only have the lead job again because there's no success message.
And there's also no error message.
So let's start working on that.
And I guess I'm going to go first to the actions.
And we want to go with that, the lead up again.
So let me copy and paste this sucker over here, and I'm going to go with my two cursors and let's just
go with delete, delete, underscore job and begin.
Save it.
Let's start, I guess, you know, introducer, there's going to be less code there.
So we're just going to go here with delete and job again.
Then we want to check here for the condition.
So say here, if action type is equal to an important delete job and begin, I'm like, I said, we
simply want to set up that loading one, since there's going to be a request.
I mean, we might as well display the loading spinner.
So we're going to go with that, not state.
And then we want to pass and is loading and set that one equal to true one.
We want to save here.
So let's save everything, and my mistake actually closed the file, that's OK.
And in the app context, let's also right away grab that lead jump.
So the lead job say that I want and not.
Let's look for our functionality where we have the job.
Like I said, work in the a job for the time being.
I just want to show that we have to get jobs.
So this is where we'll add a little bit more functionality eventually.
Meaning there's going to be more stuff in here on top when we're setting up the URL.
But the idea is that we just get all the jobs from the database.
And that's why when we remove the job, we want to get back the latest jobs that we have in the mango.
Hopefully, that makes sense on first, like I said, go dispatch, then we want to go with type now,
be equal to the elite job again, then we want to go and try catch on this point.
I think I can remove the console because I'm pretty sure that we already know what's in there.
So that's the job.
Then let's go with a white one off patch since we want to get that base URL as well as the interceptors
and then delete.
And now we're going to have to go with a temperature check.
Because we're going to go to jobs going forward, slash and specifically.
So job, Heidi over here.
And of course, in here, I didn't name this as drama, so I may just change around the parameter.
And let's say that that is a already.
I think it's a bit more explicit.
And then, like I said, once we're successful, we want to go get jobs.
So we want to invoke this function, get back to latest jobs.
And for time being, I'll do two things a log error and a response just in case there is one.
And then I'll go with a log out user and I'll invoke it, but I'll come on this one up again.
I will make sure that all of them are in place once we're ready to go to production.
And if for some reason I forget about that, please remind me.
And here's the thing.
We already have the function.
That was the whole point why we're setting up that placeholder.
We already have a dashboard where we have all jobs.
The daily job functions are in place.
Now, of course, that is in the jobs container.
If I take a look at the single job, I will see that I'm looking for my delete job right here.
That's the function that I'm working for.
So now I can simply test that out where I have five jobs, which matches exactly what we completed in
the previous video.
Remember, we deleted one job, so now let's just try out.
We had some jobs here or something.
Something is going to go.
And, you know, it looks like I'll have to refresh, and here it complains that we have a weight on
you.
Of course.
Let me navigate back to my amp context and I messed it up a little bit.
Where this one should be, I think probably should have set it up right away from the get go.
Now let me serve it, and I'll let me try one more time where we're going to go with something, something.
And what do you know?
I don't have any more of that job in a database.
Now I have only four of them, and you can probably already guess that if I'm going to keep on removing
the jobs, then I'll be removing them from the database and will be performing those fetch requests
to get the latest jobs.
And with this in place, we have completed the delete job functionality.