Commit 96bc25f5 authored by Nitin Jadhav's avatar Nitin Jadhav
Browse files

added job filter for EBI iframe

parent ccfc8767
Pipeline #155984 passed with stages
in 4 minutes and 30 seconds
......@@ -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
import { Home } from "./Home";
export function EBIHome() {
return <Home showLocations={false} />;
return <Home showLocations={false} jobLocation="EMBL-EBI Hinxton" />;
}
......@@ -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 (
......
......@@ -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>
)
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment