1
00:00:00,050 --> 00:00:00,410
All right.

2
00:00:00,410 --> 00:00:03,150
And I guess let's just start by setting up the loader.

3
00:00:03,170 --> 00:00:06,900
So effectively, what do we want to do once we navigate to this page?

4
00:00:06,920 --> 00:00:12,290
Well, we want to make a request and get the info on that specific job.

5
00:00:12,290 --> 00:00:12,620
Correct.

6
00:00:12,620 --> 00:00:18,080
So we're going to set up, try and catch I know I'm going to be getting back the data, basically an

7
00:00:18,080 --> 00:00:21,500
object with the data property and that job is going to be there.

8
00:00:21,530 --> 00:00:25,460
Then we're going to go with Await, then custom fetch Dot.

9
00:00:26,200 --> 00:00:27,760
Then we're going to go with get.

10
00:00:27,760 --> 00:00:32,980
But this is the case where we want to go with template strings and we're going to go to jobs and then

11
00:00:32,980 --> 00:00:39,010
specific job ID and in order to access it, since I have a template string, I'm going to go here with

12
00:00:39,010 --> 00:00:45,730
dollar sign, then curlies and then remember it's located in the params and I named my params the id.

13
00:00:46,590 --> 00:00:50,280
And if I'm successful, I simply want to return the data.

14
00:00:50,490 --> 00:00:53,190
And the job, of course, is going to be located over there.

15
00:00:53,370 --> 00:00:55,200
Now, what about the error?

16
00:00:55,350 --> 00:00:58,590
If let's say the ID is wrong, what do we want to do?

17
00:00:58,620 --> 00:01:02,520
Well, for starters, we want to go here with toast, with an error.

18
00:01:03,090 --> 00:01:05,280
And let's provide again that error.

19
00:01:06,340 --> 00:01:08,080
Question mark, dot.

20
00:01:08,320 --> 00:01:11,080
And we're looking for response question mark.

21
00:01:11,840 --> 00:01:13,850
That and then data.

22
00:01:14,730 --> 00:01:19,050
And then we're again looking for the message over here.

23
00:01:19,200 --> 00:01:25,770
And also, I want to navigate back to the all jobs, because there's really no need to stay on this

24
00:01:25,770 --> 00:01:28,610
page if there's something wrong with the request.

25
00:01:28,620 --> 00:01:34,860
So if I cannot get the data on that specific job, there's really no point to hang out on this page.

26
00:01:34,860 --> 00:01:37,520
And therefore I'm going to go with return redirect.

27
00:01:38,500 --> 00:01:41,310
And here let's pass in the path.

28
00:01:41,320 --> 00:01:47,640
So I want to go back to Dashboard, then forward slash and then all jobs.

29
00:01:47,650 --> 00:01:48,670
Let's save it.

30
00:01:48,670 --> 00:01:53,860
And if everything is correct, then of course in the edit job, I want to access that job.

31
00:01:53,980 --> 00:01:58,690
Like I said, this was just for demonstration purposes, so I'm going to remove this.

32
00:01:58,690 --> 00:02:05,320
And since the job is going to be located in that data, I'm going to go with job and then use loader

33
00:02:05,320 --> 00:02:05,980
data.

34
00:02:06,190 --> 00:02:13,240
Let's set up the log for now and if everything is correct, we should see info on that specific job.

35
00:02:13,240 --> 00:02:14,590
So let me refresh again.

36
00:02:15,600 --> 00:02:16,860
Let me inspect.

37
00:02:17,560 --> 00:02:18,370
And in the console.

38
00:02:18,370 --> 00:02:22,250
I should see the object with all of the info.

39
00:02:22,270 --> 00:02:27,760
Now, of course, if I'm going to go back to all jobs and if I'm going to take a look at the other one.

40
00:02:27,760 --> 00:02:33,580
So this one over here, I believe, then of course, I'll have the info on this specific job.

41
00:02:33,610 --> 00:02:39,520
Now, if I'm going to mess with the ID, for example, I'll pass something that doesn't make sense.

42
00:02:39,550 --> 00:02:45,430
Notice I'll nicely display the post for the error, but again, we're going to navigate back to all

43
00:02:45,430 --> 00:02:46,030
jobs.

44
00:02:46,060 --> 00:02:52,720
There's really no point to hang out on the edit job page, and with this in place we're done with the

45
00:02:52,720 --> 00:02:54,080
loader functionality.

46
00:02:54,100 --> 00:02:56,320
In edit Job page.

