File size: 3,759 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | import { getPlan, PLAN_BUSINESS } from '@automattic/calypso-products';
import { localizeUrl } from '@automattic/i18n-utils';
import { SelectItem } from '@automattic/onboarding';
import { useTranslate } from 'i18n-calypso';
import paymentBlocksImage from 'calypso/assets/images/onboarding/payment-blocks.svg';
import wooCommerceImage from 'calypso/assets/images/onboarding/woo-commerce.svg';
import { shoppingBag, truck } from '../../icons';
import { StoreFeatureSet } from './types';
export function useIntents(
siteSlug: string | null,
hasPaymentsFeature: boolean | false,
hasWooFeature: boolean | false,
trackSupportLinkClick: ( url: StoreFeatureSet ) => void
): SelectItem< StoreFeatureSet >[] {
const translate = useTranslate();
if ( ! siteSlug ) {
return [];
}
return [
{
key: 'simple',
title: translate( 'Start simple' ),
description: (
<>
<span className="store-features__requirements">
{ hasPaymentsFeature
? translate( 'Included in your plan' )
: translate( 'Requires a {{a}}paid plan{{/a}}', {
components: {
a: (
<a
href={ `/plans/${ siteSlug }` }
target="_blank"
rel="noopener noreferrer"
/>
),
},
} ) }
</span>
<p>
{ translate(
'Ideal if you’re looking to accept donations or sell one or two products without needing to manage shipping.'
) }
</p>
<footer className="store-features__powered-by">
<img
src={ paymentBlocksImage }
alt="Payment Blocks"
className="store-features__feature-icon"
/>
{ translate( 'Powered by {{a}}Payment Blocks{{/a}}', {
components: {
a: (
<a
href={ localizeUrl(
'https://wordpress.com/support/wordpress-editor/blocks/payments/'
) }
target="_blank"
rel="noopener noreferrer"
onClick={ () => trackSupportLinkClick( 'simple' ) }
/>
),
},
} ) }
</footer>
</>
),
icon: shoppingBag,
value: 'simple',
actionText: translate( 'Continue' ),
},
{
key: 'power',
title: translate( 'More power' ),
description: (
<>
<span className="store-features__requirements">
{ hasWooFeature
? translate( 'Included in your plan' )
: // translators: %(planName)s is the name of the Creator/Business plan
translate( 'Requires a {{a}}%(planName)s plan{{/a}}', {
components: {
a: (
<a
href={ `/plans/${ siteSlug }` }
target="_blank"
rel="noopener noreferrer"
/>
),
},
args: {
planName: getPlan( PLAN_BUSINESS )?.getTitle() || '',
},
} ) }
</span>
<p>
{ translate(
'If you have multiple products or require extensive order and shipping management then this might suit your needs better.'
) }
</p>
<footer className="store-features__powered-by">
<img
src={ wooCommerceImage }
alt="WooCommerce"
className="store-features__feature-icon"
/>
{ translate( 'Powered by {{a}}WooCommerce{{/a}}', {
components: {
a: (
<a
href={ localizeUrl(
'https://wordpress.com/support/introduction-to-woocommerce/'
) }
target="_blank"
rel="noopener noreferrer"
onClick={ () => trackSupportLinkClick( 'power' ) }
/>
),
},
} ) }
</footer>
</>
),
icon: truck,
value: 'power',
actionText: hasWooFeature ? translate( 'Continue' ) : translate( 'Upgrade' ),
},
] as SelectItem< StoreFeatureSet >[];
}
|