wp-calypso icon indicating copy to clipboard operation
wp-calypso copied to clipboard

A4A: refactor marketplace type usage with HOC

Open andrii-lysenko opened this issue 9 months ago • 3 comments

Related to https://github.com/Automattic/jetpack-genesis/issues/358

Proposed Changes

This is a follow up to https://github.com/Automattic/wp-calypso/pull/91027 I wanted to refactor the logic to be more flexible and concise, so trying to use HOC here for the context. This way we will be able to use it in both Shopping cart element as well as in useShoppingCart hook without the need of passing parameters back and forth.

As a side note, should/could we do the same for ShoppingCartContext?

Why are these changes being made?

  • To improve the scalability and readability of the code

Testing Instructions

  • Navigate to /marketplace/products/ and check the toggle and it's behavior.
  • Navigate to /marketplace/products?purchase_type=referral, you should be immediately in referral mode.
  • Check that with flag disabled flags=-a4a-automated-referrals Marketplace acts as before.

Pre-merge Checklist

  • [ ] Has the general commit checklist been followed? (PCYsg-hS-p2)
  • [ ] Have you written new tests for your changes?
  • [ ] Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • [ ] Have you checked for TypeScript, React or other console errors?
  • [ ] Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • [ ] Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • [ ] For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

andrii-lysenko avatar May 24 '24 02:05 andrii-lysenko