Skip to content

Commit 5ec7d53

Browse files
transitfeeds redirect banner (#1509)
1 parent 57525b1 commit 5ec7d53

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

web-app/src/app/components/Header.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
Select,
1414
useTheme,
1515
Link,
16+
Alert,
17+
AlertTitle,
1618
} from '@mui/material';
1719
import MenuIcon from '@mui/icons-material/Menu';
1820
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
@@ -26,7 +28,7 @@ import {
2628
gbfsMetricsNavItems,
2729
} from '../constants/Navigation';
2830
import type NavigationItem from '../interface/Navigation';
29-
import { useLocation, useNavigate } from 'react-router-dom';
31+
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
3032
import { useSelector } from 'react-redux';
3133
import { selectIsAuthenticated, selectUserEmail } from '../store/selectors';
3234
import LogoutConfirmModal from './LogoutConfirmModal';
@@ -44,9 +46,15 @@ import ThemeToggle from './ThemeToggle';
4446
import { useTranslation } from 'react-i18next';
4547

4648
export default function DrawerAppBar(): React.ReactElement {
49+
const [searchParams, setSearchParams] = useSearchParams();
50+
const hasTransitFeedsRedirectParam =
51+
searchParams.get('utm_source') === 'transitfeeds';
4752
const theme = useTheme();
4853
const location = useLocation();
4954
const [mobileOpen, setMobileOpen] = React.useState(false);
55+
const [hasTransitFeedsRedirect, setHasTransitFeedsRedirect] = React.useState(
56+
hasTransitFeedsRedirectParam,
57+
);
5058
const [openDialog, setOpenDialog] = React.useState(false);
5159
const [activeTab, setActiveTab] = React.useState('');
5260
const [navigationItems, setNavigationItems] = React.useState<
@@ -118,7 +126,7 @@ export default function DrawerAppBar(): React.ReactElement {
118126
<Box
119127
sx={{
120128
display: 'flex',
121-
height: '64px',
129+
height: hasTransitFeedsRedirect ? '115px' : '64px',
122130
mb: { xs: 2, md: 4 },
123131
}}
124132
>
@@ -399,7 +407,32 @@ export default function DrawerAppBar(): React.ReactElement {
399407
)}
400408
</Box>
401409
</Toolbar>
410+
{hasTransitFeedsRedirect && (
411+
<Alert
412+
severity='warning'
413+
onClose={() => {
414+
setHasTransitFeedsRedirect(false);
415+
if (hasTransitFeedsRedirectParam) {
416+
searchParams.delete('utm_source');
417+
setSearchParams(searchParams);
418+
}
419+
}}
420+
sx={{ '.MuiAlert-message': { pb: { xs: 0, md: 1 } } }}
421+
>
422+
<AlertTitle>
423+
You&apos;ve been redirected from TransitFeeds
424+
</AlertTitle>
425+
<Box
426+
component={'span'}
427+
sx={{ display: { xs: 'none', md: 'block' } }}
428+
>
429+
This page now lives on MobilityDatabase.org, where you&apos;ll
430+
find the most up-to-date transit data.
431+
</Box>
432+
</Alert>
433+
)}
402434
</AppBar>
435+
403436
<nav>
404437
<Drawer
405438
container={container}

web-app/src/app/screens/Feeds/Feeds.styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ export const chipHolderStyles: SxProps<Theme> = (theme) => ({
1313
export const stickyHeaderStyles = (props: {
1414
theme: Theme;
1515
isSticky: boolean;
16+
headerBannerVisible: boolean;
1617
}): SxProps => {
1718
const styles: SxProps = {
1819
display: 'flex',
1920
alignItems: 'center',
2021
position: 'sticky',
2122
zIndex: 1,
2223
top: {
23-
xs: '56px',
24-
sm: '65px',
24+
xs: props.headerBannerVisible ? '113px' : '56px',
25+
md: props.headerBannerVisible ? '140px' : '65px',
2526
},
2627
background: props.theme.palette.background.default,
2728
transition: 'box-shadow 0.3s ease-in-out',

web-app/src/app/screens/Feeds/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export default function Feed(): React.ReactElement {
7979
const feedsData = useSelector(selectFeedsData);
8080
const feedStatus = useSelector(selectFeedsStatus);
8181

82+
const hasTransitFeedsRedirectParam =
83+
searchParams.get('utm_source') === 'transitfeeds';
84+
8285
// features i/o
8386
const areNoDataTypesSelected =
8487
!selectedFeedTypes.gtfs &&
@@ -171,6 +174,9 @@ export default function Feed(): React.ReactElement {
171174
if (isOfficialFeedSearch) {
172175
newSearchParams.set('official', 'true');
173176
}
177+
if (searchParams.get('utm_source') === 'transitfeeds') {
178+
newSearchParams.set('utm_source', 'transitfeeds');
179+
}
174180
if (searchParams.toString() !== newSearchParams.toString()) {
175181
setSearchParams(newSearchParams, { replace: false });
176182
}
@@ -318,7 +324,13 @@ export default function Feed(): React.ReactElement {
318324
</Typography>
319325
)}
320326
</Container>
321-
<Box sx={stickyHeaderStyles({ theme, isSticky })}>
327+
<Box
328+
sx={stickyHeaderStyles({
329+
theme,
330+
isSticky,
331+
headerBannerVisible: hasTransitFeedsRedirectParam,
332+
})}
333+
>
322334
<Container
323335
maxWidth={'xl'}
324336
component='form'

0 commit comments

Comments
 (0)