Files
ridebus-board/src/lib/information.ts
Zakhar Timoshenko e239de45dd feat: add passenger information and settings components
- Introduced `PassengerInfo.tsx` for displaying trip details, including upcoming trips and fare information.
- Added `PassengerSettings.tsx` for managing user-defined important places and fare settings.
- Implemented validation functions for passenger settings in `passenger-settings.mjs`.
- Created utility functions for transliterating stop names in `transliteration.ts`.
- Developed weather hint functionality in `weather-hint.ts` to provide precipitation probabilities.
- Established a mock server for testing passenger-related features in `passenger-server.mjs`.
- Added comprehensive tests for passenger guide logic and transliteration functionality.
2026-10-12 20:30:49 +03:00

21 lines
1.3 KiB
TypeScript

import type { Scene, Settings } from '../types';
export const informationOptions = [
{ id: 'service', setting: 'infoServiceEnabled', name: 'Маршрут', label: 'Дальше по ближайшему рейсу' },
{ id: 'weather', setting: 'infoWeatherEnabled', name: 'Погода', label: 'Погода' },
{ id: 'qr', setting: 'infoQrEnabled', name: 'RideBus', label: 'QR-код расписания' },
{ id: 'places', setting: 'infoPlacesEnabled', name: 'Места', label: 'До важных мест' },
{ id: 'fare', setting: 'infoFareEnabled', name: 'Оплата', label: 'Оплата поездки' },
] as const;
export type InformationAvailable = { places: boolean; fare: boolean };
export function informationBlocks(settings: Settings, available?: InformationAvailable) {
return informationOptions.filter(block => settings[block.setting] && (block.id !== 'places' || (available?.places ?? settings.places.length > 0))
&& (block.id !== 'fare' || (available?.fare ?? settings.fareRules.length + settings.fareByType.length > 0)));
}
export function boardScenes(settings: Settings, hasAlerts: boolean, urgent: boolean, available?: InformationAvailable): Scene[] {
return ['departures', ...(hasAlerts || informationBlocks(settings, available).length ? ['info'] : []),
...(settings.adsEnabled && !urgent ? ['ad'] : [])] as Scene[];
}