All right.
Up next, we have job status as well as the job type.
And the setup is going to be extremely similar to the search.
Now, of course, we're not going to use regex, but the main idea is going to be the same.
Again, we want to pull out those parameters out of the req dot query and we want to inject both of
them in our filter object.
But please keep in mind that for job status and job type, we can have the value of all.
Essentially I'm saying, hey, listen, get me all of the jobs regardless of the job status and job
type.
But if we'll search for the jobs where the job status is equal to all, we'll see that again.
We get back empty array.
So let's try it out.
For starters, let's just navigate to our Thunder client.
Let's write job status and we're going to go here with pending.
So that should work.
Then back in the job controller.
We wanted the structure.
So say here job status.
And yes, we'll set up the condition in the second, but.
Let's just see what we get back.
If I just hardcode, I'll say job status is equal to the job status.
And actually, since the names are the same, I can just do it this way.
Let me send.
And if I take a look, I'll get back all the jobs where the status is pending.
And you can probably already guess that the same deal is going to be for the client and interview.
But here's the kicker again.
If we go here with all there are no jobs where the status is equal to all.
So for both of them, for job status and job type, we want to set up two conditions.
So let's go over here with job type.
And for now, also let's provide all.
Then let's navigate back to job controller.
Let's destructure it.
So I'm going to go with job type.
And instead of hard coding and setting it right away in the query object, we'll set up two conditions.
So we'll say if there is some kind of value and if it's not equal to all, then add it to an object.
So again, we want to do it above the find since this is where we are using those values and it doesn't
really matter whether you place it before or after the search, but in my case, I'll do it after and
I'll say if and then we're looking for job status.
So if it exists, maybe for some reason I'm getting an empty value.
And if it's not equal to all only then I want to add it.
So right over here, my condition, and then I'm going to look for my query object and I'll set my job.
Status is equal to a job status.
Now.
Now I want to do the same thing for the job type.
So let me.
Select all of them over here and let me type job type as well.
And now let's navigate back to all jobs.
If we send basically, we'll get back all of the jobs.
But if, for example, I'm going to go here with declined, of course now I'll have these values as
far as job status.
Now I can also change this one.
The job type, I can set it equal to full time, for example.
So now we'll get back jobs where status is declined and job type is full time.
Now if we change any of them or both of them to all, then basically we'll get back jobs regardless
of one or both of those values.
Hopefully that is clear.
And up next, we're going to work on the Sort functionality.