From 880cdca7e48ca3cadb14ce8d497619da13edc0b9 Mon Sep 17 00:00:00 2001 From: Thibaud Crespin Date: Fri, 18 Oct 2024 00:31:51 +0200 Subject: [PATCH] fix(hycu): contact list by locale and tests ref: MANAGER-14504 Signed-off-by: Thibaud Crespin --- .../Description/Description.component.tsx | 35 +++++++++++++++++++ .../components/Loading/Loading.component.tsx | 4 ++- .../src/components/Order/PackSelection.tsx | 16 ++++++--- .../src/hooks/order/useOrderCatalogHYCU.ts | 4 +-- packages/manager/apps/hycu/src/index.tsx | 2 +- .../manager/apps/hycu/src/types/api.type.ts | 6 ---- .../apps/hycu/src/utils/contactList.ts | 23 ++++++++++++ 7 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 packages/manager/apps/hycu/src/components/Description/Description.component.tsx delete mode 100644 packages/manager/apps/hycu/src/types/api.type.ts create mode 100644 packages/manager/apps/hycu/src/utils/contactList.ts diff --git a/packages/manager/apps/hycu/src/components/Description/Description.component.tsx b/packages/manager/apps/hycu/src/components/Description/Description.component.tsx new file mode 100644 index 000000000000..d59d27c2cb9e --- /dev/null +++ b/packages/manager/apps/hycu/src/components/Description/Description.component.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { + ODS_THEME_COLOR_HUE, + ODS_THEME_COLOR_INTENT, + ODS_THEME_TYPOGRAPHY_LEVEL, + ODS_THEME_TYPOGRAPHY_SIZE, +} from '@ovhcloud/ods-common-theming'; +import { OsdsText } from '@ovhcloud/ods-components/react'; + +export interface CustomDescriptionProps { + children?: any; + className?: string; +} + +/** + * Copy of ODS component to pass i18n with components, not only strings + */ +export const CustomDescription: React.FC = ({ + children, + className, +}: CustomDescriptionProps) => { + return ( + + {children} + + ); +}; + +export default CustomDescription; diff --git a/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx b/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx index bb74a4fa8e15..1f8e45b3d2ed 100644 --- a/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx +++ b/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx @@ -4,7 +4,9 @@ import { OsdsSpinner } from '@ovhcloud/ods-components/react'; export default function Loading() { return (
- +
+ +
); } diff --git a/packages/manager/apps/hycu/src/components/Order/PackSelection.tsx b/packages/manager/apps/hycu/src/components/Order/PackSelection.tsx index 055002020d81..5b3064f75cdd 100644 --- a/packages/manager/apps/hycu/src/components/Order/PackSelection.tsx +++ b/packages/manager/apps/hycu/src/components/Order/PackSelection.tsx @@ -16,17 +16,19 @@ import { OsdsLink, } from '@ovhcloud/ods-components/react'; import { - Description, OvhSubsidiary, Price, Subtitle, } from '@ovh-ux/manager-react-components'; +import CustomDescription from '@/components/Description/Description.component'; +import Error from '@/components/Error/Error'; import Loading from '@/components/Loading/Loading.component'; import { useOrderCatalogHYCU } from '@/hooks/order/useOrderCatalogHYCU'; import { urls } from '@/routes/routes.constant'; import { sortPacksByPrice } from '@/utils/sortPacks'; import { getRenewPrice } from '@/utils/getRenewPrice'; +import { CONTACT_URL_BY_SUBSIDIARY } from '@/utils/contactList'; type PackSelectionProps = { selectPack: Dispatch>; @@ -46,12 +48,16 @@ const PackSelection = ({ const { t } = useTranslation('order'); const navigate = useNavigate(); - const { data: orderCatalogHYCU, isLoading } = useOrderCatalogHYCU(subsidiary); + const { data: orderCatalogHYCU, isLoading, error } = useOrderCatalogHYCU( + subsidiary, + ); + + if (!isLoading && error) return ; return ( <> {t('hycu_order_subtitle')} - + ), }} > - + {isLoading && } {orderCatalogHYCU && !isLoading && (
diff --git a/packages/manager/apps/hycu/src/hooks/order/useOrderCatalogHYCU.ts b/packages/manager/apps/hycu/src/hooks/order/useOrderCatalogHYCU.ts index 2ba222853e19..7a6bcce22d51 100644 --- a/packages/manager/apps/hycu/src/hooks/order/useOrderCatalogHYCU.ts +++ b/packages/manager/apps/hycu/src/hooks/order/useOrderCatalogHYCU.ts @@ -1,6 +1,6 @@ import { useQuery } from '@tanstack/react-query'; import { OvhSubsidiary } from '@ovh-ux/manager-react-components'; -import { ErrorResponse } from '@/types/api.type'; +import { ApiError } from '@ovh-ux/manager-core-api'; import { getOrderCatalogHYCU } from '../../data/api/orderCatalogHYCU'; import { HYCUCatalog } from '@/types/orderCatalogHYCU.type'; @@ -13,7 +13,7 @@ export const useOrderCatalogHYCU = (ovhSubsidiary: OvhSubsidiary) => { refetchOnWindowFocus: false, keepPreviousData: true, }; - return useQuery({ + return useQuery({ queryKey: ['order/catalog/public/licenseHycu', ovhSubsidiary], queryFn: () => getOrderCatalogHYCU(ovhSubsidiary), ...options, diff --git a/packages/manager/apps/hycu/src/index.tsx b/packages/manager/apps/hycu/src/index.tsx index 8c826af14d34..f99c98002fcd 100644 --- a/packages/manager/apps/hycu/src/index.tsx +++ b/packages/manager/apps/hycu/src/index.tsx @@ -28,7 +28,7 @@ const init = async (appName: string) => { context, reloadOnLocaleChange: true, defaultNS: appName, - ns: ['listing', 'dashboard', 'onboarding', 'order'], + ns: ['listing', 'dashboard', 'onboarding'], }); const region = context.environment.getRegion(); diff --git a/packages/manager/apps/hycu/src/types/api.type.ts b/packages/manager/apps/hycu/src/types/api.type.ts deleted file mode 100644 index 283c244feaa4..000000000000 --- a/packages/manager/apps/hycu/src/types/api.type.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type ErrorResponse = { - response: { - status: number; - data: { message: string }; - }; -}; diff --git a/packages/manager/apps/hycu/src/utils/contactList.ts b/packages/manager/apps/hycu/src/utils/contactList.ts new file mode 100644 index 000000000000..3ef9c80139f7 --- /dev/null +++ b/packages/manager/apps/hycu/src/utils/contactList.ts @@ -0,0 +1,23 @@ +export const CONTACT_URL_BY_SUBSIDIARY = { + ASIA: 'https://www.ovhcloud.com/asia/contact/', + DE: 'https://www.ovhcloud.com/de/contact/', + ES: 'https://www.ovhcloud.com/es-es/contact/', + WS: 'https://www.ovhcloud.com/es/contact/', + IE: 'https://www.ovhcloud.com/en-ie/contact/', + IT: 'https://www.ovhcloud.com/it/contact/', + PL: 'https://www.ovhcloud.com/pl/contact/', + PT: 'https://www.ovhcloud.com/pt/contact/', + FR: 'https://www.ovhcloud.com/fr/contact/', + GB: 'https://www.ovhcloud.com/en-gb/contact/', + CA: 'https://www.ovhcloud.com/en-ca/contact/', + QC: 'https://www.ovhcloud.com/fr-ca/contact/', + US: 'https://www.ovhcloud.com/en/contact/', + AU: 'https://www.ovhcloud.com/en-au/contact/', + SG: 'https://www.ovhcloud.com/en-sg/contact/', + MA: 'https://www.ovhcloud.com/fr-ma/contact/', + SN: 'https://www.ovhcloud.com/fr-sn/contact/', + TN: 'https://www.ovhcloud.com/fr-tn/contact/', + NL: 'https://www.ovhcloud.com/nl/contact/', + IN: 'https://www.ovhcloud.com/en-in/contact/', + WE: 'https://www.ovhcloud.com/en/contact/', +};