diff --git a/packages/manager/core/shell-client/package.json b/packages/manager/core/shell-client/package.json index f4e26e2b2f79..88b5dc13c5cb 100644 --- a/packages/manager/core/shell-client/package.json +++ b/packages/manager/core/shell-client/package.json @@ -22,6 +22,8 @@ "@ovh-ux/ovh-at-internet": "^0.18.1", "@ovh-ux/request-tagger": "^0.4.0", "@ovh-ux/shell": "^4.1.0", + "@ovh-ux/url-builder": "^2.0.0", + "@tanstack/react-query": "^5.64.1", "i18next": "^23.8.2", "i18next-http-backend": "^2.4.2" }, diff --git a/packages/manager/core/shell-client/src/hooks/useNavigationGetUrl.ts b/packages/manager/core/shell-client/src/hooks/useNavigationGetUrl.ts new file mode 100644 index 000000000000..96a6ef2341a3 --- /dev/null +++ b/packages/manager/core/shell-client/src/hooks/useNavigationGetUrl.ts @@ -0,0 +1,21 @@ +import { useContext } from 'react'; +import { DefinedInitialDataOptions, useQuery } from '@tanstack/react-query'; +import { ParamValueType } from '@ovh-ux/url-builder'; +import { ShellContext } from '../ShellContext'; + +export const useNavigationGetUrl = ( + linkParams: [string, string, Record], + options: Partial> = {}, +) => { + const { + shell: { navigation }, + } = useContext(ShellContext); + + return useQuery({ + queryKey: ['shell', 'getUrl', linkParams], + queryFn: () => navigation.getURL(...linkParams), + refetchOnReconnect: false, + refetchOnWindowFocus: false, + ...options, + }); +};