PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Assist / components / dashboard / domains / DomainCard.jsx

DomainCard.jsx in Extendify 3.0.5, at src/Assist/components/dashboard/domains/DomainCard.jsx

104 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useDomainViewActivity } from '@assist/hooks/useDomainViewActivity';
2 import {
3 buildDomainViewItems,
4 createDomainUrlLink,
5 deleteDomainCache,
6 domainSearchUrl,
7 domains,
8 } from '@assist/lib/domains';
9 import { useDomainActivities } from '@assist/state/domain-activities';
10 import { useTasksStore } from '@assist/state/tasks';
11 import { __, isRTL } from '@wordpress/i18n';
12 import { chevronLeftSmall, chevronRightSmall, Icon } from '@wordpress/icons';
13
14 const viewItems = buildDomainViewItems(domains);
15
16 export const DomainCard = ({ task }) => {
17 const { completeTask } = useTasksStore();
18 const { setDomainActivity } = useDomainActivities();
19 useDomainViewActivity({ position: 'buy-task', items: viewItems });
20
21 const handleInteract = () => {
22 completeTask(task.slug);
23 deleteDomainCache();
24 };
25
26 const recordActivity = (domain, type) =>
27 setDomainActivity({ domain, position: 'buy-task', type });
28
29 if (!domains.length) {
30 return (
31 <div
32 className="flex h-full w-full items-center justify-center bg-cover bg-right-bottom bg-no-repeat"
33 style={{
34 backgroundImage: `url(${task.backgroundImage}})`,
35 }}
36 >
37 {__('Service offline. Check back later.', 'extendify-local')}
38 </div>
39 );
40 }
41
42 if (!domainSearchUrl) return null;
43
44 return (
45 <div
46 className="flex h-full w-full bg-cover bg-right-bottom bg-no-repeat"
47 data-test="assist-domain-card-main-domain-module"
48 style={{ backgroundImage: `url(${task.backgroundImage})` }}
49 >
50 <div className="flex w-full flex-col px-8 py-12 md:pl-8 md:pr-0 lg:mr-24">
51 <div className="title text-2xl font-semibold md:text-4xl">
52 {task.innerTitle}
53 </div>
54 <div className="description mb-8 mt-2 text-base">
55 {task.description}
56 </div>
57 <div className="overflow-auto rounded-sm bg-gray-100 md:w-full">
58 <div className="rounded-tl rounded-tr border-b border-gray-200 px-6 py-4 md:flex md:flex-wrap md:items-center md:justify-between">
59 <div>
60 <div className="mb-1 w-fit rounded-full border-wp-alert-yellow bg-wp-alert-yellow/40 px-3 py-1 text-xs uppercase text-gray-900">
61 {__('Recommended', 'extendify-local')}
62 </div>
63 <div className="text-xl font-semibold lowercase">
64 {domains[0]}
65 </div>
66 </div>
67 <a
68 href={createDomainUrlLink(domainSearchUrl, domains[0])}
69 target="_blank"
70 onClick={() => {
71 handleInteract();
72 recordActivity(domains[0], 'primary');
73 }}
74 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"
75 >
76 {__('Register this domain', 'extendify-local')}
77 <Icon
78 icon={isRTL() ? chevronLeftSmall : chevronRightSmall}
79 className="fill-current"
80 />
81 </a>
82 </div>
83 {/*Secondary domains*/}
84 {domains.slice(1).map((domain) => (
85 <a
86 href={createDomainUrlLink(domainSearchUrl, domain)}
87 target="_blank"
88 className="flex h-11 cursor-pointer items-center justify-between border-b border-gray-200 px-6 py-3.5 text-sm font-normal lowercase text-gray-800 no-underline last:border-transparent hover:bg-gray-50"
89 onClick={() => {
90 handleInteract();
91 recordActivity(domain, 'secondary');
92 }}
93 key={domain}
94 >
95 {domain}
96 <Icon icon={isRTL() ? chevronLeftSmall : chevronRightSmall} />
97 </a>
98 ))}
99 </div>
100 </div>
101 </div>
102 );
103 };
104