Skip to content

Commit

Permalink
refactor: refactor name for notification channels
Browse files Browse the repository at this point in the history
  • Loading branch information
sundasnoreen12 committed May 15, 2024
1 parent a0b0b1f commit 075587c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/notification-preferences/NotificationPreferenceApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useIsOnMobile } from '../hooks';
import ToggleSwitch from './ToggleSwitch';
import { LOADING_STATUS } from '../constants';
import NotificationTypes from './NotificationTypes';
import showEmailChannel from './data/utils';
import showNotificationChannels from './data/utils';
import { updateAppPreferenceToggle } from './data/thunks';
import NotificationPreferenceColumn from './NotificationPreferenceColumn';
import { selectPreferenceAppToggleValue, selectSelectedCourseId, selectUpdatePreferencesStatus } from './data/selectors';
Expand All @@ -24,7 +24,7 @@ const NotificationPreferenceApp = ({ appId }) => {
const appToggle = useSelector(selectPreferenceAppToggleValue(appId));
const updatePreferencesStatus = useSelector(selectUpdatePreferencesStatus());
const mobileView = useIsOnMobile();
const NOTIFICATION_CHANNELS = showEmailChannel();
const NOTIFICATION_CHANNELS = showNotificationChannels();

const onChangeAppSettings = useCallback((event) => {
dispatch(updateAppPreferenceToggle(courseId, appId, event.target.checked));
Expand Down
8 changes: 4 additions & 4 deletions src/notification-preferences/NotificationPreferenceColumn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { updateChannelPreferenceToggle, updatePreferenceToggle } from './data/th
import {
selectNonEditablePreferences, selectPreferencesOfApp, selectSelectedCourseId, selectUpdatePreferencesStatus,
} from './data/selectors';
import showEmailChannel from './data/utils';
import showNotificationChannels from './data/utils';

const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
const dispatch = useDispatch();
Expand All @@ -26,7 +26,7 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
const nonEditable = useSelector(selectNonEditablePreferences(appId));
const updatePreferencesStatus = useSelector(selectUpdatePreferencesStatus());
const mobileView = useIsOnMobile();
const emailChannels = Object.keys(showEmailChannel());
const notificationChannels = Object.keys(showNotificationChannels());

const onChannelToggle = useCallback((event) => {
const { id: notificationChannel } = event.target;
Expand Down Expand Up @@ -61,7 +61,7 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
className={classNames(
'd-flex align-items-center justify-content-center mb-2 h-4.5 column-padding',
{
'pr-0': channel === emailChannels[emailChannels.length - 1].toLowerCase(),
'pr-0': channel === notificationChannels[notificationChannels.length - 1].toLowerCase(),
'pl-0': channel === 'web' && mobileView,
},
)}
Expand Down Expand Up @@ -94,7 +94,7 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
role="button"
onClick={onChannelToggle}
className={classNames('mb-3 header-label column-padding', {
'pr-0': channel === emailChannels[emailChannels.length - 1].toLowerCase(),
'pr-0': channel === notificationChannels[notificationChannels.length - 1].toLowerCase(),
'pl-0': channel === 'web' && mobileView,
})}
>
Expand Down
4 changes: 2 additions & 2 deletions src/notification-preferences/NotificationTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Icon, OverlayTrigger, Tooltip } from '@openedx/paragon';

import messages from './messages';
import { useIsOnMobile } from '../hooks';
import showEmailChannel from './data/utils';
import showNotificationChannels from './data/utils';

import { selectPreferencesOfApp } from './data/selectors';
import NotificationPreferenceColumn from './NotificationPreferenceColumn';
Expand All @@ -18,7 +18,7 @@ const NotificationTypes = ({ appId }) => {
const intl = useIntl();
const preferences = useSelector(selectPreferencesOfApp(appId));
const mobileView = useIsOnMobile();
const NOTIFICATION_CHANNELS = showEmailChannel();
const NOTIFICATION_CHANNELS = showNotificationChannels();

return (
<div className="d-flex flex-column mr-auto px-0">
Expand Down
4 changes: 2 additions & 2 deletions src/notification-preferences/data/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getConfig } from '@edx/frontend-platform';

const showEmailChannel = () => ({ WEB: 'web', ...(getConfig().SHOW_EMAIL_CHANNEL === 'true' && { EMAIL: 'email' }) });
const showNotificationChannels = () => ({ WEB: 'web', ...(getConfig().SHOW_EMAIL_CHANNEL === 'true' && { EMAIL: 'email' }) });

export default showEmailChannel;
export default showNotificationChannels;

0 comments on commit 075587c

Please sign in to comment.