Files
frontend-app-account/src/notification-preferences/NotificationPreferenceApp.jsx
Awais Ansari 465bb9f7a0 feat: added notification preferences settings at account level (#1159)
* 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 <sundasnoreen12@gmail.com>
2025-04-16 15:29:09 +05:00

61 lines
2.2 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useSelector } from 'react-redux';
import { Collapsible } from '@openedx/paragon';
import { useIntl } from '@edx/frontend-platform/i18n';
import messages from './messages';
import { useIsOnMobile } from '../hooks';
import NotificationTypes from './NotificationTypes';
import { notificationChannels, shouldHideAppPreferences } from './data/utils';
import NotificationPreferenceColumn from './NotificationPreferenceColumn';
import { selectPreferenceAppToggleValue, selectAppPreferences } from './data/selectors';
const NotificationPreferenceApp = ({ appId }) => {
const intl = useIntl();
const appToggle = useSelector(selectPreferenceAppToggleValue(appId));
const appPreferences = useSelector(selectAppPreferences(appId));
const mobileView = useIsOnMobile();
const NOTIFICATION_CHANNELS = notificationChannels();
const hideAppPreferences = shouldHideAppPreferences(appPreferences, appId) || false;
return (
!hideAppPreferences && (
<Collapsible.Advanced
open={appToggle}
data-testid={`${appId}-app`}
className={classNames({ 'mb-4.5': !mobileView && appToggle })}
>
<Collapsible.Trigger>
<div className="d-flex align-items-center">
<span className={classNames('mr-auto preference-app font-weight-bold', { 'mb-2': !mobileView })}>
{intl.formatMessage(messages.notificationAppTitle, { key: appId })}
</span>
</div>
</Collapsible.Trigger>
<Collapsible.Body>
<div className="d-flex flex-row justify-content-between w-100">
<NotificationTypes appId={appId} />
{!mobileView && (
<div className="d-flex">
{Object.values(NOTIFICATION_CHANNELS).map((channel) => (
<NotificationPreferenceColumn key={channel} appId={appId} channel={channel} />
))}
</div>
)}
</div>
{mobileView && <hr className="border-light-400 my-4.5" />}
</Collapsible.Body>
</Collapsible.Advanced>
)
);
};
NotificationPreferenceApp.propTypes = {
appId: PropTypes.string.isRequired,
};
export default React.memo(NotificationPreferenceApp);