- Added NightScreen component for displaying night mode information and alerts. - Introduced NextStops component to show upcoming stops during a journey. - Implemented logic for determining night mode activation based on schedule and user settings. - Created journey utility functions to manage onward journey data and stop information. - Updated tests to cover new night mode features and journey logic. - Added fixture for testing night mode scenarios with specific timestamps. - Removed QR code from night screen for a cleaner UI experience. - Enhanced admin settings to manage night mode configurations.
29 lines
2.2 KiB
TypeScript
29 lines
2.2 KiB
TypeScript
import type { BoardData } from '../types';
|
|
import { minskDate } from './board.mjs';
|
|
import type { Departure } from '../types';
|
|
import type { OnwardJourney } from './journey';
|
|
|
|
export function demoJourney(departure: Departure | undefined): OnwardJourney | null {
|
|
if (!departure) return null;
|
|
return { stops: ['Площадь Свободы', 'Дом торговли', 'Поликлиника', departure.destination].map((name, index) => ({ id: 1000 + index, name, minutes: [3, 6, 9, 18][index] })), more: 0 };
|
|
}
|
|
|
|
export function createDemo(now = Date.now()): BoardData {
|
|
const routes = [
|
|
{ id: 42, number: '16тк', name: 'Боровуха-3 — Больница (Новка)', destination: 'Больница (Новка)', type: 'minibus' },
|
|
{ id: 1, number: '1', name: 'Швейная фабрика — Богатырская', destination: 'Богатырская', type: 'bus' },
|
|
{ id: 12, number: '6', name: 'Швейная фабрика — Калинина', destination: 'Калинина', type: 'bus' },
|
|
{ id: 22, number: '11', name: 'Швейная фабрика — Тросницкая', destination: 'Тросницкая', type: 'bus' },
|
|
{ id: 21, number: '2тк', name: 'Больница (Ксты) — Больница (Новка)', destination: 'Больница (Новка)', type: 'minibus' },
|
|
];
|
|
return { cityId: 1, cityName: 'Полоцк', stop: { id: 1, name: 'Швейная фабрика', direction: 'основная' },
|
|
routes, departures: [4, 8, 12, 17, 23, 31, 38].map((minutes, index) => {
|
|
const route = routes[index % routes.length];
|
|
const time = new Date(Math.floor(now / 60000) * 60000 + minutes * 60000);
|
|
return { id: `demo-${index}`, routeId: route.id, routeNumber: route.number, routeName: route.name,
|
|
destination: route.destination, type: route.type, scheduledAt: time.toISOString(),
|
|
scheduledTime: new Intl.DateTimeFormat('ru', { timeZone: 'Europe/Minsk', hour: '2-digit', minute: '2-digit' }).format(time),
|
|
note: '', source: 'schedule' };
|
|
}), alerts: [], alertsAvailable: true, partial: false, updatedAt: new Date(now).toISOString(), serviceDate: minskDate(now), mode: 'demo' };
|
|
}
|