Skip to content

Commit

Permalink
update lang and location when translating the page
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomm19 committed Jul 21, 2023
1 parent 6956ce3 commit 49c4fd6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
64 changes: 60 additions & 4 deletions src/components/NavbarDesktop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Icon from "../Icon";
import { NavItem } from "../Navbar";
import { GatsbyImage, getImage } from "gatsby-plugin-image";
import CustomBar from "../CustomBar";
import { locByLanguage } from "../../actions";

const MegaMenuContainer = styled(Div)`
top: 70px;
Expand Down Expand Up @@ -150,9 +151,51 @@ export const Navbar = ({
width: 125
placeholder: NONE # --> NONE || DOMINANT_COLOR || BLURRED | TRACED_SVG
)
# fixed(width: 125) {
# ...GatsbyImageSharpFixed
# }
}
}
allLocationYaml {
edges {
node {
city
name
latitude
longitude
phone
socials {
name
icon
link
}
country
country_shortname
defaultLanguage
breathecode_location_slug
active_campaign_location_slug
gdpr_compliant
in_person_available
online_available
meta_info {
slug
visibility
position
region
dialCode
}
button {
apply_button_text
syllabus_button_text
}
custom_bar {
active
}
}
}
nodes {
fields {
file_name
lang
slug
}
}
}
}
Expand All @@ -161,6 +204,14 @@ export const Navbar = ({
const isContentBarActive =
(contentBar.active && isTestMode) ||
(contentBar.active && !isDevelopment());

const langDictionary = {
us: 'es',
es: 'us',
};

const locations = locByLanguage(data.allLocationYaml, langDictionary[lang]);

return (
<>
<CustomBar
Expand Down Expand Up @@ -233,6 +284,11 @@ export const Navbar = ({
</Menu>
<Div alignItems="center" justifyContent="between">
<Link
onClick={() => setSession({
...session,
language: langDictionary[lang],
locations,
})}
to={
session && session.pathsDictionary && currentURL
? `${session.pathsDictionary[currentURL] || ""}${
Expand All @@ -247,7 +303,7 @@ export const Navbar = ({
margin="0 50px 0 0"
fontWeight="400"
lineHeight="16px"
></Paragraph>
/>
</Link>
<Link onClick={onToggle} to={button.button_link || "#"}>
<Button
Expand Down
4 changes: 1 addition & 3 deletions src/components/UpcomingDates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ const UpcomingDates = ({
setData(_data);
}
}, [session]);
const buttonText = locations?.find(
(loc) => loc.node?.city === session?.location?.city
)?.node?.button?.apply_button_text;
const buttonText = session?.location?.button.apply_button_text;

return (
<GridContainer id={id} style={style} margin_tablet="0 0 48px 0">
Expand Down
2 changes: 1 addition & 1 deletion src/templates/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ const Calendar = (props) => {
margin="10px 0"
textColor="white"
>
{content.cohorts.info.button_text}
{session?.location?.button.apply_button_text || content.cohorts.info.button_text}
</Button>
</Link>
</Div>
Expand Down

0 comments on commit 49c4fd6

Please sign in to comment.