Skip to content

Commit 27f224c

Browse files
committed
feat: add toast message for warnings array
1 parent 6f77dd5 commit 27f224c

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

src/components/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,18 @@ export interface ValhallaRouteResponse {
217217
id: 'valhalla_directions';
218218
trip: Trip;
219219
alternates?: ValhallaRouteResponse[];
220+
warnings?: {
221+
code: number;
222+
message: string;
223+
}[];
220224
}
221225

222226
export interface ValhallaIsochroneResponse extends GeoJSON.FeatureCollection {
223227
id: string;
228+
warnings?: {
229+
code: number;
230+
message: string;
231+
}[];
224232
}
225233

226234
export interface FetchGeocodeObject {
@@ -241,4 +249,8 @@ export interface OptimizedLocation {
241249
export interface ValhallaOptimizedRouteResponse {
242250
trip: Trip;
243251
id?: string;
252+
warnings?: {
253+
code: number;
254+
message: string;
255+
}[];
244256
}

src/hooks/use-directions-queries.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ async function fetchDirections() {
5656
}
5757
);
5858

59+
// Display routing warnings if present
60+
if (data.warnings && data.warnings.length > 0) {
61+
data.warnings.forEach((warning) => {
62+
toast.warning('Routing warning', {
63+
description: warning.message,
64+
position: 'bottom-center',
65+
duration: 5000,
66+
closeButton: true,
67+
});
68+
});
69+
}
70+
5971
// Parse geometry for main route
6072
(data as ParsedDirectionsGeometry).decodedGeometry =
6173
parseDirectionsGeometry(data);

src/hooks/use-isochrones-queries.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ async function fetchIsochrones() {
5151
}
5252
);
5353

54+
// Display routing warnings if present
55+
if (data.warnings && data.warnings.length > 0) {
56+
data.warnings.forEach((warning) => {
57+
toast.warning('Isochrone warning', {
58+
description: warning.message,
59+
position: 'bottom-center',
60+
duration: 5000,
61+
closeButton: true,
62+
});
63+
});
64+
}
65+
5466
// Calculate area for each feature
5567
data.features.forEach((feature) => {
5668
if (feature.properties) {

src/hooks/use-optimized-route-query.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ export function useOptimizedRouteQuery() {
5555
{ params: { json: JSON.stringify(request.json) } }
5656
);
5757

58+
// Display routing warnings if present
59+
if (data.warnings && data.warnings.length > 0) {
60+
data.warnings.forEach((warning) => {
61+
toast.warning('Optimization warning', {
62+
description: warning.message,
63+
position: 'bottom-center',
64+
duration: 5000,
65+
closeButton: true,
66+
});
67+
});
68+
}
69+
5870
const processedData = {
5971
...data,
6072
id: data.id ?? 'valhalla_optimized_route',

0 commit comments

Comments
 (0)