Skip to content

Commit

Permalink
feat: added notification preferences settings at account level (#1159)
Browse files Browse the repository at this point in the history
* feat: added notification preferences settings at account level

* fix: fixed test cases

* feat: added api for account notification type

* fix: fixed test cases and label

* test: added update account preference test case

* fix: fixed issue to update email cadence for account notification type

* refactor: updated time

* fix: fixed mixed cadence issue

* fix: fixed border issue when no preferences

* refactor: refactor code

---------

Co-authored-by: sundasnoreen12 <[email protected]>
  • Loading branch information
awais-ansari and sundasnoreen12 authored Dec 31, 2024
1 parent 675659d commit 6f6cf7c
Show file tree
Hide file tree
Showing 22 changed files with 345 additions and 314 deletions.
8 changes: 5 additions & 3 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
} from './data/constants';
import { fetchSiteLanguages } from './site-language';
import { fetchCourseList } from '../notification-preferences/data/thunks';
import NotificationSettings from '../notification-preferences/NotificationSettings';
import { withLocation, withNavigate } from './hoc';

class AccountSettingsPage extends React.Component {
Expand Down Expand Up @@ -732,7 +733,7 @@ class AccountSettingsPage extends React.Component {
{...editableFieldProps}
/>
</div>
<div className="account-section pt-3 mb-5" id="social-media">
<div className="account-section pt-3" id="social-media">
<h2 className="section-heading h4 mb-3">
{this.props.intl.formatMessage(messages['account.settings.section.social.media'])}
</h2>
Expand Down Expand Up @@ -768,8 +769,9 @@ class AccountSettingsPage extends React.Component {
{...editableFieldProps}
/>
</div>

<div className="account-section pt-3 mb-5" id="site-preferences" ref={this.navLinkRefs['#site-preferences']}>
<div className="border border-light-700 my-6" />
<NotificationSettings />
<div className="account-section mb-5" id="site-preferences" ref={this.navLinkRefs['#site-preferences']}>
<h2 className="section-heading h4 mb-3">
{this.props.intl.formatMessage(messages['account.settings.section.site.preferences'])}
</h2>
Expand Down
22 changes: 1 addition & 21 deletions src/account-settings/JumpNav.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { breakpoints, useWindowSize, Icon } from '@openedx/paragon';
import { OpenInNew } from '@openedx/paragon/icons';
import { breakpoints, useWindowSize } from '@openedx/paragon';
import classNames from 'classnames';
import React from 'react';
import { useSelector } from 'react-redux';
import { NavHashLink } from 'react-router-hash-link';
import Scrollspy from 'react-scrollspy';
import { Link } from 'react-router-dom';
import messages from './AccountSettingsPage.messages';
import { selectShowPreferences } from '../notification-preferences/data/selectors';

const JumpNav = ({
intl,
}) => {
const stickToTop = useWindowSize().width > breakpoints.small.minWidth;
const showPreferences = useSelector(selectShowPreferences());

return (
<div className={classNames('jump-nav px-2.25', { 'jump-nav-sm position-sticky pt-3': stickToTop })}>
Expand Down Expand Up @@ -65,21 +60,6 @@ const JumpNav = ({
</li>
)}
</Scrollspy>
{showPreferences && (
<>
<hr />
<Scrollspy
className="list-unstyled"
>
<li>
<Link to="/notifications" target="_blank" rel="noopener noreferrer">
<span>{intl.formatMessage(messages['notification.preferences.notifications.label'])}</span>
<Icon className="d-inline-block align-bottom ml-1" src={OpenInNew} />
</Link>
</li>
</Scrollspy>
</>
)}
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions src/account-settings/test/AccountSettingsPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ describe('AccountSettingsPage', () => {

afterEach(() => jest.clearAllMocks());

beforeAll(() => {
global.lightningjs = {
require: jest.fn().mockImplementation((module, url) => ({ moduleName: module, url })),
};
});

afterAll(() => {
delete global.lightningjs;
});

it('renders AccountSettingsPage correctly with editing enabled', async () => {
const { getByText, rerender, getByLabelText } = render(reduxWrapper(<IntlAccountSettingsPage {...props} />));

Expand Down
4 changes: 2 additions & 2 deletions src/account-settings/test/mockData.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const mockData = {
profileDataManager: null,
},
notificationPreferences: {
showPreferences: false,
showPreferences: true,
courses: {
status: 'success',
courses: [],
Expand All @@ -98,7 +98,7 @@ const mockData = {
preferences: {
status: 'idle',
updatePreferenceStatus: 'idle',
selectedCourse: null,
selectedCourse: 'account',
preferences: [],
apps: [],
nonEditable: {},
Expand Down
16 changes: 16 additions & 0 deletions src/divider/Divider.jsx
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;
2 changes: 2 additions & 0 deletions src/divider/index.jsx
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';
4 changes: 0 additions & 4 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import messages from './i18n';

import './index.scss';
import Head from './head/Head';
import NotificationCourses from './notification-preferences/NotificationCourses';
import NotificationPreferences from './notification-preferences/NotificationPreferences';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -38,8 +36,6 @@ subscribe(APP_READY, () => {
</div>
)}
>
<Route path="/notifications/:courseId" element={<NotificationPreferences />} />
<Route path="/notifications" element={<NotificationCourses />} />
<Route
path="/id-verification/*"
element={<IdVerificationPageSlot />}
Expand Down
16 changes: 15 additions & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $fa-font-path: "~font-awesome/fonts";
}

.dropdown-item:active,
.dropdown-item:focus,
.dropdown-item:focus,
.btn-tertiary:not(:disabled):not(.disabled).active {
background-color: $light-300 !important;
}
Expand All @@ -131,6 +131,20 @@ $fa-font-path: "~font-awesome/fonts";
.h-4\.5 {
height: 36px;
}

.course-dropdown{
#course-dropdown-btn {
width: 100%;
font-size: 14px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
border: 1px solid $light-500 !important;
}

.dropdown-item {
font-size: 14px !important;
}
}
}

.usabilla_live_button_container {
Expand Down
85 changes: 0 additions & 85 deletions src/notification-preferences/NotificationCourses.jsx

This file was deleted.

97 changes: 0 additions & 97 deletions src/notification-preferences/NotificationCourses.test.jsx

This file was deleted.

Loading

0 comments on commit 6f6cf7c

Please sign in to comment.