Skip to content

Commit

Permalink
fix: keep origin language for external links
Browse files Browse the repository at this point in the history
  • Loading branch information
flagrede committed Nov 19, 2024
1 parent 47a2207 commit 1e9bd76
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 150 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import { useLingui } from '@lingui/react';
import { useAtomValue } from 'jotai';

import { selectedLanguageAtom } from 'lib/atoms/languageSwitcher.atoms';

import TerrasosFooter from '../TerrasosFooter';
import {
Expand All @@ -16,7 +19,11 @@ import {
const RegistryLayoutTerrasosFooter: React.FC<React.PropsWithChildren<unknown>> =
() => {
const { _ } = useLingui();
const TerrasosColumnItems = getTerrasosFooterColumns(_);
const selectedLanguage = useAtomValue(selectedLanguageAtom);
const TerrasosColumnItems = getTerrasosFooterColumns({
_,
selectedLanguage,
});

return (
<TerrasosFooter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,88 +42,102 @@ export const terrasosFooterSocialItems: TerrasosSocialItem[] = [
},
];

export const getTerrasosFooterColumns = (
_: TranslatorType,
): TerrasosColumnItem[] => [
{
title: 'TERRASOS',
links: [
{
label: _(msg`About Us`),
href: 'https://www.terrasos.co/nosotros/',
},
{
label: _(msg`Our Services`),
href: 'https://www.terrasos.co/servicios/',
},
{
label: _(msg`Habitat banks`),
href: '/projects/1',
},
{
label: _(msg`What is Tebu`),
href: 'https://www.terrasos.co/que-es-tebu/',
},
{
label: _(msg`Geo-Viewer`),
href: 'https://www.terrasos.co/geovisor/',
},
type Params = {
_: TranslatorType;
selectedLanguage: string;
};

{
label: _(msg`Contact`),
href: 'https://www.terrasos.co/contacto/',
},
],
},
{
title: 'USEFUL LINKS',
links: [
{
label: _(msg`Act Now - Tebu`),
href: 'https://tebu.terrasos.co/',
},
{
label: _(msg`Opportunities`),
href: 'https://www.terrasos.co/convocatorias/',
},
{
label: _(msg`PQR Request`),
href: 'https://www.terrasos.co/pqrs/',
},
{
label: _(msg`Terms and Conditions`),
href: 'https://www.terrasos.co/terminos-y-condiciones/',
},
{
label: _(msg`Privacy Policy`),
href: 'https://www.terrasos.co/politica-de-privacidad/',
},
export const getTerrasosFooterColumns = ({
_,
selectedLanguage,
}: Params): TerrasosColumnItem[] => {
const domainUrl = 'https://www.terrasos.co';
const baseUrl = selectedLanguage === 'en' ? `${domainUrl}/en` : domainUrl;
const tebuDomainUrl = 'https://tebu.terrasos.co';
const tebuUrl =
selectedLanguage === 'en' ? `${tebuDomainUrl}/en` : tebuDomainUrl;

{
label: _(msg`Cookies Policy`),
href: 'https://www.terrasos.co/politica-de-cookies/',
},
],
},
{
title: 'CONTACT US',
links: [
{
label: 'Carrera 13 # 90 - 20,\n Bogotá, D.C. (Colombia)',
href: 'https://maps.app.goo.gl/ChQczporqpW6TS1m8',
},
{
subLinks: [
{
label: '+57 (601) 467-3587',
href: 'tel:+576014673587',
},
{
label: '+57 310-457-7606',
href: 'https://wa.me/573104577606',
},
],
},
],
},
];
return [
{
title: 'TERRASOS',
links: [
{
label: _(msg`About Us`),
href: `${baseUrl}/nosotros/`,
},
{
label: _(msg`Our Services`),
href: `${baseUrl}/servicios/`,
},
{
label: _(msg`Habitat banks`),
href: '/projects/1',
},
{
label: _(msg`What is Tebu`),
href: `${baseUrl}/que-es-tebu/`,
},
{
label: _(msg`Geo-Viewer`),
href: `${baseUrl}/geovisor/`,
},

{
label: _(msg`Contact`),
href: `${baseUrl}/contacto/`,
},
],
},
{
title: 'USEFUL LINKS',
links: [
{
label: _(msg`Act Now - Tebu`),
href: tebuUrl,
},
{
label: _(msg`Opportunities`),
href: `${baseUrl}/convocatorias/`,
},
{
label: _(msg`PQR Request`),
href: `${baseUrl}/pqrs/`,
},
{
label: _(msg`Terms and Conditions`),
href: `${baseUrl}/terminos-y-condiciones/`,
},
{
label: _(msg`Privacy Policy`),
href: `${baseUrl}/politica-de-privacidad/`,
},

{
label: _(msg`Cookies Policy`),
href: `${baseUrl}/politica-de-cookies/`,
},
],
},
{
title: 'CONTACT US',
links: [
{
label: 'Carrera 13 # 90 - 20,\n Bogotá, D.C. (Colombia)',
href: 'https://maps.app.goo.gl/ChQczporqpW6TS1m8',
},
{
subLinks: [
{
label: '+57 (601) 467-3587',
href: 'tel:+576014673587',
},
{
label: '+57 310-457-7606',
href: 'https://wa.me/573104577606',
},
],
},
],
},
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,79 @@ import { TerrasosHeaderItem } from './TerrasosHeader.types';
export const TERRASOS_LOGO_ALT = msg`Terrasos Logo`;
export const TERRASOS_BASE_PATHNAME = '/project';

export const getTerrasosHeaderItems = (
_: TranslatorType,
): TerrasosHeaderItem[] => [
{
label: _(msg`Home`),
href: 'https://www.terrasos.co/',
},
{
label: _(msg`About Us`),
href: 'https://www.terrasos.co/nosotros/',
},
{
label: _(msg`Services`),
href: 'https://www.terrasos.co/servicios/',
},
{
label: _(msg`Habitat banks`),
href: '/projects/1',
items: [
{
label: _(msg`Information`),
href: 'https://www.terrasos.co/informacion-de-bancos-de-habitat/',
},
{
label: _(msg`Explore Banks`),
href: '/projects/1',
default: true,
},
],
},
{
label: _(msg`What is Tebu`),
href: 'https://www.terrasos.co/que-es-tebu/',
},
{
label: _(msg`Geo-Viewer`),
href: 'https://www.terrasos.co/geovisor/',
},
{
label: _(msg`Information`),
href: '',
items: [
{
label: _(msg`News`),
href: 'https://www.terrasos.co/noticias/',
},
{
label: _(msg`Articles`),
href: 'https://www.terrasos.co/blog/',
},
{
label: _(msg`Publications`),
href: 'https://www.terrasos.co/publicaciones/',
},
{
label: _(msg`Frequently Asked Questions`),
href: 'https://www.terrasos.co/preguntas-frecuentes/',
},
{
label: _(msg`Contact`),
href: 'https://www.terrasos.co/contacto/',
},
],
},
];
type Params = {
_: TranslatorType;
selectedLanguage: string;
};

export const getTerrasosHeaderItems = ({
_,
selectedLanguage,
}: Params): TerrasosHeaderItem[] => {
const domainUrl = 'https://www.terrasos.co';
const baseUrl = selectedLanguage === 'en' ? `${domainUrl}/en` : domainUrl;

return [
{
label: _(msg`Home`),
href: baseUrl,
},
{
label: _(msg`About Us`),
href: `${baseUrl}/nosotros/`,
},
{
label: _(msg`Services`),
href: `${baseUrl}/servicios/`,
},
{
label: _(msg`Habitat banks`),
href: `/projects/1`,
items: [
{
label: _(msg`Information`),
href: `${baseUrl}/informacion-de-bancos-de-habitat/`,
},
{
label: _(msg`Explore Banks`),
href: '/projects/1',
default: true,
},
],
},
{
label: _(msg`What is Tebu`),
href: `${baseUrl}/que-es-tebu/`,
},
{
label: _(msg`Geo-Viewer`),
href: `${baseUrl}/geovisor/`,
},
{
label: _(msg`Information`),
href: '',
items: [
{
label: _(msg`News`),
href: `${baseUrl}/noticias/`,
},
{
label: _(msg`Articles`),
href: `${baseUrl}/blog/`,
},
{
label: _(msg`Publications`),
href: `${baseUrl}/publicaciones/`,
},
{
label: _(msg`Frequently Asked Questions`),
href: `${baseUrl}/preguntas-frecuentes/`,
},
{
label: _(msg`Contact`),
href: `${baseUrl}/contacto/`,
},
],
},
];
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useMemo, useState } from 'react';
import { msg } from '@lingui/macro';
import { useLingui } from '@lingui/react';
import { useAtomValue } from 'jotai';

import BreadcrumbIcon from 'web-components/src/components/icons/BreadcrumbIcon';
import { cn } from 'web-components/src/utils/styles/cn';

import { selectedLanguageAtom } from 'lib/atoms/languageSwitcher.atoms';

import HamburgerIcon from 'components/atoms/HumberIconTerrasos';
import TerrasosLogo from 'components/atoms/TerrasosLogo';

Expand All @@ -21,7 +24,11 @@ export interface Props {

export const TerrasosHeader = ({ className }: Props): JSX.Element => {
const { _ } = useLingui();
const items = useMemo(() => getTerrasosHeaderItems(_), [_]);
const selectedLanguage = useAtomValue(selectedLanguageAtom);
const items = useMemo(
() => getTerrasosHeaderItems({ _, selectedLanguage }),
[_],
);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);

return (
Expand Down

0 comments on commit 1e9bd76

Please sign in to comment.