Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENT-7234: Filter jobs based on job source attribute. #786

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/my-career/SearchJobRole.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform/config';
import { logError } from '@edx/frontend-platform/logging';
import { InstantSearch } from 'react-instantsearch-dom';
import { Configure, InstantSearch } from 'react-instantsearch-dom';
import { SearchContext, deleteRefinementAction } from '@edx/frontend-enterprise-catalog-search';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import FacetListRefinement from '@edx/frontend-enterprise-catalog-search/FacetListRefinement';
import { camelCaseObject } from '@edx/frontend-platform/utils';
import {
Button, Form, StatefulButton,
} from '@edx/paragon';
import { CURRENT_JOB_FACET } from '../skills-quiz/constants';
import { CURRENT_JOB_FACET, JOB_FILTERS } from '../skills-quiz/constants';
import { patchProfile, fetchJobDetailsFromAlgolia } from './data/service';
import { CURRENT_JOB_PROFILE_FIELD_NAME, SAVE_BUTTON_LABELS } from './data/constants';
import { useAlgoliaSearch } from '../../utils/hooks';
Expand Down Expand Up @@ -38,7 +38,7 @@

const getButtonState = () => {
if (requestError) {
return 'error';

Check warning on line 41 in src/components/my-career/SearchJobRole.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/my-career/SearchJobRole.jsx#L41

Added line #L41 was not covered by tests
}
if (requestComplete) {
return 'complete';
Expand All @@ -62,9 +62,9 @@
try {
resp = await patchProfile(username, params);
} catch (error) {
setLoadingRequest(false);
setRequestError(true);
logError(new Error(error));

Check warning on line 67 in src/components/my-career/SearchJobRole.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/my-career/SearchJobRole.jsx#L65-L67

Added lines #L65 - L67 were not covered by tests
}
setRequestComplete(true);
setLoadingRequest(false);
Expand All @@ -90,6 +90,10 @@
searchClient={searchClient}
>
<p> Search for your job role </p>
<Configure
facetingAfterDistinct
filters={JOB_FILTERS.JOB_SOURCE_COURSE_SKILL}
/>
<FacetListRefinement
id="current-job-dropdown"
key={attribute}
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const useDefaultSearchFilters = ({
return getCatalogString(searchCatalogs);
}

// If the learner is not confined to certain catalogs, scope to all of the enterprise's catalogs
// If the learner is not confined to certain catalogs, scope to all of enterprise's catalogs
return `enterprise_customer_uuids:${enterpriseConfig.uuid}`;
},
[enterpriseConfig.uuid, searchCatalogs, showAllRefinement],
Expand Down
2 changes: 2 additions & 0 deletions src/components/skills-quiz/SearchJobCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SearchContext } from '@edx/frontend-enterprise-catalog-search';
import { SkillsContext } from './SkillsContextProvider';
import { SET_KEY_VALUE } from './data/constants';
import JobCardComponent from './JobCardComponent';
import { JOB_FILTERS } from './constants';

const SearchJobCard = ({ index }) => {
const { refinements } = useContext(SearchContext);
Expand Down Expand Up @@ -37,6 +38,7 @@ const SearchJobCard = ({ index }) => {
async function fetchJobs() {
setIsLoading(true);
const { hits } = await index.search('', {
filters: JOB_FILTERS.JOB_SOURCE_COURSE_SKILL,
facetFilters: [
jobsToFetch,
],
Expand Down
7 changes: 6 additions & 1 deletion src/components/skills-quiz/SkillsQuizStepper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Button, Stepper, ModalDialog, Container, Form, Stack,
} from '@edx/paragon';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-dom';
import { Configure, InstantSearch } from 'react-instantsearch-dom';
import { getConfig } from '@edx/frontend-platform/config';
import { SearchContext } from '@edx/frontend-enterprise-catalog-search';
import { useHistory } from 'react-router-dom';
Expand Down Expand Up @@ -33,6 +33,7 @@ import {
STEP3,
SKILLS_QUIZ_SEARCH_PAGE_MESSAGE,
GOAL_DROPDOWN_DEFAULT_OPTION,
JOB_FILTERS,
} from './constants';
import { SkillsContext } from './SkillsContextProvider';
import { SET_KEY_VALUE } from './data/constants';
Expand Down Expand Up @@ -199,6 +200,10 @@ const SkillsQuizStepper = () => {
indexName={config.ALGOLIA_INDEX_NAME_JOBS}
searchClient={searchClient}
>
<Configure
facetingAfterDistinct
filters={JOB_FILTERS.JOB_SOURCE_COURSE_SKILL}
/>
<div className="mt-4.5">
Second, which industry describes where you work? (select one, or leave blank)
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/components/skills-quiz/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ export const HITS_PER_PAGE = 500;
export const LOADING_NO_OF_CARDS = 9;

export const JOB_DESCRIPTION_DISCLAIMER = 'This job description has been created by an artificial intelligence, and should be reviewed carefully.';

export const JOB_SOURCE_COURSE_SKILL = 'course_skill';
export const JOB_SOURCE_INDUSTRY = 'industry';

export const JOB_FILTERS = {
JOB_SOURCE_COURSE_SKILL: `job_sources:${JOB_SOURCE_COURSE_SKILL}`,
JOB_SOURCE_INDUSTRY: `job_sources:${JOB_SOURCE_INDUSTRY}`,
};
Loading