-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use discount api response for cancellation offer payment date #1384
Conversation
…ancellation offer journey
581ef98
to
74d0a91
Compare
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.
Looks good! I left some nitpicky comments to take or leave, see what you think (no obligation to make any changes, I think they're all subjective).
const strikethroughPrice = routerState.nonDiscountedPayments.reduce( | ||
(prev, current) => | ||
prev && prev.amount > current.amount ? prev : current, | ||
).amount; |
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.
Not that I'm not a fan of reduce
(I am, and think I probably overuse it) but what about this as an alternative? Maybe it's slightly clearer what the intention is?
const strikethroughPrice = routerState.nonDiscountedPayments.reduce( | |
(prev, current) => | |
prev && prev.amount > current.amount ? prev : current, | |
).amount; | |
const strikethroughPrice = Math.max(...routerState.nonDiscountedPayments.map(p => p.amount)); |
Or splitting it into two:
const allAmounts = routerState.nonDiscountedPayments.map(p => p.amount);
const strikeThroughPrice = Math.max(...allAmounts);
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.
yeah I like this 👍
const nextNonDiscountedPrice = routerState.nonDiscountedPayments.reduce( | ||
(prev, current) => | ||
prev && prev.amount > current.amount ? prev : current, | ||
).amount; |
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.
Would it be worth extracting this to a method, since it's the same logic repeated in SupporterPlusOffer.tsx
?
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.
yep, good shout 👍
…various components into a utility function that can be shared
What does this PR change?
Use the discount api response to return the next payment price (after the cancellation offer period ends). This should handle the case where the returning payment price will be different from the price paid before the offer was taken up, a price rise for example 👍