@hhgtech/hhg-components
Version:
Hello Health Group common components
65 lines (61 loc) • 3.37 kB
JavaScript
;
var healthTools = require('./healthTools-66a8dc09.js');
var index = require('./index-fa7abbff.js');
var store = require('./store-c7185440.js');
var index$1 = require('./index-ad7155cf.js');
var Locale = require('./Locale-59ccf941.js');
const isFeatureWhatsAppEnabled = [
Locale.LOCALE.Indonesia,
Locale.LOCALE.Malaysia,
].includes(index.locale);
const isFeatureSMSEnabled = [Locale.LOCALE.Vietnam].includes(index.locale);
const isFeatureZaloEnabled = [Locale.LOCALE.Vietnam].includes(index.locale);
const isSupportProduct = (featureFlagsProduct) => {
const setupSource = store.useSSOV2Store.getState().setupSource || 'discover';
const isSupportDiscover = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'discover')) &&
setupSource === 'discover';
const isSupportTogether = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'together')) &&
setupSource === 'community';
const isSupportCare = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'care')) &&
setupSource === 'care';
return isSupportDiscover || isSupportTogether || isSupportCare;
};
const getURLwithSSOTracking = (url, { source, botItem }) => {
var _a;
if (!source && !botItem)
return null;
try {
const urlObj = new URL(url.startsWith('localhost') ? `http://${url}` : url);
const mapHealthToolName = {
bmi: healthTools.HEALTH_TOOL_NAME_TRACKING.BMI,
bmr: healthTools.HEALTH_TOOL_NAME_TRACKING.BMR,
'due-date': healthTools.HEALTH_TOOL_NAME_TRACKING.DUE_DATE,
ovulation: healthTools.HEALTH_TOOL_NAME_TRACKING.OVULATION,
'baby-growth': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_GROWTH,
'baby-vaccine': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_VACCINE,
'pregnancy-weight-gain': healthTools.HEALTH_TOOL_NAME_TRACKING.PWG,
'target-heart-rate': healthTools.HEALTH_TOOL_NAME_TRACKING.THR,
'baby-poop-checking': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_POOP,
};
const healthToolName = mapHealthToolName[source];
const isHealthToolPage = window.location.href.includes('/health-tools');
// Only accept the health tools are embedded in other pages
if (healthToolName && !isHealthToolPage) {
urlObj.searchParams.set('embeddedType', 'healthTool');
urlObj.searchParams.set('toolName', healthToolName);
}
else if (((_a = botItem === null || botItem === void 0 ? void 0 : botItem.extra_settings) === null || _a === void 0 ? void 0 : _a.subot_type) === index$1.SubotType.ristScreener) {
urlObj.searchParams.set('embeddedType', 'riskScreener');
urlObj.searchParams.set('toolName', String(botItem.id));
}
return urlObj;
}
catch (err) {
return null;
}
};
exports.getURLwithSSOTracking = getURLwithSSOTracking;
exports.isFeatureSMSEnabled = isFeatureSMSEnabled;
exports.isFeatureWhatsAppEnabled = isFeatureWhatsAppEnabled;
exports.isFeatureZaloEnabled = isFeatureZaloEnabled;
exports.isSupportProduct = isSupportProduct;