aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/app')
-rw-r--r--src/frontend/app/components/StopSheet.tsx25
-rw-r--r--src/frontend/app/routes/estimates-$id.tsx6
2 files changed, 11 insertions, 20 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"
diff --git a/src/frontend/app/routes/estimates-$id.tsx b/src/frontend/app/routes/estimates-$id.tsx
index 4b232cb..dc45198 100644
--- a/src/frontend/app/routes/estimates-$id.tsx
+++ b/src/frontend/app/routes/estimates-$id.tsx
@@ -36,9 +36,6 @@ interface ErrorInfo {
}
const loadData = async (stopId: string): 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",
@@ -53,9 +50,6 @@ const loadData = async (stopId: string): Promise<StopDetails> => {
};
const loadTimetableData = async (stopId: string): Promise<TimetableEntry[]> => {
- // Add delay to see skeletons in action (remove in production)
- await new Promise(resolve => setTimeout(resolve, 1500));
-
const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format
const resp = await fetch(`/api/GetStopTimetable?date=${today}&stopId=${stopId}`, {
headers: {