Skip useOnlineBoard fetch when dateFrom/dateTo are empty
Details page calls useOnlineBoard to populate the sibling mini-list, passing empty-string params when the URL has no ?request=... context. The empty params were reaching the backend as dateFrom=&dateTo=, which returns HTTP 400 and surfaces as an error in the browser console. Short-circuit the effect so we just emit an empty result when either range bound is missing — same no-fetch behavior, no console noise.
This commit is contained in:
@@ -43,6 +43,17 @@ export function useOnlineBoard(
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Callers pass empty strings when the search context isn't resolved
|
||||
// yet (e.g. details page with no `?request=...`). Skip the fetch
|
||||
// rather than sending `dateFrom=&dateTo=` — the backend rejects that
|
||||
// with HTTP 400 and it shows up as an error in the browser console.
|
||||
if (!params.dateFrom || !params.dateTo) {
|
||||
setFlights([]);
|
||||
setLoading(false);
|
||||
setError(null);
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
Reference in New Issue
Block a user