refactor: updated logic to handle show email channel env variable

This commit is contained in:
ayeshoali
2024-05-10 17:05:11 +05:00
parent b35042ca97
commit 39fca96523
3 changed files with 27 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import classNames from 'classnames';
import { useDispatch, useSelector } from 'react-redux';
import { NavItem } from '@openedx/paragon';
import { getConfig } from '@edx/frontend-platform';
import { useIntl } from '@edx/frontend-platform/i18n';
import messages from './messages';
@@ -26,7 +25,6 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
const nonEditable = useSelector(selectNonEditablePreferences(appId));
const updatePreferencesStatus = useSelector(selectUpdatePreferencesStatus());
const mobileView = useIsOnMobile();
const showEmailChannel = getConfig().SHOW_EMAIL_CHANNEL;
const onChannelToggle = useCallback((event) => {
const { id: notificationChannel } = event.target;
@@ -84,25 +82,24 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
</div>
);
return ((showEmailChannel === 'true' || channel === 'web') && (
<div className={classNames('d-flex flex-column', { 'border-right': channel !== 'email' && showEmailChannel === 'true' })}>
<NavItem
id={channel}
key={channel}
role="button"
onClick={onChannelToggle}
className={classNames('mb-3 header-label column-padding', {
'pr-0': channel === 'email',
'pl-0': channel === 'web' && mobileView,
})}
>
{intl.formatMessage(messages.notificationChannel, { text: channel })}
</NavItem>
{appPreference
? renderPreference(appPreference)
: appPreferences.map((preference) => (renderPreference(preference)))}
</div>
)
return (
<div className={classNames('d-flex flex-column border-right channel-column')}>
<NavItem
id={channel}
key={channel}
role="button"
onClick={onChannelToggle}
className={classNames('mb-3 header-label column-padding', {
'pr-0': channel === 'email',
'pl-0': channel === 'web' && mobileView,
})}
>
{intl.formatMessage(messages.notificationChannel, { text: channel })}
</NavItem>
{appPreference
? renderPreference(appPreference)
: appPreferences.map((preference) => (renderPreference(preference)))}
</div>
);
};