woocommerce/plugins/woocommerce-admin/client/marketplace/components
Boro Sitnikovski d3765b43c0
Add BFCM promo (#51739)
* Populate `window.wcMarketplace` for Marketing > Coupons

* TEST CODE: Add promotions dummy data to the endpoint for now

See [this comment](https://github.com/Automattic/woocommerce.com/issues/21783#issuecomment-2376471712) as to how we plan to manage this through WCCOM

* Initial implementation of the `<PromoCard>` component

This commit does the following:

- Implement the `PromoCard` component
- Refactor the existing `Promotions` component
    - Extract types
    - Add support for conditional rendering based on `pathname`
    - Accept optional parameter `promoCardOnly`
- Renders `PromoCard` wherever needed, as requested in the project thread.

Some remaining TODOs:

1. Dismiss functionality
2. Tracking
3. Figma design adjustments
    - CSS styling (Flexbox in Marketplace, etc.)
    - Percent image, wherever needed
    - Background image
4. BWC testing (e.g. ensuring that "Get more for your money" banner still works)

* Make sure that WCCOM also returns path so that earlier versions of in-app marketplace don't break (path undefined error)

* Update T&C link

After https://github.com/Automattic/woocommerce.com/issues/21840

* Implement promo banner dismissal logic and tracks

* Styling the WooCommerce > Extensions version of the promo component.

- Tweaked data on `class-wc-admin-assets.php` to pass `style` and `icon` attributes for that promo.
- Moved promo on this page from the marketplace `Header` component to the `Content`, above the Sales Banner notices.
- Deleted `percent.svg` and moved its content into a React component.
- CSS tweaks for this style of promo.
- Changes to elements of `PromoCard` component to allow the layout for this style.

* Fixed some TypeScript issues.

- Added guard condition in case `promotion.id` is undefined.
- Returning null if it isn't - but below `useState` hook, so we conform to rules of hooks.
- Setting default value for `promotion.cta_label` to satisfy TypeScript, which expects a node.

Style tweaks to `.promo-cta`. Vertical centering of text, hover colour, margins.

* Remove unnecessary unique identifier for each promo, and use a smarter way (URIs) to gather the visibility data

* Lint

* Revert test code

* Changelog

* Better code comments

* Changed `promoCardOnly` attribute of `Promotions` to `format`, to allow for more types in future.

* Update plugins/woocommerce-admin/client/marketplace/components/promotions/promotions.tsx

Co-authored-by: Boro Sitnikovski <buritomath@gmail.com>

* Styling promo cards at different breakpoints.
Moved homescreen promo to after store management links.

* Added condition to merge array of promos with the main `$promotions` array.

* Added `useEffect` so we only record Track event for view of promotion once.
Changed Tracks prefix to the shorter `marketplace_promo_`.

* Added Tracks events for both formats of promotions, `promo-card`, and the original `notice`.

* Merging two style blocks.

* Passing `format` to `recordEvent` instead of hard-coding it.

* Addressing linter errors.

* Moved operation merging promos into the main array into a separate method for greater clarity.

* Moved Promotions component on WooCommerce > Home to below task list.

* Styling tweaks.
Increased schedule of `woocommerce_marketplace_cron_fetch_promotions` cron job to twice daily.
Added guard conditions in `Promotions` in case `window.wcMarketplace.promotions` isn't defined or isn't an array.

* Reduced SVG size to 72px.

* Fixing linter error.

* Style tweaks. Using WP components colour vars for CTA and dismiss links.

* Fixing linter error.

* Reverting change to `schedule_cron_event`, as this method will not be present if only this branch is cherry-picked.

---------

Co-authored-by: And Finally <andfinally@users.noreply.github.com>
2024-10-03 15:36:06 +01:00
..
category-selector Marketplace: hide the scrollbar from the category selector (#51527) 2024-09-19 12:26:06 +00:00
connect-notice Use UTM parameters to link Tracks events: CTA from connect notice and successful site connection (#50126) 2024-08-01 14:01:21 +07:00
content Add BFCM promo (#51739) 2024-10-03 15:36:06 +01:00
discover In-App Marketplace: Record the legacy Tracks event for Discover page (#51163) 2024-09-12 21:13:13 +00:00
footer Changes to IAM footer (#51315) 2024-09-12 18:28:48 +05:30
header In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00
header-account Update Woo.com references to WooCommerce.com (#46259) 2024-04-09 09:50:15 +01:00
header-title [wccom-17713] Addressing design feedback. 2023-08-18 15:20:00 +01:00
icon-with-text Changes to IAM footer (#51315) 2024-09-12 18:28:48 +05:30
install-flow Update Woo.com references to WooCommerce.com (#46259) 2024-04-09 09:50:15 +01:00
likert-scale [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
load-more-button In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00
my-subscriptions Fix subscription status and action items for free (lifetime) subs (#51628) 2024-09-30 15:14:39 +02:00
notice [Performance]: Replace `classnames` usage with `clsx` (#47760) 2024-05-31 05:49:36 +02:00
product-card Change aspect ratio of images in theme cards in in-app marketplace (#51705) 2024-09-26 14:55:09 +01:00
product-list Show correct decimals on product price and show the sale price of products (#51499) 2024-09-20 21:13:01 +05:30
product-list-content Show correct decimals on product price and show the sale price of products (#51499) 2024-09-20 21:13:01 +05:30
product-list-header Add chevron after See more to the list header (#51199) 2024-09-10 18:28:31 +02:00
product-loader Marketplace - tracking enhancements (#41365) 2023-11-21 09:48:59 +03:00
products In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00
promo-card Add BFCM promo (#51739) 2024-10-03 15:36:06 +01:00
promotions Add BFCM promo (#51739) 2024-10-03 15:36:06 +01:00
search In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00
tabs In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00
woo-update-manager-plugin Update Woo.com references to WooCommerce.com (#46259) 2024-04-09 09:50:15 +01:00
constants.ts In app search improvements feature branch (#51413) 2024-09-18 14:14:30 +02:00