PluginProbe
Extendify / trunk
Extendify vtrunk
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 / AutoLaunch / hooks / useExtendifyCodeConnector.js

useExtendifyCodeConnector.js in Extendify trunk, at src/AutoLaunch/hooks/useExtendifyCodeConnector.js

66 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { buildExtendifyCodeLink } from '@auto-launch/functions/extendify-code';
2 import { checkIn } from '@auto-launch/functions/insights';
3 import { useLaunchDataStore } from '@auto-launch/state/launch-data';
4 import { launchStrings } from '@auto-launch/strings';
5 import { useEffect } from '@wordpress/element';
6 import { arrowRight, code, external, layout } from '@wordpress/icons';
7
8 export const useExtendifyCodeConnector = ({ onProceed }) => {
9 const { descriptionRaw, title } = useLaunchDataStore();
10 const strings = launchStrings();
11 const { extendifyCodeData = {} } = window.extSharedData;
12 const { link, title: codeTitle, message, ctaPrimary } = extendifyCodeData;
13 const ready = Boolean(link && codeTitle && message && ctaPrimary);
14
15 useEffect(() => {
16 if (!ready) {
17 onProceed();
18 return;
19 }
20 checkIn({
21 stage: 'extendify_code_screen_seen',
22 description: descriptionRaw || title,
23 });
24 }, [ready, onProceed, descriptionRaw, title]);
25
26 // A partial partner payload must not trap the flow on a blank screen.
27 if (!ready) return { options: [] };
28
29 return {
30 title: strings.connectorTitle,
31 subtitle: strings.connectorBody,
32 options: [
33 {
34 key: 'wordpress',
35 icon: layout,
36 heading: strings.wordpressHeading,
37 description: strings.wordpressBody,
38 buttonLabel: strings.wordpressAction,
39 buttonIcon: arrowRight,
40 onClick: () => {
41 checkIn({ stage: 'extendify_code_choose_wordpress' });
42 onProceed();
43 },
44 },
45 {
46 key: 'builder',
47 icon: code,
48 highlight: true,
49 badgeLabel: strings.connectorBadge,
50 heading: codeTitle,
51 description: message,
52 buttonLabel: ctaPrimary,
53 buttonIcon: external,
54 onClick: () => {
55 const url = buildExtendifyCodeLink(link, {
56 description: descriptionRaw,
57 title,
58 });
59 checkIn({ stage: 'extendify_code_choose_builder' });
60 if (url) window.location.assign(url);
61 },
62 },
63 ],
64 };
65 };
66