Skip to content

Commit b7f0f0e

Browse files
authored
sync(*): master to develop
sync(*): master to develop
2 parents 5bf3d8f + 563b66c commit b7f0f0e

File tree

202 files changed

+2973
-1883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+2973
-1883
lines changed

packages/components/ovh-at-internet/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const AT_INTERNET_LEVEL2: Record<string, string> = {
1818
140: 'Manager-identity-security-operations',
1919
150: 'Manager-DedicatedServers',
2020
152: 'Manager-Network',
21+
157: 'Manager-Communications',
2122
};
2223

2324
export const AT_INTERNET_WEBSITE: Record<string, string> = {

packages/manager-tools/manager-pm/src/playbook/catalog/pnpm-private-modules.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
"turbo": "--filter @ovh-ux/manager-account",
1616
"pnpm": "packages/manager/modules/account"
1717
},
18-
{
19-
"turbo": "--filter @ovh-ux/manager-account-migration",
20-
"pnpm": "packages/manager/modules/account-migration"
21-
},
2218
{
2319
"turbo": "--filter @ovh-ux/manager-advices",
2420
"pnpm": "packages/manager/modules/advices"

packages/manager-tools/manager-pm/src/playbook/catalog/yarn-catalog.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"packages/manager/core/url-builder",
8383
"packages/manager/core/utils",
8484
"packages/manager/modules/account",
85-
"packages/manager/modules/account-migration",
8685
"packages/manager/modules/advices",
8786
"packages/manager/modules/at-internet-configuration",
8887
"packages/manager/modules/banner",

packages/manager/apps/account-creation/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
"@hookform/resolvers": "^5.1.1",
2222
"@ovh-ux/manager-common-translations": "^0.24.0",
2323
"@ovh-ux/manager-config": "^8.7.2",
24-
"@ovh-ux/manager-core-api": "^0.12.0",
2524
"@ovh-ux/manager-core-utils": "^0.4.9",
2625
"@ovh-ux/manager-gcj-module": "^0.5.1",
26+
"@ovh-ux/manager-core-api": "^0.19.1",
2727
"@ovh-ux/manager-react-components": "^2.43.1",
2828
"@ovh-ux/manager-react-core-application": "^0.13.2",
2929
"@ovh-ux/manager-react-shell-client": "^0.11.2",
30-
"@ovh-ux/request-tagger": "^0.4.1",
3130
"@ovh-ux/shell": "^4.9.0",
31+
"@ovh-ux/request-tagger": "^0.5.7",
3232
"@ovhcloud/ods-components": "^18.6.2",
3333
"@ovhcloud/ods-themes": "^18.6.2",
34-
"@tanstack/react-query": "^5.51.21",
34+
"@tanstack/react-query": "^5.64.1",
3535
"axios": "^1.1.2",
3636
"clsx": "^1.2.1",
3737
"element-internals-polyfill": "^3.0.0",
@@ -49,7 +49,7 @@
4949
"@ovh-ux/manager-vite-config": "^0.15.1",
5050
"@tanstack/react-query-devtools": "^5.51.21",
5151
"tailwindcss": "^3.4.4",
52-
"typescript": "^5.1.6",
52+
"typescript": "^5.9.2",
5353
"vite": "^6.0.7",
5454
"vitest": "^3.1.3"
5555
},

packages/manager/apps/account-creation/src/context/user/user.provider.spec.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import * as useApplicationsApi from '@/data/hooks/useApplications';
1313
import { urls } from '@/routes/routes.constant';
1414
import UserProvider from '@/context/user/user.provider';
1515

16+
vi.mock('@ovh-ux/manager-react-components', () => ({
17+
useFeatureAvailability: vi.fn(),
18+
}));
19+
1620
const url = 'https://fake-manager.com/signup';
1721
vi.spyOn(useApplicationsApi, 'useApplications').mockReturnValue({
1822
isFetched: true,
@@ -33,6 +37,12 @@ vi.spyOn(useApplicationsApi, 'useApplications').mockReturnValue({
3337
const mockedUsedNavigate = vi.fn();
3438
vi.mock('react-router-dom', () => ({
3539
useNavigate: () => mockedUsedNavigate,
40+
useSearchParams: () => [
41+
new URLSearchParams({
42+
test: 'test',
43+
}),
44+
vi.fn(),
45+
],
3646
}));
3747

3848
vi.mock('@/context/tracking/useTracking', () => ({
@@ -51,7 +61,20 @@ const renderComponent = () =>
5161
</QueryClientProvider>,
5262
);
5363

64+
5465
describe('User Provider', () => {
66+
beforeEach(() => {
67+
vi.mocked(MRC.useFeatureAvailability).mockReturnValue(({
68+
data: { 'account-creation': false },
69+
isFetched: true,
70+
isLoading: false,
71+
isError: false,
72+
error: null,
73+
status: 'success',
74+
refetch: vi.fn(),
75+
} as unknown) as MRC.UseFeatureAvailabilityResult<Record<string, boolean>>);
76+
});
77+
5578
it('should redirect to the settings page if there is no active session', async () => {
5679
vi.spyOn(useMeApi, 'useMe').mockReturnValue({
5780
isFetched: true,
@@ -60,7 +83,7 @@ describe('User Provider', () => {
6083
renderComponent();
6184

6285
await vi.waitFor(() => {
63-
expect(mockedUsedNavigate).toHaveBeenCalledWith(urls.settings);
86+
expect(mockedUsedNavigate).toHaveBeenCalledWith(`${urls.settings}?test=test`);
6487
});
6588
});
6689

@@ -74,7 +97,7 @@ describe('User Provider', () => {
7497
renderComponent();
7598

7699
await vi.waitFor(() => {
77-
expect(mockedUsedNavigate).toHaveBeenCalledWith(urls.accountType);
100+
expect(mockedUsedNavigate).toHaveBeenCalledWith(`${urls.accountType}?test=test`);
78101
});
79102
});
80103

packages/manager/apps/account-creation/src/context/user/user.provider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from 'react';
2-
import { useNavigate } from 'react-router-dom';
2+
import { useNavigate, useSearchParams } from 'react-router-dom';
33
import {
44
Country,
55
LegalForm,
@@ -24,6 +24,7 @@ type Props = {
2424

2525
export const UserProvider = ({ children = [] }: Props): JSX.Element => {
2626
const navigate = useNavigate();
27+
const [ searchParams ] = useSearchParams();
2728
const { setUser } = useTrackingContext();
2829
const { data: me, isFetched, error } = useMe({ retry: 0 });
2930
const { data: availability } = useFeatureAvailability(
@@ -50,7 +51,7 @@ export const UserProvider = ({ children = [] }: Props): JSX.Element => {
5051
useEffect(() => {
5152
if (isFetched) {
5253
if (error?.status === 401) {
53-
navigate(urls.settings);
54+
navigate(`${urls.settings}?${searchParams.toString()}`);
5455
return;
5556
}
5657
setLegalForm(me?.legalform);
@@ -70,7 +71,7 @@ export const UserProvider = ({ children = [] }: Props): JSX.Element => {
7071
if (!availability[NEW_ACCOUNT_CREATION_ACCESS_FEATURE]) {
7172
redirectToLegacySignup();
7273
} else {
73-
navigate(urls.accountType);
74+
navigate(`${urls.accountType}?${searchParams.toString()}`);
7475
}
7576
}
7677
}, [availability]);

packages/manager/apps/account-creation/src/data/api/settings.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import { Region } from '@ovh-ux/manager-config';
2-
import { v2 } from '@ovh-ux/manager-core-api';
2+
import { v6 } from '@ovh-ux/manager-core-api';
33
import { Setting } from '@/types/settings';
4-
import {
5-
MockedCASettings,
6-
MockedEUSettings,
7-
MockedUSSettings,
8-
} from '../mocks/settings.mock';
94

105
export const getSettings = async (region: Region) => {
11-
// const { data } = await v2.get<Setting[]>(`/account/settings?ovhIS=${region}`);
12-
console.log(region);
13-
const data = MockedEUSettings;
6+
const { data } = await v6.get<Setting[]>(
7+
`/newAccount/residentialCountry?ovhIS=${region}`,
8+
);
149
const result = new Map();
1510
data.forEach((setting) => {
1611
if (setting.billingCountries?.length) {

packages/manager/apps/account-creation/src/data/hooks/settings/useSettings.ts

Lines changed: 63 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,95 +6,84 @@ import { getSettings } from '../../api/settings';
66
import { BillingCountry, SupportLanguage } from '@/types/settings';
77
import { getRegion } from '@/helpers/region/regionHelper';
88

9-
export const useCountrySettings = () => {
10-
const { t } = useTranslation(NAMESPACES.COUNTRY);
11-
return useQuery({
9+
const useSettingsQuery = <T>(
10+
select: (settings: Map<string, BillingCountry[]>) => T,
11+
) =>
12+
useQuery({
1213
queryKey: ['settings'],
1314
queryFn: () => getSettings(getRegion()),
14-
select: (settings: Map<string, BillingCountry[]>) =>
15-
Array.from(settings.keys())
16-
.map((countryCode) => ({
17-
code: countryCode,
18-
label: t(`country_${countryCode}`),
19-
}))
20-
.sort((countryA, countryB) =>
21-
countryA.label > countryB.label ? 1 : -1,
22-
),
15+
select,
2316
});
17+
18+
export const useCountrySettings = () => {
19+
const { t } = useTranslation(NAMESPACES.COUNTRY);
20+
21+
return useSettingsQuery((settings) =>
22+
Array.from(settings.keys())
23+
.map((countryCode) => ({
24+
code: countryCode,
25+
label: t(`country_${countryCode}`),
26+
}))
27+
.sort((countryA, countryB) => (countryA.label > countryB.label ? 1 : -1)),
28+
);
2429
};
2530

2631
export const useCurrencySettings = (country?: string) =>
27-
useQuery({
28-
queryKey: ['settings'],
29-
queryFn: () => getSettings(getRegion()),
30-
select: (settings: Map<string, BillingCountry[]>) => {
31-
if (!country) {
32-
return [];
33-
}
34-
return (
35-
settings
36-
.get(country)
37-
?.reduce((currencies: Currency[], billingCountry) => {
38-
if (
39-
!currencies.find(
40-
(currency) => currency.code === billingCountry.currency.code,
41-
)
42-
) {
43-
currencies.push(billingCountry.currency);
44-
}
45-
return currencies;
46-
}, []) ?? []
47-
);
48-
},
32+
useSettingsQuery((settings) => {
33+
if (!country) return [];
34+
35+
return (
36+
settings
37+
.get(country)
38+
?.reduce((currencies: Currency[], billingCountry) => {
39+
if (
40+
!currencies.find(
41+
(currency) => currency.code === billingCountry.currency.code,
42+
)
43+
) {
44+
currencies.push(billingCountry.currency);
45+
}
46+
return currencies;
47+
}, []) ?? []
48+
);
4949
});
5050

5151
export const useLanguageSettings = (country?: string, currency?: string) =>
52-
useQuery({
53-
queryKey: ['settings'],
54-
queryFn: () => getSettings(getRegion()),
55-
select: (settings: Map<string, BillingCountry[]>) => {
56-
if (!(country && currency)) {
57-
return [];
58-
}
59-
return (
60-
settings
61-
.get(country)
62-
?.reduce((languages: SupportLanguage[], billingCountry) => {
63-
if (
64-
currency === billingCountry.currency.code &&
65-
!languages.includes(billingCountry.ietfLanguageTag)
66-
) {
67-
languages.push(billingCountry.ietfLanguageTag);
68-
}
69-
return languages;
70-
}, []) ?? []
71-
);
72-
},
52+
useSettingsQuery((settings) => {
53+
if (!(country && currency)) return [];
54+
55+
return (
56+
settings
57+
.get(country)
58+
?.reduce((languages: SupportLanguage[], billingCountry) => {
59+
if (
60+
currency === billingCountry.currency.code &&
61+
!languages.includes(billingCountry.ietfLanguageTag)
62+
) {
63+
languages.push(billingCountry.ietfLanguageTag);
64+
}
65+
return languages;
66+
}, []) ?? []
67+
);
7368
});
7469

7570
export const useSubsidiarySettings = (
7671
country?: string,
7772
currency?: string,
7873
language?: string,
7974
) => {
80-
return useQuery({
81-
queryKey: ['settings'],
82-
queryFn: () => getSettings(getRegion()),
83-
select: (settings: Map<string, BillingCountry[]>) => {
84-
if (!(country && currency && language)) {
85-
return null;
86-
}
87-
const foundCountry = settings
88-
.get(country)
89-
?.find(
90-
(billingCountry) =>
91-
billingCountry.currency.code === currency &&
92-
billingCountry.ietfLanguageTag === language,
93-
);
94-
if (!foundCountry) {
95-
return null;
96-
}
97-
return foundCountry.ovhSubsidiary;
98-
},
75+
return useSettingsQuery<string | null>((settings) => {
76+
if (!(country && currency && language)) {
77+
return null;
78+
}
79+
const foundCountry = settings
80+
.get(country)
81+
?.find(
82+
(billingCountry) =>
83+
billingCountry.currency.code === currency &&
84+
billingCountry.ietfLanguageTag === language,
85+
);
86+
87+
return foundCountry ? foundCountry.ovhSubsidiary : null;
9988
});
10089
};
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { useQuery } from '@tanstack/react-query';
2-
import { getApplications } from '../api/applications';
1+
import { DefinedInitialDataOptions, useQuery } from '@tanstack/react-query';
32

4-
export const useApplications = (enabled: boolean) =>
3+
import { Application } from '@ovh-ux/manager-config';
4+
5+
import { getApplications } from '@/data/api/applications';
6+
7+
export const useApplications = <Response = Record<string, Application>>(options: Partial<DefinedInitialDataOptions<Record<string, Application>, Error, Response>> = {},) =>
58
useQuery({
9+
...options,
610
queryKey: ['applications'],
711
queryFn: getApplications,
8-
enabled,
912
});

packages/manager/apps/account-creation/src/data/hooks/useMe.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export const useMe = (
1616
useQuery({
1717
queryKey: [`me`],
1818
queryFn: getMe,
19+
retry: 0,
1920
...options,
2021
});

0 commit comments

Comments
 (0)