PluginProbe
Extendify / 2.2.0
Extendify v2.2.0
3.2.3 3.2.2 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 All 129 releases
extendify / src / Assist / components / dashboard / domains / DomainCard.jsx

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

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