From 3d5532c41a16748dc27d614078b8c56a213a0f55 Mon Sep 17 00:00:00 2001 From: Paul Naszalyi Date: Tue, 12 Nov 2024 23:15:22 +0100 Subject: [PATCH] Fix Price.native --- .../react/components/price/Price.native.tsx | 21 ++++++++----------- .../price/test/Price.native.test.tsx | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/react/components/price/Price.native.tsx b/packages/react/components/price/Price.native.tsx index 501988a2..8d813fee 100644 --- a/packages/react/components/price/Price.native.tsx +++ b/packages/react/components/price/Price.native.tsx @@ -25,15 +25,12 @@ import { StatesContext } from '@/context/providerStates' * @param level {PriceLevel} Price custom size * @param style {Object} Additional style * @param inverted {boolean} Inverted Price Color - * @param children {React.ReactNode} * @param align {Alignable} Price alignement * @param inline {boolean} Inline display Price * @param testId {string} id for test * @param accessibilityLabel {string} * @param oldAmount {boolean} Striked Amount Price * @param overline {string} Price overline - * @param tagAmount {number} Tag amount - * @param tagSymbol {number} Tag symbol */ const Price = ({ amount, @@ -48,14 +45,14 @@ const Price = ({ accessibilityLabel, oldAmount, overline, - tagAmount, - tagSymbol, + tagValue, + tagLabel, ...others }: PriceProps): JSX.Element => { const statesContext = useContext(StatesContext) - const isNegative = amount < 0 - const absoluteAmount = Math.abs(amount) + const isNegative = amount ? amount < 0 : false + const absoluteAmount = amount ? Math.abs(amount) : 0 const absoluteWhole = Math.floor(absoluteAmount) const whole = isNegative ? -absoluteWhole : absoluteWhole @@ -276,7 +273,7 @@ const Price = ({ {overline && {overline}} - + )} - {tagAmount && ( + {tagValue && ( @@ -344,15 +341,15 @@ const Price = ({ style={[styles.tagTextAmount]} typo={[TypographyBold.TEXT_WEIGHT_SEMIBOLD, TypographyColor.TEXT_WHITE]} > - {tagAmount} {tagSymbol ? tagSymbol : '€'} + {tagValue} - {tagSymbol === '€' && period && ( + {tagLabel && ( {' '} - /{period} + /{tagLabel} )} diff --git a/packages/react/components/price/test/Price.native.test.tsx b/packages/react/components/price/test/Price.native.test.tsx index 3ac1b319..bdd2f3ad 100644 --- a/packages/react/components/price/test/Price.native.test.tsx +++ b/packages/react/components/price/test/Price.native.test.tsx @@ -4,7 +4,7 @@ import Price from '../Price' describe('Price', () => { it('renders correctly with whole amount', () => { - render() + render() expect(screen.getByText('24')).toBeOnTheScreen() }) })