react-code-dataset / wp-calypso /client /lib /emails /account-has-warning-with-slug.js
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
/**
* Determines if the email account provided i.e. `emailAccount` has one or more warnings with the slug `warningSlug` in its `warnings` array
* @param {string} warningSlug - The warning slug to check against
* @param {Object} emailAccount - The email account being investigated for warnings of a certain slug
* @returns {boolean} Returns true if warnings with the slug are found, false otherwise
*/
export function accountHasWarningWithSlug( warningSlug, emailAccount ) {
const warnings = emailAccount?.warnings;
return ( warnings?.[ 0 ] ? warnings : [] ).some(
( warning ) => warningSlug === warning?.warning_slug
);
}