Skip to content

Commit 25a05e0

Browse files
committed
Mantem progresso da pagina ao voltar para lançamentos
1 parent d7b566d commit 25a05e0

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

pages/launches/[launchName].tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useEffect, useMemo, useState } from 'react';
22
import { useRouter } from 'next/router';
3-
import Link from 'next/link';
43
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
54
import { Alert, Box, Button, Card, CardContent, Chip, CircularProgress, Container, Stack, Typography } from '@mui/material';
65
import {
@@ -83,8 +82,7 @@ export default function LaunchDetailsPage() {
8382
<Container maxWidth="xl" sx={{ py: 2 }}>
8483
<Stack spacing={1}>
8584
<Button
86-
component={Link}
87-
href="/launches"
85+
onClick={() => router.back()}
8886
startIcon={<ArrowBackIcon />}
8987
sx={{ width: 'fit-content', margin: 0, padding: 0 }}
9088
>

pages/launches/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import HeroSection from '@/components/projects-components/HeroSection';
1212
import { LOCALE } from '@/src/shared/consts/locales.const';
1313

1414
const SELECTED_LAUNCH_STORAGE_KEY = 'zenith-selected-launch';
15+
const SCROLL_POSITION_KEY = 'zenith-launches-scroll';
1516

1617
// TODO mover textos para arquivo de tradução
1718
export default function LaunchesPage() {
@@ -22,10 +23,19 @@ export default function LaunchesPage() {
2223
const launchesTitle = t('allLaunches:allLaunchesPage.header.title');
2324
const launchesDescription = t('allLaunches:allLaunchesPage.header.description');
2425

25-
useEffect(() => {}, [isLoadingAllLaunches, launches]);
26+
useEffect(() => {
27+
if (isLoadingAllLaunches || launches.length === 0) return;
28+
29+
const savedScroll = sessionStorage.getItem(SCROLL_POSITION_KEY);
30+
if (savedScroll) {
31+
window.scrollTo({ top: parseInt(savedScroll), behavior: 'instant' });
32+
sessionStorage.removeItem(SCROLL_POSITION_KEY);
33+
}
34+
}, [isLoadingAllLaunches, launches]);
2635

2736
const handleLaunchDetails = (launch: (typeof launches)[number]) => {
2837
sessionStorage.setItem(SELECTED_LAUNCH_STORAGE_KEY, JSON.stringify(launch));
38+
sessionStorage.setItem(SCROLL_POSITION_KEY, String(window.scrollY));
2939
router.push(`/launches/${slugifyLaunchName(launch.name)}`);
3040
};
3141

src/components/LaunchCard/LaunchSummaryCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function LaunchSummaryCard({ launch, onDetailsClick }: LaunchSumm
3434
</CardContent>
3535
<CardActions sx={{ justifyContent: 'flex-end' }}>
3636
<Button size="small" endIcon={<ChevronRightIcon />} onClick={() => onDetailsClick(launch)}>
37-
Ver detalhes
37+
Ver trajetória
3838
</Button>
3939
</CardActions>
4040
</Card>

src/shared/consts/navLinks.const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const NAV_LINKS: readonly NavLinkType[] = [
88
{ href: '/zenith', labelKey: 'common:NAVBAR.ABOUT_US' },
99
{ href: '/projetos', labelKey: 'common:NAVBAR.PROJECTS' },
1010
{ href: '/kurumim', labelKey: 'common:NAVBAR.KURUMIM' },
11-
{ href: '/processo-seletivo', labelKey: 'common:NAVBAR.RECRUITMENT_PROCESS' }
12-
// { href: '/launches', labelKey: 'common:NAVBAR.LAUNCHES' }
11+
{ href: '/processo-seletivo', labelKey: 'common:NAVBAR.RECRUITMENT_PROCESS' },
12+
{ href: '/launches', labelKey: 'common:NAVBAR.LAUNCHES' }
1313
// { href: 'https://ob-site.vercel.app/', labelKey: 'common:NAVBAR.OBSAT', external: true }
1414
] as const;

0 commit comments

Comments
 (0)