Skip to content

Commit 8c4701d

Browse files
committed
feat(mrc): updating the price component with the isStartingPrice, suffix and freePriceLabel props
ref: #MANAGER-15320 Signed-off-by: aderghamov <[email protected]>
1 parent d9832c3 commit 8c4701d

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

packages/manager-ui-kit/src/components/price/Price.component.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export function Price({
2525
ovhSubsidiary,
2626
locale,
2727
isConvertIntervalUnit,
28+
isStartingPrice,
29+
suffix = '',
30+
freePriceLabel,
2831
}: Readonly<PriceProps>) {
2932
const { t } = useTranslation('price');
3033

@@ -53,7 +56,7 @@ export function Price({
5356
const components = [
5457
{
5558
condition: value === 0,
56-
component: <span>{t('price_free')}</span>,
59+
component: <span>{freePriceLabel ?? t('price_free')}</span>,
5760
},
5861
{
5962
condition: isFrenchFormat && tax > 0,
@@ -63,6 +66,7 @@ export function Price({
6366
price={priceWithoutTax}
6467
label={t('price_ht_label')}
6568
intervalUnitText={intervalUnitText}
69+
suffix={suffix}
6670
/>
6771
<PriceText
6872
price={priceWithTax}
@@ -79,12 +83,18 @@ export function Price({
7983
price={priceWithoutTax}
8084
label={t('price_ht_label')}
8185
intervalUnitText={intervalUnitText}
86+
suffix={suffix}
8287
/>
8388
),
8489
},
8590
{
8691
condition: isGermanFormat && tax > 0,
87-
component: <PriceText price={priceWithTax} intervalUnitText={intervalUnitText} />,
92+
component: (
93+
<PriceText
94+
price={priceWithTax}
95+
intervalUnitText={intervalUnitText}
96+
suffix={suffix}
97+
/>),
8898
},
8999
{
90100
condition: isAsiaFormat && (!tax || tax === 0),
@@ -93,6 +103,7 @@ export function Price({
93103
price={priceWithoutTax}
94104
label={t('price_gst_excl_label')}
95105
intervalUnitText={intervalUnitText}
106+
suffix={suffix}
96107
/>
97108
),
98109
},
@@ -104,6 +115,7 @@ export function Price({
104115
price={priceWithoutTax}
105116
label={t('price_gst_excl_label')}
106117
intervalUnitText={intervalUnitText}
118+
suffix={suffix}
107119
/>
108120
<PriceText
109121
price={priceWithTax}
@@ -115,7 +127,12 @@ export function Price({
115127
},
116128
{
117129
condition: isUSFormat,
118-
component: <PriceText price={priceWithoutTax} intervalUnitText={intervalUnitText} />,
130+
component: (
131+
<PriceText
132+
price={priceWithoutTax}
133+
intervalUnitText={intervalUnitText}
134+
suffix={suffix}
135+
/>),
119136
},
120137
];
121138

@@ -124,7 +141,11 @@ export function Price({
124141
return null;
125142
}
126143

127-
return <Text>{matchingComponent.component}</Text>;
144+
return (
145+
<Text>
146+
{isStartingPrice && value > 0 ? t('price_from_label') : ''}
147+
{matchingComponent.component}
148+
</Text>);
128149
}
129150

130151
export default Price;

packages/manager-ui-kit/src/components/price/Price.props.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ export type PriceProps = {
1313
isConvertIntervalUnit?: boolean;
1414
/** The locale for price formatting */
1515
locale: string;
16+
/** The suffix for price formatting */
17+
suffix?: string;
18+
/** states if the price should be displayed as a starting price */
19+
isStartingPrice?: boolean;
20+
/** the label to display when the price is free */
21+
freePriceLabel?: string;
1622
};

packages/manager-ui-kit/src/components/price/price-text/PriceText.component.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const PriceText: React.FC<PriceTextProps> = ({
1111
price,
1212
intervalUnitText,
1313
label,
14+
suffix
1415
}) => (
1516
<Text
1617
preset={TEXT_PRESET.span}
@@ -35,6 +36,11 @@ export const PriceText: React.FC<PriceTextProps> = ({
3536
{intervalUnitText}
3637
</Text>
3738
)}
39+
{suffix && (
40+
<Text preset={TEXT_PRESET.span} className="mr-1">
41+
{suffix}
42+
</Text>
43+
)}
3844
{preset === PriceTextPreset.WITH_TAX && ')'}
3945
</Text>
4046
);

packages/manager-ui-kit/src/components/price/price-text/PriceText.props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export type PriceTextProps = {
88
price: string;
99
label?: string;
1010
intervalUnitText?: string;
11+
suffix?: string;
1112
};

packages/manager-ui-kit/src/components/price/translations/Messages_fr_FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"price_ht_label": "HT",
33
"price_ttc_label": "TTC",
4+
"price_from_label": "à partir de ",
45
"price_free": "Inclus",
56
"price_gst_excl_label": "ex. GST",
67
"price_gst_incl_label": "incl. GST",

0 commit comments

Comments
 (0)