feat: added env parse to boolean functionality (#1390)

This commit is contained in:
Awais Ansari
2025-12-01 19:51:35 +05:00
committed by GitHub
parent 36827914eb
commit 9c78bf34ef
2 changed files with 14 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
import { getConfig } from '@edx/frontend-platform';
import { parseEnvBoolean } from '../../utils';
export const notificationChannels = () => ({
WEB: 'web',
...(getConfig().SHOW_PUSH_CHANNEL && { PUSH: 'push' }),
...(getConfig().SHOW_EMAIL_CHANNEL && { EMAIL: 'email' }),
...(parseEnvBoolean(getConfig().SHOW_PUSH_CHANNEL) && { PUSH: 'push' }),
...(parseEnvBoolean(getConfig().SHOW_EMAIL_CHANNEL) && { EMAIL: 'email' }),
});
export const shouldHideAppPreferences = (preferences, appId) => {

View File

@@ -38,3 +38,13 @@ export function getMostRecentApprovedOrPendingVerifiedName(verifiedNames) {
return applicableName;
}
/**
* Parse an environment variable string value to a boolean.
* @param {string} value the environment variable string value
* @returns {boolean} the parsed boolean value
*/
export const parseEnvBoolean = (value) => {
if (!value) { return false; }
return String(value).toLowerCase() === 'true';
};