-
Notifications
You must be signed in to change notification settings - Fork 1
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
FIX PRICE.native #257
base: main
Are you sure you want to change the base?
FIX PRICE.native #257
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/react/components/price/Price.native.tsx (2)
290-290
: Consider extracting repeated conditionsThe undefined checks for
amount
andoldAmount
are used multiple times. Consider extracting these into variables for better maintainability.+ const hasAmount = amount !== undefined; + const hasOldAmount = oldAmount !== undefined; + - {amount !== undefined && oldAmount !== undefined && <Spacer horizontal size={SpacerSize.ONE} />} + {hasAmount && hasOldAmount && <Spacer horizontal size={SpacerSize.ONE} />}
Line range hint
291-305
: Consider extracting price display logicThe price display logic is duplicated between the current and striked price sections. Consider extracting this into a reusable component or function.
Example approach:
type PriceDisplayProps = { whole: number; cents: string; mention?: string; period?: string; hideCents: boolean; styles: any; isStriked?: boolean; }; const PriceDisplay = ({ whole, cents, mention, period, hideCents, styles, isStriked }: PriceDisplayProps) => ( <View style={[{ flexDirection: 'row' }]}> <View style={[styles.priceContainer]}> <Text style={[ styles.price, isStriked ? styles.priceFontSizeStriked : styles.priceFontSize, isStriked ? styles.priceStrikedColor : styles.priceColor, ]} >{`${whole}`}</Text> </View> <View style={[styles.priceContainer]}> <Text style={[ styles.cents, isStriked ? styles.centsFontSizeStriked : styles.centsFontSize, isStriked ? styles.priceStrikedColor : styles.priceColor, ]} > €{!hideCents && (cents || '00')} {mention && mention} </Text> <Text style={[ styles.period, isStriked ? styles.periodFontSizeStriked : styles.periodFontSize, isStriked ? styles.priceStrikedColor : styles.priceColor, ]} > {period && `/${period}`} </Text> </View> </View> );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react/components/price/Price.native.tsx
(3 hunks)
🔇 Additional comments (3)
packages/react/components/price/Price.native.tsx (3)
1-6
: LGTM: Import changes are appropriate
The new imports support the component's enhanced functionality for spacing and state management.
Line range hint 1-305
: Overall changes look good to merge
The changes successfully address the PR objectives:
- Fixed conditions for
amount
andoldAmount
by using explicit undefined checks - Corrected
hideCents
property handling in both current and striked price displays
While there are opportunities for refactoring to improve maintainability, the current implementation is functionally correct and ready to merge.
Line range hint 271-289
: Improved price validation logic
The changes from truthy checks to explicit undefined checks are more robust, properly handling edge cases like when oldAmount
is 0. The cents display now correctly respects the hideCents
flag.
Let's verify the edge cases:
fix amount and oldAmount condition;
fix hideCents props
Summary by CodeRabbit
New Features
Bug Fixes
amount
andoldAmount
to prevent unintended behavior.Refactor