-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mattapan-trolley
- Loading branch information
Showing
107 changed files
with
8,755 additions
and
9,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FetchAlertDelaysByLineParams, type FetchAlertDelaysByLineOptions } from '../types/api'; | ||
import type { LineDelays } from '../types/delays'; | ||
import { apiFetch } from './utils/fetch'; | ||
|
||
export const fetchLineDelaysByLine = async ( | ||
options: FetchAlertDelaysByLineOptions | ||
): Promise<LineDelays[]> => { | ||
if (!options[FetchAlertDelaysByLineParams.line]) return []; | ||
|
||
return await apiFetch({ | ||
path: '/api/linedelays', | ||
options, | ||
errorMessage: 'Failed to fetch delay metrics', | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { ONE_HOUR } from '../../constants/time'; | ||
import { fetchLineDelaysByLine } from '../delays'; | ||
import type { FetchAlertDelaysByLineOptions } from '../../types/api'; | ||
|
||
export const useAlertDelays = (options: FetchAlertDelaysByLineOptions, enabled?: boolean) => { | ||
return useQuery({ | ||
queryKey: ['lineDelays', options], | ||
queryFn: () => fetchLineDelaysByLine(options), | ||
enabled: enabled, | ||
staleTime: ONE_HOUR, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { ButtonGroup } from '../general/ButtonGroup'; | ||
import type { LineRouteId } from '../../types/lines'; | ||
|
||
interface BranchSelectorProps { | ||
routeId: LineRouteId; | ||
setRouteId: (routeId: LineRouteId) => void; | ||
} | ||
|
||
enum GreenLineBranchOptions { | ||
'Green-B' = 'B Branch', | ||
'Green-C' = 'C Branch', | ||
'Green-D' = 'D Branch', | ||
'Green-E' = 'E Branch', | ||
} | ||
|
||
export const BranchSelector: React.FunctionComponent<BranchSelectorProps> = ({ | ||
routeId, | ||
setRouteId, | ||
}) => { | ||
const selectedIndex = Object.keys(GreenLineBranchOptions).findIndex((route) => route === routeId); | ||
|
||
return ( | ||
<div className={'flex w-full justify-center pt-2'}> | ||
<ButtonGroup | ||
selectedIndex={selectedIndex} | ||
pressFunction={setRouteId} | ||
options={Object.entries(GreenLineBranchOptions)} | ||
additionalDivClass="md:w-auto" | ||
additionalButtonClass="md:w-fit" | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.