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

feat: added dropdowns for v2 #815

Open
wants to merge 1 commit into
base: zafzal/ENT7364
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions src/components/skills-quiz-v2/AutoSuggestDropDown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
Form,
} from '@edx/paragon';
import React, { useState } from 'react';

const AutoSuggestDropDown = () => {
const [selected, setSelected] = useState('');

Check warning on line 7 in src/components/skills-quiz-v2/AutoSuggestDropDown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/AutoSuggestDropDown.jsx#L7

Added line #L7 was not covered by tests

return (

Check warning on line 9 in src/components/skills-quiz-v2/AutoSuggestDropDown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/AutoSuggestDropDown.jsx#L9

Added line #L9 was not covered by tests
<Form.Autosuggest
aria-label="form autosuggest"
value={selected}
onSelected={(value) => setSelected(value)}
>
<Form.AutosuggestOption>JavaScript</Form.AutosuggestOption>
<Form.AutosuggestOption>Python</Form.AutosuggestOption>
<Form.AutosuggestOption>Excel</Form.AutosuggestOption>

Check warning on line 17 in src/components/skills-quiz-v2/AutoSuggestDropDown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/AutoSuggestDropDown.jsx#L13-L17

Added lines #L13 - L17 were not covered by tests
<Form.AutosuggestOption>React</Form.AutosuggestOption>
<Form.AutosuggestOption>Rube</Form.AutosuggestOption>
</Form.Autosuggest>
);
};

export default AutoSuggestDropDown;
41 changes: 41 additions & 0 deletions src/components/skills-quiz-v2/GoalDropdown.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useContext } from 'react';
import { Form } from '@edx/paragon';
import {
DROPDOWN_OPTION_CHANGE_CAREERS,
DROPDOWN_OPTION_IMPROVE_CURRENT_ROLE,
DROPDOWN_OPTION_GET_PROMOTED,
DROPDOWN_OPTION_OTHER,
GOAL_DROPDOWN_DEFAULT_OPTION,
} from '../skills-quiz/constants';
import { SET_KEY_VALUE } from '../skills-quiz/data/constants';
import { SkillsContext } from '../skills-quiz/SkillsContextProvider';

const GoalDropdown = () => {
const { dispatch, state } = useContext(SkillsContext);
const { goal } = state;
const handleGoalChange = (e) => {
dispatch({ type: SET_KEY_VALUE, key: 'goal', value: e?.target?.value });
};
const gaolDropdownOptions = [

Check warning on line 19 in src/components/skills-quiz-v2/GoalDropdown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/GoalDropdown.jsx#L19

Added line #L19 was not covered by tests
GOAL_DROPDOWN_DEFAULT_OPTION,
DROPDOWN_OPTION_CHANGE_CAREERS,
DROPDOWN_OPTION_GET_PROMOTED,
DROPDOWN_OPTION_IMPROVE_CURRENT_ROLE,
DROPDOWN_OPTION_OTHER,
];

return (

Check warning on line 27 in src/components/skills-quiz-v2/GoalDropdown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/GoalDropdown.jsx#L27

Added line #L27 was not covered by tests
<Form.Control
as="select"
name="selectedGoal"
value={goal}
onChange={handleGoalChange}
>
{gaolDropdownOptions.map((option) => (
<option key={option} value={option}>{option}</option>

Check warning on line 35 in src/components/skills-quiz-v2/GoalDropdown.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/GoalDropdown.jsx#L35

Added line #L35 was not covered by tests
))}
</Form.Control>
);
};

export default GoalDropdown;
38 changes: 30 additions & 8 deletions src/components/skills-quiz-v2/SkillsQuiz.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/* eslint-disable object-curly-newline */
import React, { useState, useContext } from 'react';
import React, { useState, useContext, useMemo } from 'react';
import {
ModalDialog, Container, Button, SelectableBox, Chip, CardGrid,
} from '@edx/paragon';
import { useHistory } from 'react-router-dom';
import { AppContext } from '@edx/frontend-platform/react';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-dom';

import GoalDropdown from '../skills-quiz/GoalDropdown';
import { getConfig } from '@edx/frontend-platform/config';
import GoalDropdown from './GoalDropdown';
import {
InterestedJobs,
SKILLS_QUIZ_SEARCH_PAGE_MESSAGE_V2,
Expand All @@ -16,16 +19,30 @@
import headerImage from '../skills-quiz/images/headerImage.png';
import CourseCard from './CourseCard';
import ClosingAlert from './ClosingAlert';
import IndustryDropdown from '../skills-quiz/IndustryDropdown';
import AutoSuggestDropDown from './AutoSuggestDropDown';

const SkillsQuizV2 = () => {
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
const config = getConfig();

Check warning on line 27 in src/components/skills-quiz-v2/SkillsQuiz.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/SkillsQuiz.jsx#L27

Added line #L27 was not covered by tests

const { enterpriseConfig } = useContext(AppContext);
const [value, setValue] = useState('green');
const handleChange = (e) => setValue(e.target.value);
const history = useHistory();
const [showAlert, setShowAlert] = useState(false);

const [searchClient] = useMemo(
() => {
const client = algoliasearch(

Check warning on line 36 in src/components/skills-quiz-v2/SkillsQuiz.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/SkillsQuiz.jsx#L34-L36

Added lines #L34 - L36 were not covered by tests
config.ALGOLIA_APP_ID,
config.ALGOLIA_SEARCH_API_KEY,
);
const cIndex = client.initIndex(config.ALGOLIA_INDEX_NAME);
const jIndex = client.initIndex(config.ALGOLIA_INDEX_NAME_JOBS);
return [client, cIndex, jIndex];

Check warning on line 42 in src/components/skills-quiz-v2/SkillsQuiz.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/skills-quiz-v2/SkillsQuiz.jsx#L40-L42

Added lines #L40 - L42 were not covered by tests
},
[config.ALGOLIA_APP_ID, config.ALGOLIA_INDEX_NAME, config.ALGOLIA_INDEX_NAME_JOBS, config.ALGOLIA_SEARCH_API_KEY],
);
const showCloseAlert = () => {
setShowAlert(true);
};
Expand Down Expand Up @@ -77,22 +94,27 @@
&& (
<div>
<h5 className="mt-3.5">
Tell us about what you want to acheive
Tell us about what you want to achieve
</h5>
<div className="mt-2">
<GoalDropdown />
</div>
<h5 className="mt-3.5">
Search and select your current job title
</h5>
<div className="mt-2">
<GoalDropdown />
</div>
<InstantSearch
indexName={config.ALGOLIA_INDEX_NAME_JOBS}
searchClient={searchClient}
>
<div className="mt-2">
<IndustryDropdown />
</div>
</InstantSearch>
<h5 className="mt-3.5">
What industry are you interested in?
</h5>
<div className="mt-2">
<GoalDropdown />
<AutoSuggestDropDown />
</div>
</div>
)}
Expand Down