-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(new-price-calculator): stop deriving purchase summary state from …
…selected offer (#4882) ## Describe your changes * We need to keep an active query for `PriceIntent` for all price calculator context. So I'm moving `useSyncPriceIntentState` call from `PurchaseFormV2` to `PriceCalculatorCmsPageContent` * Stop getting offer data used by `PurchaseSummary` form `selectedOfferAtom`. That one should be in sync with price intent changes to avoid unexpected behaviors. * It's hard to know which offer was just added to the cart while reseting price intent whenever something get's added. We do need to reset price intent whenever something get's added to the cart so I'm replacing _show purchase summary_ state with an _added offer_ state which `PurchaseSummary` can use for its UI. Showing/hiding `PurchaseSummary` now is about changing that state. With that said this is how it works now: * Price calculator get's initialized with price intent (P1) * User adds it to the cart * We store the offer that got added * We create a new price intent P2 and synchronize all atoms with it * We use the stored offer to render `PurchaseSummary` ## Justify why they are needed The issue https://github.com/user-attachments/assets/10a149f6-ced8-495d-8238-75d5d27412a2 `PurchaseHero` relies on `useIsPriceIntentStateReady()` which check the presence of a price intent. Since `useSyncPriceIntentState` was being called inside `PurchaseFormV2` we keep an active query for Price Intent until `PurchaseFormV2` is mounted. When something get's added to the cart we reset Price Intent and swap what's gets rendered at the right section: `PurchaseFormV2` --> `PurchaseSummary` marking the end of the flow. However `useIsPriceIntentStateReady()` will never return `true` because we don't sync priceIntentAtoms with the new Price Intent because `PurchaseFormV2` was unmounted. This causes the `PurchaseHero` never being rendered.
- Loading branch information
Showing
5 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters