react-native-gigya-sdk
Version:
SAP CDC/Gigya SDK for your React Native applications
38 lines (31 loc) • 1.52 kB
JavaScript
import getAccountInfo from './getAccountInfo';
import getRequiredConsentSchemas from './getRequiredConsentSchemas';
export default function () {
return new Promise(async (resolve, reject) => {
try {
const requiredConsentSchemas = await getRequiredConsentSchemas();
const consentSchemaKeys = requiredConsentSchemas.map(schema => schema.key);
const preferences = (await getAccountInfo({
noUID: true
})).preferences;
if (consentSchemaKeys.length < 1 || !preferences) {
return resolve(null);
}
let output = [];
for (let key of consentSchemaKeys) {
var _preferences$key, _preferences$consentP, _preferences$consentP2;
const [consentPreference, consentPreferenceKey] = key.split('.');
if (!(preferences !== null && preferences !== void 0 && (_preferences$key = preferences[key]) !== null && _preferences$key !== void 0 && _preferences$key.isConsentGranted) && !(preferences !== null && preferences !== void 0 && (_preferences$consentP = preferences[consentPreference]) !== null && _preferences$consentP !== void 0 && (_preferences$consentP2 = _preferences$consentP[consentPreferenceKey]) !== null && _preferences$consentP2 !== void 0 && _preferences$consentP2.isConsentGranted)) {
output = [...output, key];
}
}
if (!output.length) {
return resolve(null);
}
resolve(output);
} catch (e) {
reject(e);
}
});
}
//# sourceMappingURL=getUnacceptedConsentSchemas.js.map