1
00:00:00,080 --> 00:00:00,420
All right.

2
00:00:00,440 --> 00:00:03,740
And the last thing we want to do is to set up the action.

3
00:00:03,740 --> 00:00:10,970
So essentially, once we change the values and we click on submit now, instead of creating the job,

4
00:00:11,000 --> 00:00:13,610
we're going to edit the job.

5
00:00:13,730 --> 00:00:16,280
And for starters, let's just navigate to action.

6
00:00:16,280 --> 00:00:17,950
We're looking for two things.

7
00:00:17,960 --> 00:00:23,930
We want the request because I want, of course, all of the input values and we also want the params.

8
00:00:23,930 --> 00:00:24,460
Why?

9
00:00:24,470 --> 00:00:30,170
Well, because remember, when it comes to edit job, just like with getting a single job, we still

10
00:00:30,170 --> 00:00:31,700
need to pass in those params.

11
00:00:31,700 --> 00:00:32,320
Correct.

12
00:00:32,330 --> 00:00:35,030
So for starters, let's grab the form data.

13
00:00:35,900 --> 00:00:38,060
So this should be equal to a weight.

14
00:00:38,270 --> 00:00:41,420
Then we want to go with request.

15
00:00:42,060 --> 00:00:43,650
Sorry, not redirect.

16
00:00:43,980 --> 00:00:46,260
We're looking for request, then form data.

17
00:00:46,290 --> 00:00:48,300
Then we're going to invoke it.

18
00:00:49,190 --> 00:00:54,980
After that, we're going to set up a new one, a data one, and we're just going to go with Object Dot

19
00:00:54,980 --> 00:00:58,550
and then from entries and then we'll pass in the form data.

20
00:00:58,760 --> 00:01:00,020
Then we want to.

21
00:01:00,780 --> 00:01:02,520
Set up the try and catch.

22
00:01:03,530 --> 00:01:06,800
And for starters, let's just set up a weight.

23
00:01:07,730 --> 00:01:09,590
And again, custom fetch.

24
00:01:09,680 --> 00:01:15,110
And notice how we're not looking for any value because if we're successful, we'll actually go back

25
00:01:15,110 --> 00:01:16,850
to the all jobs page.

26
00:01:16,850 --> 00:01:22,130
So custom fetch then patch request since that's what the server is expecting.

27
00:01:22,130 --> 00:01:26,270
We right away want to go with template string since we'll pass in the ID.

28
00:01:26,690 --> 00:01:28,580
So we'll start here with jobs.

29
00:01:28,670 --> 00:01:32,660
Then let's access the params and then the id.

30
00:01:33,750 --> 00:01:36,700
And after that, we also want to provide the data.

31
00:01:36,750 --> 00:01:41,790
So essentially, this is the new job data that we're getting back from the inputs.

32
00:01:41,880 --> 00:01:46,200
And then if we're successful, let's set up a toast.

33
00:01:46,380 --> 00:01:48,120
We'll say toast, success.

34
00:01:48,150 --> 00:01:50,250
And we're going to go with job.

35
00:01:51,270 --> 00:01:53,280
Edited and successfully.

36
00:01:53,460 --> 00:01:58,740
And also we want to redirect the user so we're going to go back to all jobs again.

37
00:01:58,740 --> 00:02:03,180
There's really no point to stay on this page if everything is correct.

38
00:02:03,180 --> 00:02:07,530
So we're going to go here with Dashboard and Forward Slash and then all jobs.

39
00:02:07,560 --> 00:02:13,170
Now, if there is any kind of issue, for starters, we're going to return the error.

40
00:02:13,170 --> 00:02:16,080
And also we want to set up the toast.

41
00:02:16,080 --> 00:02:16,560
Right?

42
00:02:16,560 --> 00:02:19,110
So let me just copy from the loader.

43
00:02:19,260 --> 00:02:20,940
This is going to be my error.

44
00:02:20,940 --> 00:02:22,830
And now let's try it out.

45
00:02:23,610 --> 00:02:30,090
I'm going to navigate over here and I'll right away actually change the let me see which one, the pending

46
00:02:30,090 --> 00:02:30,270
one.

47
00:02:30,270 --> 00:02:35,910
Basically the job status, just so we can see how different badges look like.

48
00:02:36,030 --> 00:02:42,560
So here, let's change it to interview as far as the company, maybe let's go with Facebook.

49
00:02:42,570 --> 00:02:48,240
Let's submit and check it out since we're successful, job status right now is interview.

50
00:02:48,240 --> 00:02:50,370
And also we changed the company.

51
00:02:50,400 --> 00:02:55,110
Now, of course, if there's going to be some kind of error, then we'll display it also in a toast

52
00:02:55,110 --> 00:02:57,840
and we'll stay on the edit page.

53
00:02:57,840 --> 00:03:02,520
And with this in place, we can start working on delete job functionality.

