{warning}
; + } + return warning; +}; + +const Warnings = ({ + stepMethodSelectionData, +}) => { + const { invalid, duplicate, role } = stepMethodSelectionData; + + const [detailsShown, setDetailsShown] = useState(false); + + const detailClasses = classNames( + 'mailpoet_subscribers_data_parse_results_details', + { mailpoet_hidden: !detailsShown }, + ); + + const invalidWarning = getSingleWarning(MailPoet.I18n.t('importNoticeInvalid'), invalid); + + const duplicateWarning = getSingleWarning(MailPoet.I18n.t('importNoticeDuplicate'), duplicate); + + let roleBasedWarning = ''; + if (role.length) { + roleBasedWarning = ReactStringReplace( + MailPoet.I18n.t('importNoticeRoleBased'), + /(%1\$s|\[link\].*\[\/link\]|%2\$s)/, + (match) => { + if (match === '%1$s') return {role.length.toLocaleString()}; + if (match === '%2$s') return role.join(', '); + return ( + + {match.replace('[link]', '').replace('[/link]', '')} + + ); + } + ); + roleBasedWarning ={roleBasedWarning}
; + } + + if ( + invalid.length + || duplicate.length + || role.length + ) { + const allWarningsCount = invalid.length + duplicate.length + role.length; + return ( ++ {ReactStringReplace(MailPoet.I18n.t('importNoticeSkipped'), '%1$s', () => ( + {allWarningsCount.toLocaleString()} + ))} + {' '} + setDetailsShown(!detailsShown)} + role="button" + tabIndex={0} + onKeyDown={(event) => { + if ((['keydown', 'keypress'].includes(event.type) && ['Enter', ' '].includes(event.key)) + ) { + event.preventDefault(); + setDetailsShown(!detailsShown); + } + }} + > + {MailPoet.I18n.t('showMoreDetails')} + +
+