diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-21 10:29:33 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-21 10:29:33 +0100 |
| commit | 4fcf9ad479441e7661933b954cc878355bde1e5d (patch) | |
| tree | 394782b29436596d18de5bba0dfb43f80d0bf205 | |
| parent | e82e9ffaa58a4817666155c29ad3efe666805881 (diff) | |
feat: Update ConsolidatedCirculationCard to support readonly mode; enhance button behavior based on GPS availability
3 files changed, 30 insertions, 14 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs index 0591230..6423c2f 100644 --- a/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs +++ b/src/Costasdev.Busurbano.Backend/Controllers/VigoController.cs @@ -107,7 +107,6 @@ public class VigoController : ControllerBase var realtimeTask = _api.GetStopEstimates(stopId); var todayDate = nowLocal.Date.ToString("yyyy-MM-dd"); - var tomorrowDate = nowLocal.Date.AddDays(1).ToString("yyyy-MM-dd"); // Load both today's and tomorrow's schedules to handle night services var timetableTask = LoadStopArrivalsProto(stopId.ToString(), todayDate); diff --git a/src/frontend/app/components/StopSheet.tsx b/src/frontend/app/components/StopSheet.tsx index 8749fe8..f32c435 100644 --- a/src/frontend/app/components/StopSheet.tsx +++ b/src/frontend/app/components/StopSheet.tsx @@ -167,6 +167,7 @@ export const StopSheet: React.FC<StopSheetProps> = ({ key={idx} estimate={estimate} regionConfig={regionConfig} + readonly /> ))} </div> diff --git a/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx b/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx index 47fa56b..97f0682 100644 --- a/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx +++ b/src/frontend/app/components/Stops/ConsolidatedCirculationCard.tsx @@ -10,6 +10,7 @@ interface ConsolidatedCirculationCardProps { estimate: ConsolidatedCirculation; regionConfig: RegionConfig; onMapClick?: () => void; + readonly?: boolean; } // Utility function to parse service ID and get the turn number @@ -71,7 +72,7 @@ const parseServiceId = (serviceId: string): string => { export const ConsolidatedCirculationCard: React.FC< ConsolidatedCirculationCardProps -> = ({ estimate, regionConfig, onMapClick }) => { +> = ({ estimate, regionConfig, onMapClick, readonly }) => { const { t } = useTranslation(); const absoluteArrivalTime = (minutes: number) => { @@ -172,15 +173,30 @@ export const ConsolidatedCirculationCard: React.FC< // Check if bus has GPS position (live tracking) const hasGpsPosition = !!estimate.currentPosition; + const Tag = readonly ? "div" : "button"; + const interactiveProps = readonly + ? {} + : { + onClick: onMapClick, + type: "button" as const, + disabled: !hasGpsPosition, + }; + return ( - <button + <Tag className={`consolidated-circulation-card ${ - hasGpsPosition ? "has-gps" : "no-gps" + readonly + ? !hasGpsPosition + ? "no-gps" + : "" + : hasGpsPosition + ? "has-gps" + : "no-gps" }`} - onClick={onMapClick} - type="button" - disabled={!hasGpsPosition} - aria-label={`${hasGpsPosition ? "View" : "No GPS data for"} ${estimate.line} to ${estimate.route}${hasGpsPosition ? " on map" : ""}`} + {...interactiveProps} + aria-label={`${hasGpsPosition ? "View" : "No GPS data for"} ${ + estimate.line + } to ${estimate.route}${hasGpsPosition ? " on map" : ""}`} > <div className="card-row main"> <div className="line-info"> @@ -189,17 +205,17 @@ export const ConsolidatedCirculationCard: React.FC< <div className="route-info"> <strong>{estimate.route}</strong> </div> + {hasGpsPosition && ( + <div className="gps-indicator" title="Live GPS tracking"> + <span className="gps-pulse" /> + </div> + )} <div className={`eta-badge ${timeClass}`}> <div className="eta-text"> <span className="eta-value">{etaValue}</span> <span className="eta-unit">{etaUnit}</span> </div> </div> - {hasGpsPosition && ( - <div className="gps-indicator" title="Live GPS tracking"> - <span className="gps-pulse" /> - </div> - )} </div> {metaChips.length > 0 && ( <div className="card-row meta"> @@ -213,6 +229,6 @@ export const ConsolidatedCirculationCard: React.FC< ))} </div> )} - </button> + </Tag> ); }; |
