Skip to content
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

Conversation

eason9487
Copy link
Member

@eason9487 eason9487 commented Aug 26, 2022

Changes proposed in this Pull Request:

This PR implements the 📌 Ads audience and budget sections in #1610.

  • Tweak UI for the AudienceSection component and BudgetSection-related components.
  • Add the ads audience and budget sections to step 4 of the onboarding flow for paid campaign creation.
    • Handle the form data of campaign creation in PaidAdsSectionsGroup and forward it to the upper layer.
  • Fix that the validation of campaign amount should only allow the number type (excluding NaN).

Screenshots:

Kapture.2022-08-26.at.18.11.03.mp4

Detailed test instructions:

  1. Go to step 4 of the onboarding flow.
  2. Disconnect the Google Ads account via the current UI if an account is already connected.
  3. Check if both the audience and budget sections are disabled when there is no connected Google Ads account.
  4. Create or connect to a Google Ads account.
  5. Check if both the audience and budget sections are editable after a Google Ads account is connected.
  6. Check if the "Create a paid ad campaign" at the bottom is disabled when the audience countries are empty or the budget amount is ≤ 0.

💡 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

@eason9487 eason9487 added the changelog: none Skip changelog entry for this PR label Aug 26, 2022
@eason9487 eason9487 requested a review from a team August 26, 2022 10:55
@eason9487 eason9487 self-assigned this Aug 26, 2022
@github-actions github-actions bot added changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement. labels Aug 26, 2022
@eason9487 eason9487 force-pushed the add/1610-audience-budget-sections branch from c104831 to 3e0debd Compare August 26, 2022 11:03
@eason9487 eason9487 removed type: enhancement The issue is a request for an enhancement. changelog: add A new feature, function, or functionality was added. labels Aug 26, 2022
Base automatically changed from add/1610-google-ads-account-section to feature/1610-streamlined-onboarding August 30, 2022 09:17
{ ( formProps ) => {
const { countryCodes } = formProps.values;
const disabledAudience =
googleAdsAccount?.status !== 'connected';
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 4d7da2b.

Comment on lines +1 to +15
// 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."`;
Copy link
Contributor

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.

Copy link
Member Author

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 ) {
Copy link
Contributor

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?

Copy link
Member Author

@eason9487 eason9487 Sep 1, 2022

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.

/**
* 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 ] );

Copy link
Contributor

@puntope puntope left a 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 💅 )

@eason9487 eason9487 merged commit f05b205 into feature/1610-streamlined-onboarding Sep 5, 2022
@eason9487 eason9487 deleted the add/1610-audience-budget-sections branch September 5, 2022 04:22
@eason9487 eason9487 added changelog: add A new feature, function, or functionality was added. and removed changelog: none Skip changelog entry for this PR labels Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants