import { __, _n, sprintf } from '@wordpress/i18n'; import type { JSX } from 'react'; import type { LinkDetail } from '../../shared/api/types/links'; import { formatNumber } from '../../shared/lib/numbers'; import { placesPhrase } from '../../shared/text/countedPhrases'; import { Icon } from '../../shared/ui/Icon'; const USES_SHOWN = 3; export function Uses( { link }: { link: LinkDetail } ): JSX.Element { const shownUses = link.uses.slice( 0, USES_SHOWN ); const hiddenCount = link.uses_count - shownUses.length; return (

{ sprintf( /* translators: %s: number of places, for example "3 places" */ __( 'Used in %s', 'aiplaz-link-checkup' ), placesPhrase( link.uses_count ) ) }

{ shownUses.map( ( use, index ) => (
{ use.post_title } { use.post_type_label }

{ use.before } { use.text } { use.after }

{ use.builder !== null && (

{ sprintf( /* translators: 1: name of a page builder, for example Elementor */ __( 'This page is made with %1$s. Change the link in the %1$s editor.', 'aiplaz-link-checkup' ), use.builder ) }

) } { use.view_url !== null && ( { __( 'Show on page', 'aiplaz-link-checkup' ) } ) }
) ) } { hiddenCount > 0 && ( { sprintf( /* translators: %s: number of places */ _n( 'and %s more place', 'and %s more places', hiddenCount, 'aiplaz-link-checkup' ), formatNumber( hiddenCount ) ) } ) }
); }