import { __, sprintf } from '@wordpress/i18n'; import type { JSX } from 'react'; import type { Link } from '../../shared/api/types/links'; import { linkName } from '../../shared/links/linkName'; import { openFixPanel } from '../../shared/links/openFixPanel'; import { isFixable, problemOf } from '../../shared/links/problem'; import { StatusPill } from '../../shared/links/ProblemBadges'; import { reasonText } from '../../shared/links/reasonText'; import { timeAgo } from '../../shared/lib/timeAgo'; import { placesPhrase } from '../../shared/text/countedPhrases'; import { Button } from '../../shared/ui/Button'; import { linkStateLabel } from './linkStateLabel'; import { problemAction } from './problemAction'; type LinkRowProps = { link: Link; now: number; isSelected: boolean; onSelect: ( isSelected: boolean ) => void; }; export function LinkRow( { link, now, isSelected, onSelect, }: LinkRowProps ): JSX.Element { const problem = problemOf( link ); const name = linkName( link.url ); const isLinkFixable = isFixable( link ); const openPanel = () => { openFixPanel( link.id ); }; return (
{ onSelect( event.target.checked ); } } aria-label={ sprintf( /* translators: %s: address of a link */ __( 'Select %s', 'aiplaz-link-checkup' ), name ) } />
{ isLinkFixable ? ( ) : ( { name } ) } { reasonText( link ) }
{ isLinkFixable ? ( ) : ( { linkStateLabel( link ) } ) } { placesPhrase( link.uses_count ) } { timeAgo( link.checked_at, now ) } { isLinkFixable && ( ) }
); }