Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/app/components/CoveredAreaMap.tsx
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot CoveredAreaMap component should get it's route data passed as a prop and not rely on the store

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in bfe0896. Added totalRoutes?: number to CoveredAreaMapProps and replaced the selectGtfsDatasetRoutesTotal store selector with the prop-derived value. FeedView (which already receives totalRoutes from the server-side fetch) now passes it down to CoveredAreaMap. The hasNoRoutes boolean is now computed as totalRoutes !== undefined && totalRoutes === 0.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface CoveredAreaMapProps {
boundingBox?: LngLatTuple[];
latestDataset?: LatestDatasetLite;
feed: AllFeedType;
totalRoutes?: number;
}

export const fetchGeoJson = async (
Expand All @@ -83,6 +84,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
boundingBox,
latestDataset,
feed,
totalRoutes,
}) => {
const t = useTranslations('feeds');
const tCommon = useTranslations('common');
Expand All @@ -106,6 +108,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
const routesJsonLoadingStatus = useSelector(
selectGtfsDatasetRoutesLoadingStatus,
);
const hasNoRoutes = totalRoutes == undefined || totalRoutes === 0;

const getAndSetGeoJsonData = (urlToExtract: string): void => {
setGeoJsonLoading(true);
Expand Down Expand Up @@ -166,6 +169,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
if (
feed?.data_type === 'gtfs' &&
routesJsonLoadingStatus != 'failed' &&
!hasNoRoutes &&
boundingBox != undefined
) {
setView('gtfsVisualizationView');
Expand All @@ -180,7 +184,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
return;
}
setView('boundingBoxView');
}, [feed, routesJsonLoadingStatus, boundingBox, geoJsonData]);
}, [feed, routesJsonLoadingStatus, totalRoutes, boundingBox, geoJsonData]);

const handleViewChange = (
_: React.MouseEvent<HTMLElement>,
Expand Down Expand Up @@ -279,9 +283,10 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
return (
feed?.data_type === 'gtfs' &&
routesJsonLoadingStatus != 'failed' &&
!hasNoRoutes &&
boundingBox != undefined
);
}, [feed?.data_type, routesJsonLoadingStatus, boundingBox]);
}, [feed?.data_type, routesJsonLoadingStatus, hasNoRoutes, boundingBox]);

return (
<Box
Expand Down
1 change: 1 addition & 0 deletions src/app/screens/Feed/FeedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export default async function FeedView({
boundingBox={boundingBox}
latestDataset={latestDataset}
feed={feed}
totalRoutes={totalRoutes}
/>
)}
<Box sx={{ width: { xs: '100%', md: '475px' } }}>
Expand Down
Loading