Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
embl.org
html-sites
embl-jobs-pages
Commits
96bc25f5
Commit
96bc25f5
authored
May 14, 2021
by
Nitin Jadhav
Browse files
added job filter for EBI iframe
parent
ccfc8767
Pipeline
#155984
passed with stages
in 4 minutes and 30 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
17 deletions
+24
-17
.eslintrc.json
.eslintrc.json
+2
-1
src/components/home/EBIHome.js
src/components/home/EBIHome.js
+1
-1
src/components/home/Home.js
src/components/home/Home.js
+5
-5
src/components/job-list-filters/JobListFilters.jsx
src/components/job-list-filters/JobListFilters.jsx
+8
-8
src/services/useFetchJobsList.js
src/services/useFetchJobsList.js
+8
-2
No files found.
.eslintrc.json
View file @
96bc25f5
...
...
@@ -25,6 +25,7 @@
"no-unused-vars"
:
"warn"
,
"react/react-in-jsx-scope"
:
"off"
,
"react/prop-types"
:
"off"
,
"react/no-unescaped-entities"
:
"off"
"react/no-unescaped-entities"
:
"off"
,
"no-debugger"
:
"warn"
}
}
\ No newline at end of file
src/components/home/EBIHome.js
View file @
96bc25f5
import
{
Home
}
from
"
./Home
"
;
export
function
EBIHome
()
{
return
<
Home
showLocations
=
{
false
}
/>
;
return
<
Home
showLocations
=
{
false
}
jobLocation
=
"
EMBL-EBI Hinxton
"
/>
;
}
src/components/home/Home.js
View file @
96bc25f5
...
...
@@ -4,11 +4,11 @@ import {
JobListFilters
,
}
from
"
components/job-list-filters/JobListFilters
"
;
import
{
JobList
}
from
"
components/job-list/JobList
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useCallback
,
useState
}
from
"
react
"
;
import
{
useFetchJobsList
}
from
"
services/useFetchJobsList
"
;
import
"
./Home.scss
"
;
export
function
Home
({
showLocations
=
true
})
{
export
function
Home
({
showLocations
=
true
,
jobLocation
})
{
const
[
filters
,
setFilters
]
=
useState
(
getInitialFilters
());
const
{
...
...
@@ -17,13 +17,13 @@ export function Home({ showLocations = true }) {
positionJobsCount
,
loading
,
error
,
}
=
useFetchJobsList
(
filters
);
}
=
useFetchJobsList
(
filters
,
jobLocation
);
const
handleSearch
=
(
searchTerm
)
=>
{
setFilters
({
setFilters
((
filters
)
=>
({
...
filters
,
searchTerm
,
});
})
)
;
};
return
(
...
...
src/components/job-list-filters/JobListFilters.jsx
View file @
96bc25f5
...
...
@@ -22,10 +22,10 @@ export function JobListFilters({
// toggle this element in array
let
selectedLocations
=
toggleInArray
(
filters
.
selectedLocations
,
location
);
onFiltersChange
({
onFiltersChange
((
filters
)
=>
({
...
filters
,
selectedLocations
,
});
})
)
;
};
const
handleJobTypeFilterChange
=
(
targetJobTypeKey
)
=>
{
...
...
@@ -35,17 +35,17 @@ export function JobListFilters({
targetJobTypeKey
);
onFiltersChange
({
onFiltersChange
((
filters
)
=>
({
...
filters
,
selectedJobTypes
,
});
})
)
;
};
const
handleClosingDateSortDirectionChange
=
(
selectedClosingDateSortDir
)
=>
{
onFiltersChange
({
onFiltersChange
((
filters
)
=>
({
...
filters
,
selectedClosingDateSortDir
,
});
})
)
;
};
const
handleResetFilters
=
(
event
)
=>
{
...
...
@@ -79,7 +79,7 @@ export function JobListFilters({
htmlFor
=
{
`location-checkbox-
${
index
}
`
}
className
=
"vf-form__label"
>
{
locationTitle
}
(
{
jobCount
}
)
{
locationTitle
}
(
{
jobCount
}
)
</
label
>
</
div
>
)
...
...
@@ -105,7 +105,7 @@ export function JobListFilters({
htmlFor
=
{
`jobtype-checkbox-
${
index
}
`
}
className
=
"vf-form__label"
>
{
positionTitle
}
(
{
jobCount
}
)
{
positionTitle
}
(
{
jobCount
}
)
</
label
>
</
div
>
)
...
...
src/services/useFetchJobsList.js
View file @
96bc25f5
...
...
@@ -4,7 +4,8 @@ import { stripHtml } from "helpers/helpers";
import
{
useFetch
}
from
"
helpers/useFetch
"
;
import
{
locations
,
positionTypes
}
from
"
data/jobs-data.json
"
;
export
function
useFetchJobsList
(
filters
)
{
/* Custom hook for jobs fetching and filtering. If jobLocation is not provided, assume all job locations */
export
function
useFetchJobsList
(
filters
,
jobLocation
)
{
const
{
data
,
loading
,
error
}
=
useFetch
(
"
jobs?_format=json&source=contenthub
"
,
[]
...
...
@@ -18,7 +19,12 @@ export function useFetchJobsList(filters) {
useEffect
(()
=>
{
/* Extend job object with metadata necessary for display and search */
if
(
data
&&
data
.
length
)
{
let
extendedJobs
=
extendJobsObjects
(
data
);
//remove nulls due to potential error while extending
const
dataAtLocation
=
jobLocation
?
data
.
filter
((
datum
)
=>
datum
.
field_jobs_duty_station
.
includes
(
jobLocation
)
)
:
data
;
let
extendedJobs
=
extendJobsObjects
(
dataAtLocation
);
//remove nulls due to potential error while extending
setExtendedJobs
(
extendedJobs
);
//LOCATIONS WITH JOB COUNT: count jobs at each location
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment