diff --git a/components/Layout/Head.tsx b/components/Layout/Head.tsx index 023d0ba20..0f23ff0ed 100644 --- a/components/Layout/Head.tsx +++ b/components/Layout/Head.tsx @@ -9,12 +9,12 @@ export const Head: React.VFC<{ title: string }> = ({ title }) => { const tsln = useTranslation() const altLang = tsln._language === 'en' ? 'fr' : 'en' - const [isCanadaDotCa, setIsCanadaDotCa] = useState(false) + const [isAlpha, setIsAlpha] = useState(false) useEffect(() => { if (typeof window !== undefined) { const hostName = window.location.hostname - setIsCanadaDotCa(hostName.includes('.canada.ca')) + setIsAlpha(hostName.includes('.alpha.service')) } }, []) @@ -35,18 +35,18 @@ export const Head: React.VFC<{ title: string }> = ({ title }) => { @@ -54,9 +54,9 @@ export const Head: React.VFC<{ title: string }> = ({ title }) => { rel="alternate" lang={tsln._language} href={ - isCanadaDotCa - ? `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}` - : `https://ep-be.alpha.service.canada.ca/${tsln._language}${router.pathname}` + isAlpha + ? `https://ep-be.alpha.service.canada.ca/${tsln._language}${router.pathname}` + : `https://estimateursv-oasestimator.service.canada.ca/${tsln._language}${router.pathname}` } /> diff --git a/components/Layout/index.tsx b/components/Layout/index.tsx index 8935b14d9..994296b7a 100644 --- a/components/Layout/index.tsx +++ b/components/Layout/index.tsx @@ -14,6 +14,7 @@ export const Layout: React.VFC<{ title: string }> = ({ children, title }) => { const router = useRouter() + const hostname = typeof window !== 'undefined' ? window.location.hostname : '' // basically returns 'results' or 'resultats' IF, otherwise index or questions in the other locale. const langToggleLink = @@ -53,54 +54,59 @@ export const Layout: React.VFC<{ onSubmit: () => {}, } - const breadcrumbs = - process.env.APP_ENV === 'production' - ? [ - { - text: tsln.breadcrumb1Title, - link: tsln.breadcrumb1URL, - }, - { - text: tsln.breadcrumb2Title, - link: tsln.breadcrumb2URL, - }, - { - text: tsln.breadcrumb3Title, - link: tsln.breadcrumb3URL, - }, - { - text: tsln.breadcrumb4Title, - link: tsln.breadcrumb4URL, - }, - ] - : [ - { - text: tsln.breadcrumb1aTitle, - link: tsln.breadcrumb1aURL, - }, - { - text: tsln.breadcrumb2aTitle, - link: tsln.breadcrumb2aURL, - }, - ] + const getBreadcrumbs = () => { + const isBeta = !hostname.includes('.alpha.service') + const breadcrumbs = + process.env.APP_ENV === 'production' && isBeta + ? [ + { + text: tsln.breadcrumb1Title, + link: tsln.breadcrumb1URL, + }, + { + text: tsln.breadcrumb2Title, + link: tsln.breadcrumb2URL, + }, + { + text: tsln.breadcrumb3Title, + link: tsln.breadcrumb3URL, + }, + { + text: tsln.breadcrumb4Title, + link: tsln.breadcrumb4URL, + }, + ] + : [ + { + text: tsln.breadcrumb1aTitle, + link: tsln.breadcrumb1aURL, + }, + { + text: tsln.breadcrumb2aTitle, + link: tsln.breadcrumb2aURL, + }, + ] - if (router.pathname === '/questions') { - breadcrumbs.push({ - text: tsln.breadcrumb6Title, - link: tsln.breadcrumb6URL, - }) - } else if ( - router.pathname === '/results' || - router.pathname === '/resultats' - ) { - breadcrumbs.push({ - text: tsln.breadcrumb6Title, - link: tsln.breadcrumb6URL, - }), + if (router.pathname === '/questions') { breadcrumbs.push({ - text: tsln.breadcrumb7Title, - link: tsln.breadcrumb7URL, + text: tsln.breadcrumb6Title, + link: tsln.breadcrumb6URL, }) + } else if ( + router.pathname === '/results' || + router.pathname === '/resultats' + ) { + breadcrumbs.push({ + text: tsln.breadcrumb6Title, + link: tsln.breadcrumb6URL, + }), + breadcrumbs.push({ + text: tsln.breadcrumb7Title, + link: tsln.breadcrumb7URL, + }) + } + + return breadcrumbs } const handleOnClick = () => { @@ -122,7 +128,7 @@ export const Layout: React.VFC<{ id="header" locale={router.locale} langUrl={langToggleLink} - breadcrumbItems={breadcrumbs} + breadcrumbItems={getBreadcrumbs()} topNavProps={topnavProps} headerText={{ globalHeader: tsln.globalHeader,