From 6b3fbdf16b9a166a2e42590fa7e5371cbc47acd1 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Wed, 21 Dec 2022 02:38:56 +0800 Subject: [PATCH] Display new campaign types in create campaign modal. --- .../Campaigns/Campaigns.scss | 33 ++++- .../Campaigns/CampaignsCardHeader.tsx | 124 ++++++++++++++---- .../Campaigns/useNewCampaignTypes.ts | 38 ++++++ .../client/marketing/types/CampaignType.ts | 9 ++ 4 files changed, 170 insertions(+), 34 deletions(-) create mode 100644 plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/useNewCampaignTypes.ts create mode 100644 plugins/woocommerce-admin/client/marketing/types/CampaignType.ts diff --git a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.scss b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.scss index d35fa4ecd9b..9d3b138e222 100644 --- a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.scss +++ b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.scss @@ -54,11 +54,16 @@ .woocommerce-marketing-create-campaign-modal { max-width: 600px; - &__question-label { - font-size: 14px; - font-weight: 600; - line-height: 17px; - margin-bottom: 16px; + .woocommerce-marketing-new-campaigns { + padding-top: $gap-large; + padding-bottom: $gap; + + &__question-label { + font-size: 14px; + font-weight: 600; + line-height: 17px; + margin-bottom: 16px; + } } .components-button.is-link { @@ -75,4 +80,22 @@ .components-card-divider { display: none; } + + .woocommerce-marketing-new-campaign-type { + padding: $gap 0; + + &__name { + font-weight: 600; + font-size: 14px; + line-height: 20px; + } + + &__description { + color: #555d66; + } + } + + .woocommerce-marketing-add-channels { + padding-top: $gap; + } } diff --git a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/CampaignsCardHeader.tsx b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/CampaignsCardHeader.tsx index fb39a577ed0..5ebd51161e8 100644 --- a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/CampaignsCardHeader.tsx +++ b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/CampaignsCardHeader.tsx @@ -3,7 +3,15 @@ */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; -import { Button, CardHeader, Modal, Icon } from '@wordpress/components'; +import { + Button, + CardHeader, + Modal, + Icon, + Flex, + FlexBlock, + FlexItem, +} from '@wordpress/components'; import { chevronUp, chevronDown } from '@wordpress/icons'; /** @@ -14,11 +22,13 @@ import { RecommendedChannelsList, } from '~/marketing/components'; import { useRecommendedChannels } from '~/marketing/hooks'; +import { useNewCampaignTypes } from './useNewCampaignTypes'; export const CampaignsCardHeader = () => { const [ open, setOpen ] = useState( false ); const [ collapsed, setCollapsed ] = useState( true ); - const { data } = useRecommendedChannels(); + const { loading, data: newCampaignTypes } = useNewCampaignTypes(); + const { data: recommendedChannels } = useRecommendedChannels(); const openModal = () => setOpen( true ); const closeModal = () => setOpen( false ); @@ -37,34 +47,90 @@ export const CampaignsCardHeader = () => { title={ __( 'Create a new campaign', 'woocommerce' ) } onRequestClose={ closeModal } > -
- { __( - 'Where would you like to promote your products?', - 'woocommerce' - ) } -
- { /* TODO: list of campaign type here. */ } - { data.length > 0 && ( - <> - - { ! collapsed && ( - +
+
+ { __( + 'Where would you like to promote your products?', + 'woocommerce' ) } - +
+
+ { newCampaignTypes.map( ( el ) => { + return ( + + + { + + + + + { el.name } + + + { el.description } + + + + + + + + ); + } ) } +
+
+ { recommendedChannels.length > 0 && ( +
+ + + + + { ! collapsed && ( + + + + ) } + +
) } ) } diff --git a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/useNewCampaignTypes.ts b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/useNewCampaignTypes.ts new file mode 100644 index 00000000000..ce8962935c6 --- /dev/null +++ b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/useNewCampaignTypes.ts @@ -0,0 +1,38 @@ +/** + * Internal dependencies + */ +import { CampaignType } from '~/marketing/types/CampaignType'; + +type UseNewCampaignTypes = { + loading: boolean; + data: Array< CampaignType >; +}; + +export const useNewCampaignTypes = (): UseNewCampaignTypes => { + return { + loading: false, + data: [ + { + id: 'google-ads', + icon: 'https://woocommerce.com/wp-content/plugins/wccom-plugins/marketing-tab-rest-api/icons/google.svg', + name: 'Google', + description: + 'Boost your product listings with a campaign that is automatically optimized to meet your goals', + createUrl: + 'https://wc1.test/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fsetup-ads', + channelSlug: 'google-listings-and-ads', + channelName: 'Google Listings and Ads', + }, + { + id: 'pinterest-ads', + icon: 'https://woocommerce.com/wp-content/plugins/wccom-plugins/marketing-tab-rest-api/icons/pinterest.svg', + name: 'Pinterest', + description: + 'Create single or multi image ads that promote a product relevant to people’s interests (Opens in Pinterest Ads Manager)', + createUrl: 'https://pinterest.com/create-campaign', + channelSlug: 'pinterest-for-woocommerce', + channelName: 'Pinterest for WooCommerce', + }, + ], + }; +}; diff --git a/plugins/woocommerce-admin/client/marketing/types/CampaignType.ts b/plugins/woocommerce-admin/client/marketing/types/CampaignType.ts new file mode 100644 index 00000000000..49e0418038a --- /dev/null +++ b/plugins/woocommerce-admin/client/marketing/types/CampaignType.ts @@ -0,0 +1,9 @@ +export type CampaignType = { + id: string; + icon: string; + name: string; + description: string; + createUrl: string; + channelName: string; + channelSlug: string; +};