import { useDomainViewActivity } from '@assist/hooks/useDomainViewActivity'; import { buildDomainViewItems, createDomainUrlLink, deleteDomainCache, domainSearchUrl, domains, } from '@assist/lib/domains'; import { useDomainActivities } from '@assist/state/domain-activities'; import { useTasksStore } from '@assist/state/tasks'; import { __, isRTL } from '@wordpress/i18n'; import { chevronLeftSmall, chevronRightSmall, Icon } from '@wordpress/icons'; const viewItems = buildDomainViewItems(domains); export const DomainCard = ({ task }) => { const { completeTask } = useTasksStore(); const { setDomainActivity } = useDomainActivities(); useDomainViewActivity({ position: 'buy-task', items: viewItems }); const handleInteract = () => { completeTask(task.slug); deleteDomainCache(); }; const recordActivity = (domain, type) => setDomainActivity({ domain, position: 'buy-task', type }); if (!domains.length) { return (
{__('Service offline. Check back later.', 'extendify-local')}
); } if (!domainSearchUrl) return null; return (
{task.innerTitle}
{task.description}
{__('Recommended', 'extendify-local')}
{domains[0]}
{ handleInteract(); recordActivity(domains[0], 'primary'); }} className="mt-3 inline-flex h-8 cursor-pointer items-center justify-between rounded-xs border-design-main bg-design-main px-3 py-2 text-center text-sm leading-tight text-design-text no-underline hover:opacity-90 md:mt-0 md:flex" > {__('Register this domain', 'extendify-local')}
{/*Secondary domains*/} {domains.slice(1).map((domain) => ( { handleInteract(); recordActivity(domain, 'secondary'); }} key={domain} > {domain} ))}
); };