-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added notification preferences settings at account level
- Loading branch information
1 parent
45bcfdd
commit 27c686f
Showing
15 changed files
with
219 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
const Divider = ({ className, ...props }) => ( | ||
<div className={classNames('divider', className)} {...props} /> | ||
); | ||
|
||
Divider.propTypes = { | ||
className: PropTypes.string, | ||
}; | ||
|
||
Divider.defaultProps = { | ||
className: undefined, | ||
}; | ||
|
||
export default Divider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export { default as Divider } from './Divider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
src/notification-preferences/NotificationCoursesDropdown.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useCallback, useEffect, useMemo } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { Dropdown } from '@openedx/paragon'; | ||
|
||
import { IDLE_STATUS, SUCCESS_STATUS } from '../constants'; | ||
import { selectCourseList, selectCourseListStatus, selectSelectedCourseId } from './data/selectors'; | ||
import { fetchCourseList, setSelectedCourse } from './data/thunks'; | ||
import messages from './messages'; | ||
|
||
const NotificationCoursesDropdown = () => { | ||
const intl = useIntl(); | ||
const dispatch = useDispatch(); | ||
const coursesList = useSelector(selectCourseList()); | ||
const courseListStatus = useSelector(selectCourseListStatus()); | ||
const selectedCourseId = useSelector(selectSelectedCourseId()); | ||
const selectedCourse = useMemo( | ||
() => coursesList.find((course) => course.id === selectedCourseId), | ||
[coursesList, selectedCourseId], | ||
); | ||
|
||
const handleCourseSelection = useCallback((courseId) => { | ||
dispatch(setSelectedCourse(courseId)); | ||
}, [dispatch]); | ||
|
||
const fetchCourses = useCallback((page = 1, pageSize = 99999) => { | ||
dispatch(fetchCourseList(page, pageSize)); | ||
}, [dispatch]); | ||
|
||
useEffect(() => { | ||
if (courseListStatus === IDLE_STATUS) { | ||
fetchCourses(); | ||
} | ||
}, [courseListStatus, fetchCourses]); | ||
|
||
return ( | ||
courseListStatus === SUCCESS_STATUS && ( | ||
<div className="mb-5"> | ||
<h5 className="text-primary-500 mb-3">{intl.formatMessage(messages.notificationDropdownlabel)}</h5> | ||
<Dropdown className="course-dropdown"> | ||
<Dropdown.Toggle | ||
variant="outline-primary" | ||
id="course-dropdown-btn" | ||
className="w-100 justify-content-between small" | ||
> | ||
{selectedCourse?.name} | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu className="w-100"> | ||
{coursesList.map((course) => ( | ||
<Dropdown.Item | ||
className="w-100" | ||
key={course.id} | ||
active={course.id === selectedCourse?.id} | ||
eventKey={course.id} | ||
onSelect={handleCourseSelection} | ||
> | ||
{course.name} | ||
</Dropdown.Item> | ||
))} | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
<span className="x-small text-gray-500">{intl.formatMessage(messages.notificationDropdownApplies)}</span> | ||
</div> | ||
) | ||
); | ||
}; | ||
|
||
export default NotificationCoursesDropdown; |
Oops, something went wrong.