forked from woocommerce/google-listings-and-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathads-campaign.js
More file actions
112 lines (107 loc) · 3.54 KB
/
ads-campaign.js
File metadata and controls
112 lines (107 loc) · 3.54 KB
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
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import StepContent from '.~/components/stepper/step-content';
import StepContentHeader from '.~/components/stepper/step-content-header';
import StepContentFooter from '.~/components/stepper/step-content-footer';
import AppDocumentationLink from '.~/components/app-documentation-link';
import AppButton from '.~/components/app-button';
import { useAdaptiveFormContext } from '.~/components/adaptive-form';
import AudienceSection from './audience-section';
import BudgetSection from './budget-section';
import { CampaignPreviewCard } from './campaign-preview';
import FaqsSection from './faqs-section';
/**
* @typedef {import('.~/data/actions').Campaign} Campaign
*/
/**
* Renders the container of the form content for campaign management.
*
* Please note that this component relies on an CampaignAssetsForm's context and custom adapter,
* so it expects a `CampaignAssetsForm` to existing in its parents.
*
* @fires gla_documentation_link_click with `{ context: 'create-ads' | 'edit-ads' | 'setup-ads', link_id: 'see-what-ads-look-like', href: 'https://support.google.com/google-ads/answer/6275294' }`
*
* @param {Object} props React props.
* @param {Campaign} [props.campaign] Campaign data to be edited. If not provided, this component will show campaign creation UI.
* @param {() => void} props.onContinue Callback called once continue button is clicked.
* @param {'create-ads'|'edit-ads'|'setup-ads'} props.trackingContext A context indicating which page this component is used on. This will be the value of `context` in the track event properties.
*/
export default function AdsCampaign( {
campaign,
onContinue,
trackingContext,
} ) {
const isCreation = ! campaign;
const formContext = useAdaptiveFormContext();
const { isValidForm } = formContext;
const disabledBudgetSection = ! formContext.values.countryCodes.length;
const helperText = isCreation
? __(
'You can only choose from countries you’ve selected during product listings configuration.',
'google-listings-and-ads'
)
: __(
'Once a campaign has been created, you cannot change the target country(s).',
'google-listings-and-ads'
);
return (
<StepContent>
<StepContentHeader
title={
isCreation
? __(
'Create your paid campaign',
'google-listings-and-ads'
)
: __(
'Edit your paid campaign',
'google-listings-and-ads'
)
}
description={ createInterpolateElement(
__(
'Paid Performance Max campaigns are automatically optimized for you by Google. <link>See what your ads will look like.</link>',
'google-listings-and-ads'
),
{
link: (
<AppDocumentationLink
context={ trackingContext }
linkId="see-what-ads-look-like"
href="https://support.google.com/google-ads/answer/6275294"
/>
),
}
) }
/>
<AudienceSection
disabled={ ! isCreation }
multiple={ isCreation || campaign.allowMultiple }
countrySelectHelperText={ helperText }
formProps={ formContext }
/>
<BudgetSection
formProps={ formContext }
disabled={ disabledBudgetSection }
>
<CampaignPreviewCard />
</BudgetSection>
<FaqsSection />
<StepContentFooter>
<AppButton
isPrimary
disabled={ ! isValidForm }
onClick={ onContinue }
>
{ __( 'Continue', 'google-listings-and-ads' ) }
</AppButton>
</StepContentFooter>
</StepContent>
);
}