Skip to content

Commit ad8b3a6

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 4b51e9d commit ad8b3a6

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

packages/manager-ui-kit/src/components/filters/filter-add/__tests__/FilterAdd.snapshot.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { act } from '@testing-library/react';
2-
import { beforeEach, vi } from 'vitest';
2+
import { afterEach, beforeEach, vi } from 'vitest';
33

44
import { cleanup, render } from '@/setupTest';
55

@@ -30,9 +30,11 @@ describe('FilterAdd Snapshot Tests', () => {
3030
isLoading: false,
3131
isFetched: true,
3232
});
33+
vi.useFakeTimers();
3334
});
3435

3536
afterEach(async () => {
37+
vi.useRealTimers();
3638
// Wait for all pending async operations and state updates
3739
await act(async () => {
3840
await new Promise((resolve) => setTimeout(resolve, 100));
@@ -69,6 +71,7 @@ describe('FilterAdd Snapshot Tests', () => {
6971
});
7072

7173
it('should match snapshot with date filter type', () => {
74+
vi.setSystemTime(new Date(2025, 9, 23, 13));
7275
const props = {
7376
columns: [
7477
{

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

Lines changed: 20 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,15 @@ 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 price={priceWithTax} intervalUnitText={intervalUnitText} suffix={suffix} />
94+
),
8895
},
8996
{
9097
condition: isAsiaFormat && (!tax || tax === 0),
@@ -93,6 +100,7 @@ export function Price({
93100
price={priceWithoutTax}
94101
label={t('price_gst_excl_label')}
95102
intervalUnitText={intervalUnitText}
103+
suffix={suffix}
96104
/>
97105
),
98106
},
@@ -104,6 +112,7 @@ export function Price({
104112
price={priceWithoutTax}
105113
label={t('price_gst_excl_label')}
106114
intervalUnitText={intervalUnitText}
115+
suffix={suffix}
107116
/>
108117
<PriceText
109118
price={priceWithTax}
@@ -115,7 +124,9 @@ export function Price({
115124
},
116125
{
117126
condition: isUSFormat,
118-
component: <PriceText price={priceWithoutTax} intervalUnitText={intervalUnitText} />,
127+
component: (
128+
<PriceText price={priceWithoutTax} intervalUnitText={intervalUnitText} suffix={suffix} />
129+
),
119130
},
120131
];
121132

@@ -124,7 +135,12 @@ export function Price({
124135
return null;
125136
}
126137

127-
return <Text>{matchingComponent.component}</Text>;
138+
return (
139+
<Text>
140+
{isStartingPrice && value > 0 ? t('price_from_label') : ''}
141+
{matchingComponent.component}
142+
</Text>
143+
);
128144
}
129145

130146
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)