Skip to content

Commit 73e1f41

Browse files
author
Nicolas Pierre-charles
committed
feat(ips): remove mrc modifications
ref: #MANAGER-19934 Signed-off-by: Nicolas Pierre-charles <[email protected]>
1 parent 677df7d commit 73e1f41

File tree

18 files changed

+356
-91
lines changed

18 files changed

+356
-91
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from './headers/headers.component';
22
export * from './price/price.component';
3-
export * from './price/price.utils';
43
export * from './dashboard-tile/dashboard-tile.component';
54
export * from './dashboard-tile/tile-block.component';
65
export * from './ManagerTile/manager-tile.component';

packages/manager-react-components/src/components/content/price/price.component.tsx

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ export function Price({
2222
ovhSubsidiary,
2323
locale,
2424
isConvertIntervalUnit,
25-
isStartingPrice,
26-
suffix = '',
27-
freePriceLabel,
2825
}: Readonly<PriceProps>) {
2926
const { t } = useTranslation('price');
3027
const isAsiaFormat = ['ASIA', 'AU', 'IN', 'SG'].includes(ovhSubsidiary);
@@ -69,7 +66,7 @@ export function Price({
6966
const components = [
7067
{
7168
condition: value === 0,
72-
component: <span>{freePriceLabel ?? t('price_free')}</span>,
69+
component: <span>{t('price_free')}</span>,
7370
},
7471
{
7572
condition: isFrenchFormat && tax > 0,
@@ -84,11 +81,6 @@ export function Price({
8481
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
8582
{intervalUnitText}
8683
</span>
87-
{suffix && (
88-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
89-
{suffix}
90-
</span>
91-
)}
9284
<TextPriceContent>
9385
<span className="text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
9486
({priceWithTax}
@@ -113,11 +105,6 @@ export function Price({
113105
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
114106
{intervalUnitText}
115107
</span>
116-
{suffix && (
117-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
118-
{suffix}
119-
</span>
120-
)}
121108
</>
122109
),
123110
},
@@ -131,11 +118,6 @@ export function Price({
131118
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
132119
{intervalUnitText}
133120
</span>
134-
{suffix && (
135-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
136-
{suffix}
137-
</span>
138-
)}
139121
</>
140122
),
141123
},
@@ -152,11 +134,6 @@ export function Price({
152134
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
153135
{intervalUnitText}
154136
</span>
155-
{suffix && (
156-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
157-
{suffix}
158-
</span>
159-
)}
160137
</>
161138
),
162139
},
@@ -173,11 +150,6 @@ export function Price({
173150
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
174151
{intervalUnitText}
175152
</span>
176-
{suffix && (
177-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
178-
{suffix}
179-
</span>
180-
)}
181153
<TextPriceContent>
182154
<span className="text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
183155
({priceWithTax}
@@ -199,11 +171,6 @@ export function Price({
199171
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
200172
{intervalUnitText}
201173
</span>
202-
{suffix && (
203-
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
204-
{suffix}
205-
</span>
206-
)}
207174
</>
208175
),
209176
},
@@ -214,12 +181,7 @@ export function Price({
214181
return <></>;
215182
}
216183

217-
return (
218-
<OdsText>
219-
{isStartingPrice && value > 0 ? t('price_from_label') : ''}
220-
{matchingComponent.component}
221-
</OdsText>
222-
);
184+
return <OdsText>{matchingComponent.component}</OdsText>;
223185
}
224186

225187
export default Price;

packages/manager-react-components/src/components/content/price/price.utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ export interface PriceProps {
1717
isConvertIntervalUnit?: boolean;
1818
/** The locale for price formatting */
1919
locale: string;
20-
suffix?: string;
21-
isStartingPrice?: boolean;
22-
freePriceLabel?: string;
2320
}
2421

2522
export const getPrice = (value: number, tax?: number): number => {

packages/manager-react-components/src/components/content/price/translations/Messages_fr_FR.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"price_ht_label": "HT",
33
"price_ttc_label": "TTC",
4-
"price_from_label": "à partir de ",
54
"price_free": "Inclus",
65
"price_gst_excl_label": "ex. GST",
76
"price_gst_incl_label": "incl. GST",

packages/manager-react-components/src/components/region/translations/region/Messages_fr_FR.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"region_eu-central-waw": "Europe (Poland - Warsaw)",
99
"region_eu-west-eri": "Europe (UK - Erith)",
1010
"region_us-east-vin": "North America (US - East - Vinthill)",
11-
"region_us-east-va": "North America (US - East - Vinthill 2)",
1211
"region_us-west-hil": "North America (US - West - Hillsboro)",
1312
"region_ca-east-bhs": "North America (Canada - East - Beauharnois)",
1413
"region_ap-southeast-sgp": "Asia Pacific (Singapore - Singapore)",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"price_ht_label": "HT",
3+
"price_ttc_label": "TTC",
4+
"price_from_label": "à partir de ",
5+
"price_free": "Inclus",
6+
"price_gst_excl_label": "ex. GST",
7+
"price_gst_incl_label": "incl. GST",
8+
"price_per_month": "/mois",
9+
"price_per_year": "/an",
10+
"price_per_day": "/jour"
11+
}

packages/manager/apps/ips/src/components/PriceDescription/PriceDescription.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import {
33
IntervalUnitType,
44
OvhSubsidiary,
5-
Price,
65
} from '@ovh-ux/manager-react-components';
76
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
87
import { OdsSpinner, OdsText } from '@ovhcloud/ods-components/react';
98
import { ODS_SPINNER_SIZE, ODS_TEXT_PRESET } from '@ovhcloud/ods-components';
109
import { useTranslation } from 'react-i18next';
10+
import { Price } from '@/components/price';
1111

1212
export type PriceFooterProps = {
1313
price: number | null;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './price.component';
2+
export * from './price.utils';
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { OdsText } from '@ovhcloud/ods-components/react';
4+
import { IntervalUnitType } from '@ovh-ux/manager-react-components';
5+
import {
6+
getPrice,
7+
convertIntervalPrice,
8+
getPriceTextFormatted,
9+
PriceProps,
10+
} from './price.utils';
11+
import { TRANSLATION_NAMESPACES } from '@/utils';
12+
13+
const TextPriceContent: React.FC<{ children: React.ReactNode }> = ({
14+
children,
15+
}) => <span className="ml-1">{children}</span>;
16+
17+
export function Price({
18+
value,
19+
intervalUnit,
20+
tax,
21+
ovhSubsidiary,
22+
locale,
23+
isConvertIntervalUnit,
24+
isStartingPrice,
25+
suffix = '',
26+
freePriceLabel,
27+
}: Readonly<PriceProps>) {
28+
const { t } = useTranslation(TRANSLATION_NAMESPACES.price);
29+
const isAsiaFormat = ['ASIA', 'AU', 'IN', 'SG'].includes(ovhSubsidiary);
30+
const isGermanFormat = ['DE', 'FI', 'SN'].includes(ovhSubsidiary);
31+
const isFrenchFormat = [
32+
'CZ',
33+
'ES',
34+
'FR',
35+
'GB',
36+
'IE',
37+
'IT',
38+
'LT',
39+
'MA',
40+
'NL',
41+
'PL',
42+
'PT',
43+
'TN',
44+
].includes(ovhSubsidiary);
45+
const isUSFormat = ['CA', 'QC', 'US', 'WE', 'WS'].includes(ovhSubsidiary);
46+
47+
const convertedValue = isConvertIntervalUnit
48+
? convertIntervalPrice(value, intervalUnit)
49+
: value;
50+
const convertedTax = isConvertIntervalUnit
51+
? convertIntervalPrice(tax || 0, intervalUnit)
52+
: tax || 0;
53+
54+
const priceWithoutTax = getPriceTextFormatted(
55+
ovhSubsidiary,
56+
locale,
57+
getPrice(convertedValue),
58+
);
59+
const priceWithTax = getPriceTextFormatted(
60+
ovhSubsidiary,
61+
locale,
62+
getPrice(convertedValue, convertedTax),
63+
);
64+
const intervalUnitText =
65+
intervalUnit && intervalUnit !== IntervalUnitType.none
66+
? t(`price_per_${intervalUnit}`)
67+
: '';
68+
const components = [
69+
{
70+
condition: value === 0,
71+
component: <span>{freePriceLabel ?? t('price_free')}</span>,
72+
},
73+
{
74+
condition: isFrenchFormat && tax > 0,
75+
component: (
76+
<>
77+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
78+
{priceWithoutTax}
79+
</span>
80+
<span className="text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
81+
{t('price_ht_label')}
82+
</span>
83+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
84+
{intervalUnitText}
85+
</span>
86+
{suffix && (
87+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
88+
{suffix}
89+
</span>
90+
)}
91+
<TextPriceContent>
92+
<span className="text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
93+
({priceWithTax}
94+
</span>
95+
<span className="ml-1 text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
96+
{t('price_ttc_label')})
97+
</span>
98+
</TextPriceContent>
99+
</>
100+
),
101+
},
102+
{
103+
condition: isFrenchFormat && !tax,
104+
component: (
105+
<>
106+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
107+
{priceWithoutTax}
108+
</span>
109+
<span className="text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
110+
{t('price_ht_label')}
111+
</span>
112+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
113+
{intervalUnitText}
114+
</span>
115+
{suffix && (
116+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
117+
{suffix}
118+
</span>
119+
)}
120+
</>
121+
),
122+
},
123+
{
124+
condition: isGermanFormat && tax > 0,
125+
component: (
126+
<>
127+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
128+
{priceWithTax}
129+
</span>
130+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
131+
{intervalUnitText}
132+
</span>
133+
{suffix && (
134+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
135+
{suffix}
136+
</span>
137+
)}
138+
</>
139+
),
140+
},
141+
{
142+
condition: isAsiaFormat && (!tax || tax === 0),
143+
component: (
144+
<>
145+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
146+
{priceWithoutTax}
147+
</span>
148+
<span className="text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
149+
{t('price_gst_excl_label')}
150+
</span>
151+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
152+
{intervalUnitText}
153+
</span>
154+
{suffix && (
155+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
156+
{suffix}
157+
</span>
158+
)}
159+
</>
160+
),
161+
},
162+
{
163+
condition: isAsiaFormat,
164+
component: (
165+
<>
166+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
167+
{priceWithoutTax}
168+
</span>
169+
<span className="text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
170+
{t('price_gst_excl_label')}
171+
</span>
172+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
173+
{intervalUnitText}
174+
</span>
175+
{suffix && (
176+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
177+
{suffix}
178+
</span>
179+
)}
180+
<TextPriceContent>
181+
<span className="text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
182+
({priceWithTax}
183+
</span>
184+
<span className="ml-1 text-[--ods-color-neutral-500] text-[14px] leading-[18px] font-semibold">
185+
{t('price_gst_incl_label')})
186+
</span>
187+
</TextPriceContent>
188+
</>
189+
),
190+
},
191+
{
192+
condition: isUSFormat,
193+
component: (
194+
<>
195+
<span className="mr-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
196+
{priceWithoutTax}
197+
</span>
198+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
199+
{intervalUnitText}
200+
</span>
201+
{suffix && (
202+
<span className="ml-1 text-[--ods-color-text] text-[16px] leading-[20px] font-semibold">
203+
{suffix}
204+
</span>
205+
)}
206+
</>
207+
),
208+
},
209+
];
210+
211+
const matchingComponent = components.find(({ condition }) => condition);
212+
if (!matchingComponent) {
213+
return <></>;
214+
}
215+
216+
return (
217+
<OdsText>
218+
{isStartingPrice && value > 0 ? t('price_from_label') : ''}
219+
{matchingComponent.component}
220+
</OdsText>
221+
);
222+
}
223+
224+
export default Price;

0 commit comments

Comments
 (0)