-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Free Listings + Paid Ads: Add the ads audience and budget sections #1655
Free Listings + Paid Ads: Add the ads audience and budget sections #1655
Conversation
…flow for paid campaign creation
c104831
to
3e0debd
Compare
{ ( formProps ) => { | ||
const { countryCodes } = formProps.values; | ||
const disabledAudience = | ||
googleAdsAccount?.status !== 'connected'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅 This status could be also defined as Constant I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 4d7da2b.
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validateForm When the amount is not a number, should not pass 1`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the amount is not a number, should not pass 2`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the amount is not a number, should not pass 3`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the amount is not a number, should not pass 4`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the amount is ≤ 0, should not pass 1`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the amount is ≤ 0, should not pass 2`] = `"Please make sure daily average cost is greater than 0."`; | ||
|
||
exports[`validateForm When the country codes array is empty, should not pass 1`] = `"Please select at least one country for your ads campaign."`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅 Maybe to consider switch to unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related discussions can be found in #893 (comment) and #927 (comment).
@@ -25,7 +25,7 @@ const validateForm = ( values ) => { | |||
); | |||
} | |||
|
|||
if ( values.amount <= 0 ) { | |||
if ( ! Number.isFinite( values.amount ) || values.amount <= 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ How comes amount
could be a non finite number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The budget amount will temporarily be set to undefined
when the input is disabled.
google-listings-and-ads/js/src/components/paid-ads/budget-section/index.js
Lines 41 to 50 in c08364f
/** | |
* In addition to the initial value setting during initialization, when `disabled` changes | |
* - from false to true, then clear filled amount to `undefined` for showing a blank <input>. | |
* - from true to false, then reset amount to the initial value passed from the consumer side. | |
*/ | |
const initialAmountRef = useRef( amount ); | |
useEffect( () => { | |
const nextAmount = disabled ? undefined : initialAmountRef.current; | |
setValue( 'amount', nextAmount ); | |
}, [ disabled, setValue ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ LGTM
- Tested the two sections match with figma and are disabled/enabled depending on if we have google ads connected.
I left some comments in code (minor 💅 )
Changes proposed in this Pull Request:
This PR implements the 📌 Ads audience and budget sections in #1610.
AudienceSection
component andBudgetSection
-related components.PaidAdsSectionsGroup
and forward it to the upper layer.amount
should only allow the number type (excludingNaN
).Screenshots:
Kapture.2022-08-26.at.18.11.03.mp4
Detailed test instructions:
💡 When re-entering step 4, the previously selected "continue setting up paid ads" state and entered form data are reset. Processing the selected state and entered form data will be developed in another PR.
💡 The disabled style covering the whole section is different from the visual on Figma. This's the expected style and has been confirmed with the Design team.
Changelog entry