Skip to content

Commit

Permalink
Updates all npm packages Apr 2024 (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte authored Apr 14, 2024
1 parent 4e72d0b commit b326076
Show file tree
Hide file tree
Showing 16 changed files with 11,089 additions and 18,655 deletions.
22 changes: 12 additions & 10 deletions common/api/hooks/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ export const useHistoricalAlertsData = (
line: LineShort,
busRoute?: string
) => {
return useQuery(
['alerts', date, line, busRoute],
() => fetchHistoricalAlerts(date, line, busRoute),
{
staleTime: FIVE_MINUTES,
enabled: date !== undefined,
}
);
return useQuery({
queryKey: ['alerts', date, line, busRoute],
queryFn: () => fetchHistoricalAlerts(date, line, busRoute),
staleTime: FIVE_MINUTES,
enabled: date !== undefined,
});
};

export const useAlertsData = (
line: LineShort,
busRoute?: string
): UseQueryResult<AlertsResponse[]> => {
return useQuery(['alerts', line, busRoute], () => fetchAlerts(line, busRoute), {
return useQuery({
queryKey: ['alerts', line, busRoute],
queryFn: () => fetchAlerts(line, busRoute),
staleTime: ONE_MINUTE,
});
};

export const useAccessibilityAlertsData = (line: LineShort) => {
return useQuery(['accessibilityAlerts', line], () => fetchAccessibilityAlertsForLine(line), {
return useQuery({
queryKey: ['accessibilityAlerts', line],
queryFn: () => fetchAccessibilityAlertsForLine(line),
staleTime: ONE_MINUTE,
});
};
7 changes: 0 additions & 7 deletions common/api/hooks/facilities.ts

This file was deleted.

4 changes: 3 additions & 1 deletion common/api/hooks/predictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { fetchPredictions } from '../predictions';
import type { FetchPredictionsParams } from '../../types/api';

export const usePredictionData = (params: FetchPredictionsParams, enabled: boolean = true) => {
return useQuery(['predictions', params], () => fetchPredictions(params), {
return useQuery({
queryKey: ['predictions', params],
queryFn: () => fetchPredictions(params),
enabled: enabled,
staleTime: ONE_HOUR,
});
Expand Down
6 changes: 4 additions & 2 deletions common/api/hooks/ridership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { fetchLandingRidership, fetchRidership } from '../ridership';
import { ONE_HOUR } from '../../constants/time';

export const useRidershipData = (options: FetchRidershipOptions, enabled?: boolean) => {
return useQuery(['trips', options], () => fetchRidership(options), {
return useQuery({
queryKey: ['trips', options],
queryFn: () => fetchRidership(options),
enabled: enabled,
staleTime: ONE_HOUR,
});
};

export const useRidershipDataLanding = () => {
return useQuery(['ridership-landing'], () => fetchLandingRidership());
return useQuery({ queryKey: ['ridership-landing'], queryFn: () => fetchLandingRidership() });
};
8 changes: 6 additions & 2 deletions common/api/hooks/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { ONE_HOUR } from '../../constants/time';
import { fetchScheduledService, fetchServiceHours } from '../service';

export const useScheduledService = (options: FetchScheduledServiceOptions, enabled?: boolean) => {
return useQuery(['scheduledservice', options], () => fetchScheduledService(options), {
return useQuery({
queryKey: ['scheduledservice', options],
queryFn: () => fetchScheduledService(options),
enabled: enabled,
staleTime: ONE_HOUR,
});
};

export const useServiceHours = (params: FetchServiceHoursOptions, enabled?: boolean) => {
return useQuery(['service_hours', params], () => fetchServiceHours(params), {
return useQuery({
queryKey: ['service_hours', params],
queryFn: () => fetchServiceHours(params),
enabled: enabled,
staleTime: 0,
});
Expand Down
8 changes: 5 additions & 3 deletions common/api/hooks/slowzones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { ONE_HOUR } from '../../constants/time';
import type { FetchSpeedRestrictionsOptions } from '../../types/api';

export const useSlowzoneAllData = () => {
return useQuery(['allSlow'], fetchAllSlow, { staleTime: ONE_HOUR });
return useQuery({ queryKey: ['allSlow'], queryFn: fetchAllSlow, staleTime: ONE_HOUR });
};

export const useSlowzoneDelayTotalData = () => {
return useQuery(['delayTotals'], fetchDelayTotals, { staleTime: ONE_HOUR });
return useQuery({ queryKey: ['delayTotals'], queryFn: fetchDelayTotals, staleTime: ONE_HOUR });
};

export const useSpeedRestrictionData = (options: FetchSpeedRestrictionsOptions) => {
return useQuery(['speedRestrictions', options], () => fetchSpeedRestrictions(options), {
return useQuery({
queryKey: ['speedRestrictions', options],
queryFn: () => fetchSpeedRestrictions(options),
enabled: options.date !== undefined,
staleTime: ONE_HOUR,
});
Expand Down
4 changes: 3 additions & 1 deletion common/api/hooks/speed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import type { FetchSpeedsOptions } from '../../types/api';
import { FIVE_MINUTES } from '../../constants/time';

export const useSpeedData = (options: FetchSpeedsOptions, enabled?: boolean) => {
return useQuery(['speed', options], () => fetchSpeeds(options), {
return useQuery({
queryKey: ['speed', options],
queryFn: () => fetchSpeeds(options),
enabled: enabled,
staleTime: FIVE_MINUTES,
});
Expand Down
6 changes: 4 additions & 2 deletions common/api/hooks/tripmetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export const useDeliveredTripMetrics = (
options: FetchDeliveredTripMetricsOptions,
enabled?: boolean
) => {
return useQuery(['actualTrips', options], () => fetchActualTripsByLine(options), {
return useQuery({
queryKey: ['actualTrips', options],
queryFn: () => fetchActualTripsByLine(options),
enabled: enabled,
staleTime: FIVE_MINUTES,
});
};

export const useTripMetricsForLanding = () => {
return useQuery(['landingTrips'], () => fetchLandingTripMetrics());
return useQuery({ queryKey: ['landingTrips'], queryFn: () => fetchLandingTripMetrics() });
};
2 changes: 1 addition & 1 deletion common/layouts/PrimaryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const queryClient = new QueryClient({
export const Layout: React.FC<LayoutProps> = ({ children }) => {
return (
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools position="bottom-right" />
<ReactQueryDevtools buttonPosition="top-left" />
<div className="flex h-screen flex-col">
<main className="relative h-full">{children}</main>
</div>
Expand Down
4 changes: 2 additions & 2 deletions modules/commute/alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Alerts: React.FC<AlertsProps> = ({ title, alerts }) => {
<Divider title="Today" line={line} />

<AlertBox
alerts={alerts.data}
alerts={alerts.data || []}
lineShort={lineShort}
busRoute={busRoute}
type={'current'}
Expand All @@ -53,7 +53,7 @@ export const Alerts: React.FC<AlertsProps> = ({ title, alerts }) => {
<Divider title="Upcoming" line={line} />

<AlertBox
alerts={alerts.data}
alerts={alerts.data || []}
lineShort={lineShort}
busRoute={busRoute}
type={'upcoming'}
Expand Down
3 changes: 2 additions & 1 deletion modules/landing/charts/OverallRidershipChartWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { OverallRidershipChart } from './OverallRidershipChart';

export const OverallRidershipChartWrapper: React.FC = () => {
const ridershipData = useRidershipDataLanding();
const ridershipDataReady = !ridershipData.isLoading && !ridershipData.isError;
const ridershipDataReady =
!ridershipData.isLoading && !ridershipData.isError && ridershipData.data;
if (!ridershipDataReady) return <ChartPlaceHolder query={ridershipData} />;
return <OverallRidershipChart ridershipData={ridershipData.data} />;
};
2 changes: 1 addition & 1 deletion modules/landing/charts/OverallServiceChartWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OverallServiceChart } from './OverallServiceChart';

export const OverallServiceChartWrapper: React.FC = () => {
const serviceData = useTripMetricsForLanding();
const serviceDataReady = !serviceData.isLoading && !serviceData.isError;
const serviceDataReady = !serviceData.isLoading && !serviceData.isError && serviceData.data;
if (!serviceDataReady) return <ChartPlaceHolder query={serviceData} />;

return <OverallServiceChart serviceData={serviceData.data} />;
Expand Down
2 changes: 1 addition & 1 deletion modules/landing/charts/OverallSpeedChartWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OverallSpeedChart } from './OverallSpeedChart';

export const OverallSpeedChartWrapper: React.FC = () => {
const speedData = useTripMetricsForLanding();
const speedDataReady = !speedData.isLoading && !speedData.isError;
const speedDataReady = !speedData.isLoading && !speedData.isError && speedData.data;
if (!speedDataReady) return <ChartPlaceHolder query={speedData} />;

return <OverallSpeedChart speedData={speedData.data} />;
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const nextConfig = {
async rewrites() {
return rewrites;
},
output: 'export',
trailingSlash: true,
reactStrictMode: true,
transpilePackages: ['next-goatcounter'],
Expand Down
Loading

0 comments on commit b326076

Please sign in to comment.