Skip to content

Commit

Permalink
Merge pull request #137 from Pearson-Advance/hide-toggle-for-courses
Browse files Browse the repository at this point in the history
feat: site setting to control the toggle visibility in courses
  • Loading branch information
01001110J authored Dec 10, 2024
2 parents 5fda844 + 7e973e0 commit 9da56e9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/features/Courses/CoursesFilters/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';

import { Col, Form } from '@edx/paragon';
import { Select } from 'react-paragon-topaz';
import { getConfig } from '@edx/frontend-platform';

import { updateFilters, updateCurrentPage, updateShowAllCourses } from 'features/Courses/data/slice';
import { fetchCoursesData, fetchCoursesOptionsData } from 'features/Courses/data/thunks';
Expand All @@ -22,6 +23,8 @@ const CoursesFilters = () => {
const [inputCourse, setInputCourse] = useState('');
const [defaultOption, setDefaultOption] = useState(allResultsOption);

const showCoursesToggle = getConfig().enable_toggle_courses || false;

const filterOptions = (option, input) => {
if (input) {
return option.label.toLowerCase().includes(input) || option.value === defaultOption.value;
Expand Down Expand Up @@ -106,16 +109,20 @@ const CoursesFilters = () => {
/>
</Form.Group>
</Form.Row>
<Form.Row className="w-100 mt-2">
<Form.Switch
checked={showAllCourses}
onChange={handleToggleChange}
className="ml-3"
disabled={isLoading}
>
Show my courses
</Form.Switch>
</Form.Row>
{
showCoursesToggle && (
<Form.Row className="w-100 mt-2">
<Form.Switch
checked={showAllCourses}
onChange={handleToggleChange}
className="ml-3"
disabled={isLoading}
>
Show my courses
</Form.Switch>
</Form.Row>
)
}
</Form>
</div>
</div>
Expand Down

0 comments on commit 9da56e9

Please sign in to comment.