/** Service for bus stop-related API calls */ import { apiClient } from './apiClient' import type { BusStop, Route } from '@/types' export const busStopsService = { /** Get all bus stops */ async getAllBusStops(): Promise { const response = await apiClient.get('/api/bus-stops') return response.data }, /** Get a single bus stop by ID */ async getBusStopById(id: string): Promise { const response = await apiClient.get(`/api/bus-stops/${id}`) return response.data }, /** Get all routes passing through a bus stop */ async getBusStopRoutes(stopId: string): Promise { const response = await apiClient.get(`/api/bus-stops/${stopId}/routes`) return response.data }, /** Get estimated next bus arrivals (Mock Data) */ async getNextBusArrivals(_stopId: string): Promise<{ routeName: string; arrivalTime: string }[]> { // Mock delay to simulate network request await new Promise(resolve => setTimeout(resolve, 500)); // Generate some random mock arrivals const mockArrivals = [ { routeName: "Ruta Boquete - David", arrivalTime: "5 min" }, { routeName: "Ruta David - Boquete", arrivalTime: "12 min" }, { routeName: "Ruta Circular", arrivalTime: "25 min" } ]; // Randomly return 1-3 arrivals return mockArrivals.slice(0, Math.floor(Math.random() * 3) + 1); }, /** Create a new bus stop (Admin) */ async createBusStop(data: import('@/types').BusStopCreate): Promise { const response = await apiClient.post('/api/bus-stops', data) return response.data }, /** Update a bus stop (Admin) */ async updateBusStop(id: string, data: import('@/types').BusStopUpdate): Promise { const response = await apiClient.put(`/api/bus-stops/${id}`, data) return response.data }, /** Delete a bus stop (Admin) */ async deleteBusStop(id: string): Promise { await apiClient.delete(`/api/bus-stops/${id}`) } }