diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-09-07 19:35:19 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-09-07 19:35:19 +0200 |
| commit | 822f0e9f33b8711ac8a8b656a4778b7404a37e0b (patch) | |
| tree | 6ef319511eab5202dd667d87ae564186863e9fcf /src/frontend/app/components | |
| parent | 5735b05871e2cf7a83c3484894d7e3f03e587b06 (diff) | |
Remove timeouts that shouldn't be there
Diffstat (limited to 'src/frontend/app/components')
| -rw-r--r-- | src/frontend/app/components/StopSheet.tsx | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/frontend/app/components/StopSheet.tsx b/src/frontend/app/components/StopSheet.tsx index e8000d1..702c574 100644 --- a/src/frontend/app/components/StopSheet.tsx +++ b/src/frontend/app/components/StopSheet.tsx @@ -23,19 +23,16 @@ interface ErrorInfo { } const loadStopData = async (stopId: number): Promise<StopDetails> => { - // Add delay to see skeletons in action (remove in production) - await new Promise(resolve => setTimeout(resolve, 1000)); - const resp = await fetch(`/api/GetStopEstimates?id=${stopId}`, { headers: { Accept: "application/json", }, }); - + if (!resp.ok) { throw new Error(`HTTP ${resp.status}: ${resp.statusText}`); } - + return await resp.json(); }; @@ -55,17 +52,17 @@ export const StopSheet: React.FC<StopSheetProps> = ({ if (!navigator.onLine) { return { type: 'network', message: 'No internet connection' }; } - + if (error.message?.includes('Failed to fetch') || error.message?.includes('NetworkError')) { return { type: 'network' }; } - + if (error.message?.includes('HTTP')) { const statusMatch = error.message.match(/HTTP (\d+):/); const status = statusMatch ? parseInt(statusMatch[1]) : undefined; return { type: 'server', status }; } - + return { type: 'unknown', message: error.message }; }; @@ -74,7 +71,7 @@ export const StopSheet: React.FC<StopSheetProps> = ({ setLoading(true); setError(null); setData(null); - + const stopData = await loadStopData(stopId); setData(stopData); setLastUpdated(new Date()); @@ -138,8 +135,8 @@ export const StopSheet: React.FC<StopSheetProps> = ({ {loading ? ( <StopSheetSkeleton /> ) : error ? ( - <ErrorDisplay - error={error} + <ErrorDisplay + error={error} onRetry={loadData} title={t("errors.estimates_title", "Error al cargar estimaciones")} className="compact" @@ -193,9 +190,9 @@ export const StopSheet: React.FC<StopSheetProps> = ({ })} </div> )} - + <div className="stop-sheet-actions"> - <button + <button className="stop-sheet-reload" onClick={loadData} disabled={loading} @@ -204,7 +201,7 @@ export const StopSheet: React.FC<StopSheetProps> = ({ <RefreshCw className={`reload-icon ${loading ? 'spinning' : ''}`} /> {t("estimates.reload", "Recargar")} </button> - + <Link to={`/estimates/${stopId}`} className="stop-sheet-view-all" |
