All right, and once we have the job component in place now, let's start slowly setting up the functionality
for edit and delete.
And I'll start with edit.
And the first thing that we want to do is actually set up a set added job functionality.
Now why do we want to do that?
Well, because we will perform the request from the AJAB, so that is still coming up.
First of all, we want to do is set up the values and as a result will be able to display them in the
job.
So let me showcase how was I going to look like as far as the big picture?
And then, of course, we'll set up Dealogic.
So let me go right now to the components.
And then I'll showcase.
That in the context provider, we have all the values for a job.
So if I keep on scrolling somewhere, there should be a status one.
And I mean, there's more properties in here, so it's going to be probably hard to see.
But the idea is that once we click on edit notice, how we're changing these powers.
So I change here at a job, the job location as well as the type and we navigate over here.
So the first thing that we want to set up is actually those values in the state, and then we'll worry
about performing the request when we add the jump in the actual database.
Hopefully, it makes sense.
First, let's start by setting up the action so set at a job that incentive our function, the set at
a job.
We're looking for that.
We want to dispatch the action.
And as far as the payload will pass in the R.D, now we'll also write or set up at a job and you'll
see by the end of video why you want to do that again.
This is just going to be a placeholder function for now, but eventually we will use it.
And not in the reducer.
If the action is set at a job first, I want to grab the job based on the idea.
So I have the jobs already in the state, correct?
So in the reducer, I'm going to go with state jobs and then find.
And then I'll look for a job whose I.D. matches the one that's coming in with my argument, and that's
where iterating over the jobs that are in our state.
I mean, the job has to be there.
So we get back the job and then we pull out these values that re the position and all that and when
we update.
So then I say, Yeah, I'm actually editing.
So we set this one to a event at a job idea is going to be equal to that and then position company and
the rest of them.
And eventually, since we have already a ajob, we'll also grab the at a jump and then remember if we're
editing, which is the case here now where we're going with editing true, then we'll invoke at a job.
And then of course, we'll have to set up the request and all that.
Hopefully, it is clear what we're about to do.
So let's start first in the actions where again?
Copy and paste.
And then let's set up those two cursor here.
And as far as my name for the action, I'm going to go set at a job.
So let's do that and we're going to go set at it and jab and serve it as far as the import.
Well, in this case, I think I'm going to copy here and we're looking for the context.
Here, let's copy and paste and let's navigate down.
And that's not what I wanted.
So let me navigate down over here.
And we're looking for already set at a job.
We're going to be getting dirty.
So now this patch, that action.
Let's say this patch, the type will be set at a job.
And as far as the payload, we're going to pass in my handy.
Now, let's go to the producer.
Then let's go up.
And we're looking for a reset at a job, and let's not ever get down and land in here and let's go if
action and then not type is equal to set at a job.
Like I said first, we want to grab the job out of the jobs that we have in the states.
A cost is equal to marriage.
Located in the state, then jobs and then find.
So that's the method we can use on the array.
And here I'm just going to say if the job.
It matches to that I'm passing in.
Then, of course, get me back the job, so I'm going to go with the job on the security.
That's the proper name.
And if that is equal to action, then payload and the I.D..
And once I have the job, let me pull out the values.
So I'm going to go with concert and then on the security.
Then I also want to get the position company.
The job, location, location, location and we want to go job.
Type that out, we want to go in status, and all of that is equal to the job.
So that's what we pull out and then let's update the state where we're going to go with return.
That's not and then state.
And the first thing that we want to set up is everything true.
So now we're editing.
And therefore, in the ad job, we'll right away flip those values where instead of our job, we'll
have had a job.
And remember, we'll navigate there because we have the link, correct?
So we're going to go with his editing now that is said equal to true.
And we're going to go with edit job.
And also that one equal to the ad that we have over here.
So that is equal to the idea that we want to go with position, company, job, location, basically
all of these values and not spirits up, I can just grab them and copy and paste.
So now all of my state vows will be equal to whatever I have in this job.
And as a result, when we navigate to our jobs since we are using them as the initial value for our
input, there will be right away display.
So we have our logic.
Awesome.
So now let's just start out by setting up the function in the context, the placeholder one.
And I think I'm going to do that before daily job, when I'm going to go with concept and then edit
job.
So that's my function.
And here, let's just go with console.log.
I'll just say here added job.
Now you're probably wondering, OK, but why are we not grabbing some values since we will invoke this
in our AJOB function?
Remember, all our values are in this state, and this again emphasizes something that I already mentioned.
Normally, all of these values our most likely set up in the ad job page, let's say if I'm just performing
a fetch request to add jobs to the database.
But since in this case, I wanted to combine both functionality where we can also edit.
That's why I set them up instead, because keep in mind.
We are setting those logs from two different pages.
So there has to be some kind of way how we can communicate.
That's why they are state voters going to let me repeat.
Normally, if that's not the case, I would simply set them up in the ajob and I would just forget about
it.
Hopefully that makes sense.
And let me go right now and actually import this one, meaning I've added to the value and here I'm
going to go with added job, so not at a job if you are looking for at a job.
And now let's navigate through the ad one very ad job page of refine its pages.
Then we're looking for a dashboard one.
And then we want to have the ad job one.
And remember.
In here, what happens?
Well, we grab all of these things from the state, and there's one more thing we want to add.
So we already have is editing.
That's why you married me.
I just pretty much showcased that.
Yes, you should grab the editing if it's not there, but it should be already there.
So we're editing.
And I also want to get the added job.
So let me take this one.
So I'm going to go with edit and then jump and then remember where we have the handles submit if we
are editing, which at the moment we're changing in a state.
Correct?
What do we want to call?
Well, eventually you want to call out a job.
So let me just come on this one and remove this eventually.
So now, since we're changing that state value instead of creating the job we should see in the council
edit job.
So let's try it out.
We're going to navigate to your my application and I will showcase how we're changing stuff instead,
because maybe it was hard to see since there were so many states of ours already in the complete one.
So let me take a look at the provider.
And at the moment, what are the values here?
Well, is that it is false and a job empty, position empty, and we have some default ones for select
buyers.
OK.
So that kind of makes sense.
Now, once I click on Edit, I should update my status.
And then as a result in the Ajob, two things should be there.
First of all, it should be is editing, meaning we should have the text of editing job.
That's number one, and all the values should be already filled.
Why?
Because they're coming from the state and the moment we click, we should update this stuff out.
So let's try it out.
And I successfully navigate here, but it looks like I didn't update any values.
Hmm.
So before I start running around like I had less chicken, let me try one more time by just refreshing,
because that sometimes is the case with me.
Go back.
I'm not going to give you the whole speech again.
I just open everything.
I will try with the same value just to showcase that.
And now everything works.
We do have the added gem in the add job page and check it out.
Estate values are filled out.
We are editing the added job position and all that.
And again, the case is that the moment I'll click the segment now will edit the job and the reason
why we're not passing anything into the added job function simply because we'll grab those values right
from the state anyway.
So they already located over here.
So when we'll set up the request, well, they'll all be available.
So let's try it out.
I'll click on submit notice.
Right now, we have had a jump.
And then one last thing that I want to mention in this video.
Remember, we also have clear functionality, and if you remember in the reducer, we pretty much set
everything back to the default.
And since I want to showcase that notice the moment I click clear now, I'm not adding the added job
is clean and the same goes for position and a company.
We still have default ones for the pending and full time, and this is coming as our location from the
user.
But hopefully this makes sense where that's the reason why, with clear, we pretty much took everything
back to the start since I don't want this is editing lingering around when the user actually decides
to clear the form.
And with this in place now, we can start setting up edit job functionality on the server and then eventually
implement in the front as well.