diff --git a/src/app/screens/Feed/FeedView.tsx b/src/app/screens/Feed/FeedView.tsx index 4fecc2e..3c22a09 100644 --- a/src/app/screens/Feed/FeedView.tsx +++ b/src/app/screens/Feed/FeedView.tsx @@ -168,7 +168,7 @@ export default async function FeedView({ feedId={feed.id ?? ''} /> - + diff --git a/src/app/screens/Feed/components/FeedNavigationControls.tsx b/src/app/screens/Feed/components/FeedNavigationControls.tsx index 04c8b5b..21198b9 100644 --- a/src/app/screens/Feed/components/FeedNavigationControls.tsx +++ b/src/app/screens/Feed/components/FeedNavigationControls.tsx @@ -17,20 +17,21 @@ export default function FeedNavigationControls({ const t = useTranslations('common'); const router = useRouter(); + const handleBack = (): void => { + if (window.history.length > 1) { + router.back(); + return; + } + router.push('/feeds'); + }; + return ( - + diff --git a/src/app/screens/Feed/components/FullMapView.tsx b/src/app/screens/Feed/components/FullMapView.tsx index a448c3d..31be773 100644 --- a/src/app/screens/Feed/components/FullMapView.tsx +++ b/src/app/screens/Feed/components/FullMapView.tsx @@ -119,6 +119,20 @@ export default function FullMapView({ const isGtfsFeed = feed?.data_type === 'gtfs'; const hasError = !isGtfsFeed || feed == null || boundingBox == null; + const handleExitMap = (): void => { + if (window.history.length > 1) { + router.back(); + return; + } + + if (feedId != null) { + router.replace(`/feeds/${feed?.data_type ?? 'gtfs'}/${feedId}`); + return; + } + + router.replace('/feeds'); + }; + const errorDetails = useMemo(() => { const messages: string[] = []; if (feed == null) { @@ -251,13 +265,7 @@ export default function FullMapView({ startIcon={} color={'inherit'} sx={{ pl: 0, display: { xs: 'none', md: 'inline-flex' } }} - onClick={() => { - if (!hasError && feedId != null) { - router.push(`/feeds/gtfs/${feedId}`); - } else { - router.push('/'); - } - }} + onClick={handleExitMap} > {tCommon('back')} @@ -387,13 +395,7 @@ export default function FullMapView({ size='small' aria-label={t('fullMapView.aria.close')} sx={{ position: 'absolute', top: 10, right: 10, zIndex: 1000 }} - onClick={() => { - if (!hasError && feedId != null) { - router.push(`/feeds/${feed?.data_type}/${feedId}`); - } else { - router.push('/'); - } - }} + onClick={handleExitMap} >