All right.
And the last thing we want to do is to set up the action.
So essentially, once we change the values and we click on submit now, instead of creating the job,
we're going to edit the job.
And for starters, let's just navigate to action.
We're looking for two things.
We want the request because I want, of course, all of the input values and we also want the params.
Why?
Well, because remember, when it comes to edit job, just like with getting a single job, we still
need to pass in those params.
Correct.
So for starters, let's grab the form data.
So this should be equal to a weight.
Then we want to go with request.
Sorry, not redirect.
We're looking for request, then form data.
Then we're going to invoke it.
After that, we're going to set up a new one, a data one, and we're just going to go with Object Dot
and then from entries and then we'll pass in the form data.
Then we want to.
Set up the try and catch.
And for starters, let's just set up a weight.
And again, custom fetch.
And notice how we're not looking for any value because if we're successful, we'll actually go back
to the all jobs page.
So custom fetch then patch request since that's what the server is expecting.
We right away want to go with template string since we'll pass in the ID.
So we'll start here with jobs.
Then let's access the params and then the id.
And after that, we also want to provide the data.
So essentially, this is the new job data that we're getting back from the inputs.
And then if we're successful, let's set up a toast.
We'll say toast, success.
And we're going to go with job.
Edited and successfully.
And also we want to redirect the user so we're going to go back to all jobs again.
There's really no point to stay on this page if everything is correct.
So we're going to go here with Dashboard and Forward Slash and then all jobs.
Now, if there is any kind of issue, for starters, we're going to return the error.
And also we want to set up the toast.
Right?
So let me just copy from the loader.
This is going to be my error.
And now let's try it out.
I'm going to navigate over here and I'll right away actually change the let me see which one, the pending
one.
Basically the job status, just so we can see how different badges look like.
So here, let's change it to interview as far as the company, maybe let's go with Facebook.
Let's submit and check it out since we're successful, job status right now is interview.
And also we changed the company.
Now, of course, if there's going to be some kind of error, then we'll display it also in a toast
and we'll stay on the edit page.
And with this in place, we can start working on delete job functionality.