-
Notifications
You must be signed in to change notification settings - Fork 683
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
[PWA-178] Gift options support in cart page #2114
Conversation
|
packages/venia-ui/lib/components/CartPage/PriceAdjustments/GiftOptions/GiftOptions.js
Outdated
Show resolved
Hide resolved
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.
packages/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions.js
Outdated
Show resolved
Hide resolved
packages/venia-ui/lib/components/CartPage/PriceSummary/giftCardSummary.js
Outdated
Show resolved
Hide resolved
packages/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions.js
Outdated
Show resolved
Hide resolved
packages/venia-ui/lib/components/CartPage/PriceAdjustments/GiftOptions/GiftOptions.js
Outdated
Show resolved
Hide resolved
packages/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions.js
Outdated
Show resolved
Hide resolved
packages/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions.js
Outdated
Show resolved
Hide resolved
|
||
const resolvers = { | ||
Query: { | ||
gift_options: (_, __, { cache }) => { |
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.
I'm not sure if these can be async but you may consider moving the REST calls here to the resolvers. Basically you would only interact with graphql in the component/talon but the resolvers would actually handle doing the rest call and update the cache accordingly.
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.
Resolvers are temporary. I went with the easiest temporary option here. Making a network call from the hook gives me more control over when to make the call, for instance in case of gift message only send the request every 10 seconds. Yes, I can do this from the resolver as well, but the resolver can not differentiate between the checkbox and gift message.
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 flow I imagined was similar to how we used actions.
User input > call mutation (or invoke action) > call rest > augment cache (or redux store) with rest results
Right now we're doing both sort of simultaneously, which isn't necessarily wrong I guess, but it puts all the logic of doing the fetch within the component in a manner that we're trying to move away from in the long run.
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.
@tjwiebell @jimbo lemme know if I'm trying to scope creep here.
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 isn't relevant anymore since as of now we are only storing gift option choices and text to local storage through Apollo. When we work on Checkout we will need to make sure to add some step that pulls this data from the cache and submits it via REST when you click the checkout button.
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.
I would normally have done the API call on submit of the "step", which is Proceed to Checkout
or some variation of Continue
. With the way the forms are broken out, though, it may be easier to wait until Place Order
.
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.
Code looks good to me. Only a couple of very minor things to change. 👍
Remember to look at other components in the codebase for guidance; some patterns not enforced by the linter are pretty consistent here nonetheless.
I'll test it out while you're fixing it up, then return to approve.
packages/peregrine/lib/talons/CartPage/GiftOptions/useGiftOptions.js
Outdated
Show resolved
Hide resolved
|
||
const classes = useMemo(() => mergeClasses(defaultClasses, props.classes), [ | ||
props.classes | ||
]); |
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.
Don't bother memoizing this.
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.
Sure. Any particular reason?
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.
Just consistency. We don't memoize mergeClasses()
in any of the existing components (afaik), and I have minor concerns about things slipping through the cracks when we get to refactoring classify
one day.
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.
Thanks for fixing the validator! Sucks we had to do a one-off but hopefully we can figure out a long term solution for client-side schema at a later time :)
@revanth0212 I can see gift options even after disabling this setting in Admin UI. Is this expected? |
Oh man I didn't even realize this was a thing. I think that we should create a fast-follow that goes back and enables/disables cart features based on their admin toggles. This will probably require either some build or runtime GQL check. |
Description
Gift Options Support in Venia Cart Page
Related Issue
Closes PWA-178
Verification Stakeholders
@soumya-ashok
@jimbo
Verification Steps
See Gift Options
section.Screenshots / Screen Captures
Checklist