Skip to content

Commit

Permalink
fix: error when using window
Browse files Browse the repository at this point in the history
  • Loading branch information
LaercioSR committed Sep 25, 2024
1 parent 39c4e0b commit f85cbe2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
},
"summary": {
"label": "Summary"
},
"hasNotSummary": {
"label": "Click on some of the experiences to see more details"
}
},
"formation": {
Expand Down
3 changes: 3 additions & 0 deletions src/app/i18n/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
},
"summary": {
"label": "Resumo"
},
"hasNotSummary": {
"label": "Clique em algumas das experiências para ver mais detalhes"
}
},
"formation": {
Expand Down
9 changes: 3 additions & 6 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import { GITHUB_LINK, EMAIL_LINK, LINKEDIN_LINK } from "./utils/contrants";

export default function Home() {
const { t } = useTranslation();
const { innerWidth: windowWidth } = window;

const projectsHighlighted = projects.filter((project) => project.highlight);
const [experiencesWithActive, setExperiencesWithActive] = useState(
experiences.map((experience, index) => ({
...experience,
active: index === 0 && windowWidth > 1024,
active: index === 0,
})),
);

Expand All @@ -44,15 +43,13 @@ export default function Home() {
);
return activeExperience
? t(`data.experiences.${activeExperience.title}.description.label`)
: "";
: t("pages.home.experience.hasNotSummary.label");
}, [experiencesWithActive, t]);

function handleActiveExperienceChange(title: string) {
const updatedExperiences = experiencesWithActive.map((experience) => ({
...experience,
active:
experience.title === title &&
(!experience.active || windowWidth > 1024),
active: experience.title === title && !experience.active,
}));
setExperiencesWithActive(updatedExperiences);
}
Expand Down

0 comments on commit f85cbe2

Please sign in to comment.