import { Card, Badge } from '@automattic/components';
import DOMPurify from 'dompurify';
import { localize, LocalizeProps, translate } from 'i18n-calypso';
import { Fragment } from 'react';
import ActionPanelLink from 'calypso/components/action-panel/link';
import InlineSupportLink from 'calypso/components/inline-support-link';
import type { DomainNames, EligibilityWarning } from 'calypso/state/automated-transfer/selectors';
interface ExternalProps {
context: string | null;
warnings: EligibilityWarning[];
showContact?: boolean;
}
type Props = ExternalProps & LocalizeProps;
export const WarningList = ( { context, translate, warnings, showContact = true }: Props ) => {
return (
{ warnings.map( ( { name, description, supportPostId, supportUrl, domainNames }, index ) => (
{ context !== 'plugin-details' && context !== 'hosting-features' && (
{ name }:
) }
{ domainNames && displayDomainNames( domainNames ) }
{ supportUrl && (
{ translate( 'Learn more.' ) }
) }
) ) }
{ showContact && (
{ translate( '{{a}}Contact support{{/a}} for help and questions.', {
components: {
a: ,
},
} ) }
) }
);
};
function displayDomainNames( domainNames: DomainNames ) {
//Split out the first part of the domain names and then join the rest back together.
const domainNamesArrayCurrent = domainNames.current.split( '.' );
const domainNamesArrayNew = domainNames.new.split( '.' );
const firstPartCurrent = domainNamesArrayCurrent.shift();
const firstPartNew = domainNamesArrayNew.shift();
const secondPartCurrent = '.' + domainNamesArrayCurrent.join( '.' );
const secondPartNew = '.' + domainNamesArrayNew.join( '.' );
return (
{ firstPartCurrent }
{ secondPartCurrent }
{ translate( 'current' ) }
{ firstPartNew }
{ secondPartNew }
{ translate( 'new' ) }
);
}
export default localize( WarningList );