@autobusal/routes-order 1.32.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/Checkout/Checkout.tsx +35 -1
- package/Facts/Facts.tsx +130 -15
- package/Facts/questions.ts +215 -0
- package/Facts/styles.ts +26 -0
- package/Facts/types.ts +61 -1
- package/Faq/Faq.tsx +52 -0
- package/Faq/styles.ts +68 -0
- package/Links/Links.tsx +27 -3
- package/Links/styles.ts +30 -0
- package/Sections/Schema.tsx +47 -48
- package/Sections/Sections.tsx +29 -4
- package/Step4/Passenger/Passenger.tsx +196 -12
- package/Step4/Passengers/Display.tsx +6 -2
- package/Step4/Passengers/Passengers.tsx +16 -2
- package/Step4/Saved/Choose.tsx +99 -0
- package/Step4/Saved/Remember.tsx +58 -0
- package/Step4/Saved/styles.ts +87 -0
- package/package.json +1 -1
- package/services.ts +75 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.33.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **The pair page is a page about the journey, not just a search box over it.** `/routes/search/facts` now carries how often the pair is served (the union of days a traveller can leave on, plus departures per week), how many of the scheduled services run non-stop, how many travel overnight, the cities in between, what is on board, the two countries, and the dearest fare alongside the cheapest - all read off the timetable, all riding the existing 6h cache, none of it estimated.
|
|
8
|
+
- Every list-shaped fact carries an `every` flag beside it, and the copy is chosen from that flag. Six of the ten Tirana-Thessaloniki coaches are non-stop and they carry different equipment, so "every bus calls at Korca" and "some buses also call at Korca" are different claims; obtapi says which one the data supports rather than leaving the wording to guess.
|
|
9
|
+
- **A visible FAQ** (`Faq/`), built from `Facts/questions` - the same array the `FAQPage` structured data is emitted from, so the answer Google quotes is the string the page renders, character for character, in all fifteen languages. Native `<details>`, no state: the answer is in the DOM whether it is open or shut, which is what a prerendered snapshot and a crawler that does not click both need. Questions with no data behind them are not asked.
|
|
10
|
+
- **`BusTrip` gained an `itinerary`** - but only where every service on the pair calls at every stop listed. An itinerary is a statement about *the* trip, and on a pair where most coaches run non-stop there is no single itinerary to state. Departure and arrival stops carry a `PostalAddress` where obtapi knows the country.
|
|
11
|
+
- **A "travelling back?" link**, from the new `links.reverse`. Pairs are directional, so the return leg is a different page with its own timetable - and it belonged to neither "popular from" nor "popular to", being a pair from the destination back to the origin. Null, and absent, when nobody sells it.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **"3h 0m" in the facts grid, "3h" in the answer below it.** The facts block carried its own copy of the duration formatter without the whole-hour rule the FAQ answers use, so a three-hour coach was described two ways on one page. One exported formatter now.
|
|
16
|
+
- **The departure count called itself the wrong thing.** `facts.departures` counts the distinct coaches in the timetable, and a single daily one of them makes seven departures a week - so "10 scheduled departures" beside the new "every day, 70 scheduled departures a week" read as a contradiction rather than as two facts. The label and the FAQ answer now say *scheduled services* in all fifteen languages; the number they print is unchanged.
|
|
17
|
+
- **"There are 1 scheduled departures"** - the sentence a thin pair got from the FAQ schema for as long as the block has existed, and a thin pair is most of them. A separate key rather than an i18next plural rule; the plural categories of the eight Slavic locales here are not something one English-shaped rule gets right.
|
|
18
|
+
|
|
19
|
+
## 1.32.1
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **A saved-passenger chooser and a "remember this passenger" checkbox**, per passenger rather than per order, because "remember me but not the person I am buying for" is the ordinary case and one control per booking cannot say it. The list is fetched once for the whole checkout, not once per traveller.
|
|
24
|
+
|
|
25
|
+
Picking applies the whole person, not the filled parts: a passport left from a previous choice is cleared, because the customer has said who is sitting in that seat. Only fields the route actually collects are written - react-hook-form submits values set for names it never registered, so writing the rest would post a WhatsApp number to a route that never asked for one.
|
|
26
|
+
|
|
27
|
+
A journey that needs a field the saved profile lacks says so in the form's own words. `missing` absent means *not measured* and is not treated as "nothing missing".
|
|
28
|
+
|
|
3
29
|
## 1.32.0
|
|
4
30
|
|
|
5
31
|
### Added
|
package/Checkout/Checkout.tsx
CHANGED
|
@@ -24,7 +24,7 @@ import { CouponData } from '@autobusal/providers/types/orders';
|
|
|
24
24
|
import { TotalData } from '../types';
|
|
25
25
|
import { useUserStore } from '@autobusal/providers/stores/user';
|
|
26
26
|
import { useGetSettings } from '@autobusal/providers/services';
|
|
27
|
-
import { usePostOrder, useGetFlex, useGetPayments } from '../services';
|
|
27
|
+
import { usePostOrder, useGetFlex, useGetPayments, useGetSavedPassengers } from '../services';
|
|
28
28
|
import { addon as commerceAddon, beginCheckout, stash } from '@autobusal/providers/Setup/commerce';
|
|
29
29
|
import { item as commerceItem } from '../commerce';
|
|
30
30
|
|
|
@@ -125,6 +125,38 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
|
|
|
125
125
|
step1.babies ?? 0
|
|
126
126
|
);
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* "Book somebody you have booked before" - saved passengers.
|
|
130
|
+
*
|
|
131
|
+
* Edited: Claude - Date: 2026-08-20
|
|
132
|
+
*
|
|
133
|
+
* Fetched ONCE here and drilled down rather than asked for inside each
|
|
134
|
+
* passenger block: a family of five would otherwise be five requests for
|
|
135
|
+
* one list, and the list is the same list.
|
|
136
|
+
*
|
|
137
|
+
* ONLY FOR A SIGNED-IN CUSTOMER. The endpoint is `role:visitor`, so a
|
|
138
|
+
* guest and a member of staff both get a 404 - a deliberate refusal that
|
|
139
|
+
* confirms nothing (see obtapi's Account\PassengersController). Deciding
|
|
140
|
+
* that here, from a fact the app already knows, means the request is never
|
|
141
|
+
* made for them and there is no failed query on a checkout screen to
|
|
142
|
+
* accidentally surface.
|
|
143
|
+
*
|
|
144
|
+
* The price ids go with it so every row comes back saying what THIS
|
|
145
|
+
* journey would still have to ask for - see the chooser.
|
|
146
|
+
*/
|
|
147
|
+
const isCustomer = UserData?.type === 'visitor';
|
|
148
|
+
|
|
149
|
+
const { data: SavedData } = useGetSavedPassengers(
|
|
150
|
+
step2.price.id as number,
|
|
151
|
+
step3?.price.id as (number | undefined),
|
|
152
|
+
isCustomer
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// undefined until the list has landed, which is also what a guest gets and
|
|
156
|
+
// is exactly the right answer for both: nothing about the feature renders
|
|
157
|
+
// until there is an account behind it with an answer
|
|
158
|
+
const saved = isCustomer ? (SavedData?.data ?? []) : undefined;
|
|
159
|
+
|
|
128
160
|
const addonItems = [
|
|
129
161
|
addonWhatsapp && SettingsData?.addons?.whatsapp.available ? {
|
|
130
162
|
label: t('routes_order.step5.addons.whatsapp.label'),
|
|
@@ -280,6 +312,8 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
|
|
|
280
312
|
fields={ fields }
|
|
281
313
|
busFrom={ busFrom }
|
|
282
314
|
busTo={ busTo }
|
|
315
|
+
saved={ saved }
|
|
316
|
+
savedMax={ SavedData?.max }
|
|
283
317
|
t={ t }
|
|
284
318
|
errors={ passenger.formState.errors }
|
|
285
319
|
refs={ passenger.register }
|
package/Facts/Facts.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import { Container, Grid, Fact, Label, Value, Note, Operators } from './styles';
|
|
2
|
+
import { Container, Grid, Fact, Label, Value, Note, Operators, Prose } from './styles';
|
|
3
3
|
import { FactsData } from './types';
|
|
4
|
+
import { DAYS, duration } from './questions';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
id: string
|
|
@@ -29,21 +30,55 @@ interface Props {
|
|
|
29
30
|
* Renders nothing at all when the API has no facts for the pair. An empty
|
|
30
31
|
* facts block is worse than none - it is exactly the thin content this tier
|
|
31
32
|
* exists to remove.
|
|
33
|
+
*
|
|
34
|
+
* Edited: Claude - Date: 2026-08-20
|
|
35
|
+
*
|
|
36
|
+
* It now also answers "what is this journey LIKE", which is the half a
|
|
37
|
+
* grid of numbers cannot: how often it runs, how many of the coaches are
|
|
38
|
+
* non-stop, how many travel overnight, where they call, what is on board,
|
|
39
|
+
* and whether it crosses a border. Sentences rather than more tiles,
|
|
40
|
+
* because that is the half a reader takes away and a machine can quote.
|
|
41
|
+
*
|
|
42
|
+
* The same restraint applies to all of it: a sentence whose data is
|
|
43
|
+
* missing is not printed, and one whose data supports only a weaker claim
|
|
44
|
+
* is printed in the weaker wording. A pair with one weekly coach ends up
|
|
45
|
+
* with a short honest block, not a padded one.
|
|
32
46
|
*/
|
|
33
47
|
const Facts = ({ id, facts, t }: Props): JSX.Element => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Edited: Claude - Date: 2026-08-20
|
|
50
|
+
*
|
|
51
|
+
* Whether this coach leaves the country, which is the first thing a
|
|
52
|
+
* traveller wants settled and the one fact here that is not about the
|
|
53
|
+
* timetable at all - it is about the two cities. Silent when either
|
|
54
|
+
* country is unknown rather than assuming the pair is domestic, and
|
|
55
|
+
* silent on the wording of what a border crossing REQUIRES: entry rules
|
|
56
|
+
* are the traveller's own and this page has no business inventing them.
|
|
57
|
+
*/
|
|
58
|
+
const countries = (() => {
|
|
59
|
+
if (!facts.from_country || !facts.to_country) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return facts.from_country === facts.to_country
|
|
64
|
+
? <p>{ t('routes_order.facts.domestic', { country: facts.from_country }) }</p>
|
|
65
|
+
: <p>{ t('routes_order.facts.international', { from_country: facts.from_country, to_country: facts.to_country }) }</p>;
|
|
66
|
+
})();
|
|
67
|
+
|
|
68
|
+
const via = facts.via && facts.via.cities.length > 0 ? facts.via : null;
|
|
69
|
+
|
|
70
|
+
const amenities = facts.amenities && facts.amenities.names.length > 0 ? facts.amenities : null;
|
|
71
|
+
|
|
72
|
+
// Edited: Claude - Date: 2026-08-20
|
|
73
|
+
// A thin pair can have none of the four sentences below, and an empty
|
|
74
|
+
// <Prose> is still a box with a top margin - a gap under the grid that
|
|
75
|
+
// reads as something failing to load.
|
|
76
|
+
const prose = Boolean(countries || via || amenities || facts.operators.length > 0);
|
|
42
77
|
|
|
43
78
|
const range = facts.duration_min !== null && facts.duration_max !== null
|
|
44
79
|
? (facts.duration_min === facts.duration_max
|
|
45
|
-
? duration(facts.duration_min)
|
|
46
|
-
: `${ duration(facts.duration_min) } – ${ duration(facts.duration_max) }`)
|
|
80
|
+
? duration(facts.duration_min, t)
|
|
81
|
+
: `${ duration(facts.duration_min, t) } – ${ duration(facts.duration_max, t) }`)
|
|
47
82
|
: null;
|
|
48
83
|
|
|
49
84
|
return (
|
|
@@ -84,6 +119,51 @@ const Facts = ({ id, facts, t }: Props): JSX.Element => {
|
|
|
84
119
|
<Value>{ facts.departures }</Value>
|
|
85
120
|
</Fact>
|
|
86
121
|
|
|
122
|
+
{ /* Edited: Claude - Date: 2026-08-20
|
|
123
|
+
HOW OFTEN, which the departure count above cannot say - ten
|
|
124
|
+
services means something very different once a week than it
|
|
125
|
+
does every day. Absent entirely when no coach on the pair has a
|
|
126
|
+
usable timetable row, including the case that matters: a season
|
|
127
|
+
that has already ended. Saying nothing there is the honest
|
|
128
|
+
answer; "runs 3 times a week" about a coach that stopped
|
|
129
|
+
running last September is not. */ }
|
|
130
|
+
{ facts.frequency && (
|
|
131
|
+
<Fact>
|
|
132
|
+
<Label>{ t('routes_order.facts.frequency') }</Label>
|
|
133
|
+
|
|
134
|
+
<Value>
|
|
135
|
+
{ facts.frequency.daily
|
|
136
|
+
? t('routes_order.facts.frequency_daily')
|
|
137
|
+
: facts.frequency.days.map(day => t(`data.days.${ DAYS[day] }`)).join(', ') }
|
|
138
|
+
|
|
139
|
+
<Note>
|
|
140
|
+
{ facts.frequency.weekly === 1
|
|
141
|
+
? t('routes_order.facts.frequency_weekly_single')
|
|
142
|
+
: t('routes_order.facts.frequency_weekly', { count: facts.frequency.weekly }) }
|
|
143
|
+
</Note>
|
|
144
|
+
</Value>
|
|
145
|
+
</Fact>
|
|
146
|
+
) }
|
|
147
|
+
|
|
148
|
+
{ /* Edited: Claude - Date: 2026-08-20
|
|
149
|
+
Counted out of the total rather than shown as a yes/no. "Direct
|
|
150
|
+
service: yes" on a pair where one coach in ten is direct is
|
|
151
|
+
true and useless; "1 of 10" is what a reader needs to know
|
|
152
|
+
before they start comparing departures. */ }
|
|
153
|
+
{ facts.direct > 0 && (
|
|
154
|
+
<Fact>
|
|
155
|
+
<Label>{ t('routes_order.facts.direct') }</Label>
|
|
156
|
+
<Value>{ t('routes_order.facts.of_total', { count: facts.direct, total: facts.departures }) }</Value>
|
|
157
|
+
</Fact>
|
|
158
|
+
) }
|
|
159
|
+
|
|
160
|
+
{ facts.overnight > 0 && (
|
|
161
|
+
<Fact>
|
|
162
|
+
<Label>{ t('routes_order.facts.overnight') }</Label>
|
|
163
|
+
<Value>{ t('routes_order.facts.of_total', { count: facts.overnight, total: facts.departures }) }</Value>
|
|
164
|
+
</Fact>
|
|
165
|
+
) }
|
|
166
|
+
|
|
87
167
|
{ facts.distance && (
|
|
88
168
|
<Fact>
|
|
89
169
|
<Label>{ t('routes_order.facts.distance') }</Label>
|
|
@@ -107,10 +187,45 @@ const Facts = ({ id, facts, t }: Props): JSX.Element => {
|
|
|
107
187
|
) }
|
|
108
188
|
</Grid>
|
|
109
189
|
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
190
|
+
{ /* Edited: Claude - Date: 2026-08-20
|
|
191
|
+
The part somebody reads rather than scans. Four sentences at most,
|
|
192
|
+
each one printed only when the data behind it exists, and none of
|
|
193
|
+
them a generality - a pair served by one weekly coach gets one
|
|
194
|
+
sentence and it is true, which is a better page than four
|
|
195
|
+
sentences of hedging.
|
|
196
|
+
|
|
197
|
+
EVERY/SOME IS THE WHOLE CARE HERE. Buses on one route are not
|
|
198
|
+
interchangeable: six of the ten Tirana-Thessaloniki coaches run
|
|
199
|
+
non-stop and they carry different equipment. "Every bus calls at
|
|
200
|
+
Korca" and "some buses also call at Korca" are different claims
|
|
201
|
+
and obtapi says which one the data supports, so the copy never
|
|
202
|
+
has to guess. */ }
|
|
203
|
+
{ prose && (
|
|
204
|
+
<Prose>
|
|
205
|
+
{ countries }
|
|
206
|
+
|
|
207
|
+
{ via && (
|
|
208
|
+
<p>
|
|
209
|
+
{ t(via.every ? 'routes_order.facts.via_every' : 'routes_order.facts.via_some', {
|
|
210
|
+
cities: via.cities.join(', ')
|
|
211
|
+
}) }
|
|
212
|
+
</p>
|
|
213
|
+
) }
|
|
214
|
+
|
|
215
|
+
{ amenities && (
|
|
216
|
+
<p>
|
|
217
|
+
{ t(amenities.every ? 'routes_order.facts.amenities_every' : 'routes_order.facts.amenities_some', {
|
|
218
|
+
amenities: amenities.names.join(', ')
|
|
219
|
+
}) }
|
|
220
|
+
</p>
|
|
221
|
+
) }
|
|
222
|
+
|
|
223
|
+
{ facts.operators.length > 0 && (
|
|
224
|
+
<Operators>
|
|
225
|
+
{ t('routes_order.facts.operators', { operators: facts.operators.join(', ') }) }
|
|
226
|
+
</Operators>
|
|
227
|
+
) }
|
|
228
|
+
</Prose>
|
|
114
229
|
) }
|
|
115
230
|
</Container>
|
|
116
231
|
);
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import { FactsData } from './types';
|
|
3
|
+
|
|
4
|
+
export interface Question {
|
|
5
|
+
// stable enough to key a list on, and never rendered
|
|
6
|
+
id: string
|
|
7
|
+
q: string
|
|
8
|
+
a: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ISO weekday to the short day names the rest of the site already ships in
|
|
13
|
+
* all fifteen languages (`data.days.*`) - "Mon, Wed, Fri" rather than a new
|
|
14
|
+
* set of long names nobody would have translated for a week.
|
|
15
|
+
*/
|
|
16
|
+
export const DAYS: Record<number, string> = {
|
|
17
|
+
1: 'mon', 2: 'tue', 3: 'wed', 4: 'thu', 5: 'fri', 6: 'sat', 7: 'sun'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The questions a pair page answers, and their answers.
|
|
22
|
+
*
|
|
23
|
+
* Edited: Claude - Date: 2026-08-20
|
|
24
|
+
*
|
|
25
|
+
* ONE BUILDER, TWO CONSUMERS, AND THAT IS THE ENTIRE POINT. The FAQPage
|
|
26
|
+
* structured data and the FAQ a human reads are built from this same array,
|
|
27
|
+
* so the schema's `acceptedAnswer` is the identical string the page renders
|
|
28
|
+
* a few hundred pixels away - character for character, in whatever language
|
|
29
|
+
* the reader is in. Google requires that match and pulls a site's rich
|
|
30
|
+
* results when it fails; two lists of hand-written questions kept in step by
|
|
31
|
+
* good intentions is exactly how it fails, six months later, in one locale
|
|
32
|
+
* nobody re-read.
|
|
33
|
+
*
|
|
34
|
+
* EVERY ANSWER IS A FACT obtapi COMPUTED, never an estimate and never a
|
|
35
|
+
* generality. A question whose data is missing is not asked: no "typically
|
|
36
|
+
* around 6 hours", no "usually several a day". A pair served by one coach a
|
|
37
|
+
* week gets four questions and they are all true, which is a better page
|
|
38
|
+
* than eight questions padded with hedges.
|
|
39
|
+
*
|
|
40
|
+
* Ordered by how often the question is actually typed - how long, how much,
|
|
41
|
+
* how often - rather than by how the payload happens to be shaped.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* A journey length, in words.
|
|
45
|
+
*
|
|
46
|
+
* Edited: Claude - Date: 2026-08-20
|
|
47
|
+
*
|
|
48
|
+
* "07:30" built from a duration in minutes reads as a time of day, so the
|
|
49
|
+
* hours and minutes are spelled out - and a whole number of hours drops the
|
|
50
|
+
* "0m" rather than printing it.
|
|
51
|
+
*
|
|
52
|
+
* Exported because the facts block prints the same number a few hundred
|
|
53
|
+
* pixels from the FAQ answer that quotes it, and it had its own copy of
|
|
54
|
+
* this without the whole-hour rule: a three-hour coach read "3h 0m" in the
|
|
55
|
+
* grid and "3h" in the answer directly below it, on the same page, about
|
|
56
|
+
* the same bus.
|
|
57
|
+
*/
|
|
58
|
+
export const duration = (minutes: number, t: TFunction<'common'>): string => (
|
|
59
|
+
minutes % 60 === 0
|
|
60
|
+
? t('routes_order.facts.duration_hours', { hours: minutes / 60 })
|
|
61
|
+
: t('routes_order.facts.duration_value', { hours: Math.floor(minutes / 60), minutes: minutes % 60 })
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const questions = (facts: FactsData, t: TFunction<'common'>): Question[] => {
|
|
65
|
+
const all: Question[] = [];
|
|
66
|
+
|
|
67
|
+
const cities = { from: facts.from, to: facts.to };
|
|
68
|
+
|
|
69
|
+
if (facts.duration_min !== null && facts.duration_max !== null) {
|
|
70
|
+
all.push({
|
|
71
|
+
id: 'duration',
|
|
72
|
+
q: t('routes_order.schema.duration_q', cities),
|
|
73
|
+
a: facts.duration_min === facts.duration_max
|
|
74
|
+
? t('routes_order.schema.duration_a', { ...cities, duration: duration(facts.duration_min, t) })
|
|
75
|
+
: t('routes_order.schema.duration_a_range', { ...cities, min: duration(facts.duration_min, t), max: duration(facts.duration_max, t) })
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (facts.price_from_display) {
|
|
80
|
+
all.push({
|
|
81
|
+
id: 'price',
|
|
82
|
+
q: t('routes_order.schema.price_q', cities),
|
|
83
|
+
|
|
84
|
+
// A range only where there is one. On a pair whose services all cost
|
|
85
|
+
// the same, "from 15.00 EUR to 15.00 EUR" is a sentence that makes a
|
|
86
|
+
// reader distrust the rest of the page.
|
|
87
|
+
a: facts.price_to_display && facts.price_to !== facts.price_from
|
|
88
|
+
? t('routes_order.schema.price_a_range', { ...cities, low: facts.price_from_display, high: facts.price_to_display })
|
|
89
|
+
: t('routes_order.schema.price_a', { ...cities, price: facts.price_from_display })
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (facts.frequency) {
|
|
94
|
+
const days = facts.frequency.days.map(day => t(`data.days.${ DAYS[day] }`)).join(', ');
|
|
95
|
+
|
|
96
|
+
all.push({
|
|
97
|
+
id: 'frequency',
|
|
98
|
+
q: t('routes_order.schema.frequency_q', cities),
|
|
99
|
+
a: facts.frequency.daily
|
|
100
|
+
? t('routes_order.schema.frequency_a_daily', { ...cities, count: facts.frequency.weekly })
|
|
101
|
+
: (facts.frequency.weekly === 1
|
|
102
|
+
? t('routes_order.schema.frequency_a_single', { ...cities, days })
|
|
103
|
+
: t('routes_order.schema.frequency_a', { ...cities, days, count: facts.frequency.weekly }))
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (facts.departures > 0) {
|
|
108
|
+
all.push({
|
|
109
|
+
id: 'departures',
|
|
110
|
+
q: t('routes_order.schema.departures_q', cities),
|
|
111
|
+
|
|
112
|
+
// SERVICES, not departures. `facts.departures` counts the distinct
|
|
113
|
+
// coaches in the timetable, and a single daily one of them makes
|
|
114
|
+
// seven departures a week - so beside the frequency answer above,
|
|
115
|
+
// the old wording ("10 scheduled departures" next to "70 a week")
|
|
116
|
+
// read as a contradiction rather than as two facts. Both strings
|
|
117
|
+
// were reworded; the number they print never changed.
|
|
118
|
+
//
|
|
119
|
+
// And "There are 1 scheduled departures" was the sentence a thin
|
|
120
|
+
// pair got for as long as this block has existed - a thin pair being
|
|
121
|
+
// most of them. A separate key rather than an i18next plural: the
|
|
122
|
+
// plural categories of the eight Slavic locales here are not
|
|
123
|
+
// something a single English-shaped rule gets right.
|
|
124
|
+
a: facts.departures === 1
|
|
125
|
+
? t('routes_order.schema.departures_a_single', cities)
|
|
126
|
+
: t('routes_order.schema.departures_a', { ...cities, count: facts.departures })
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (facts.departure_first && facts.departure_last) {
|
|
131
|
+
all.push({
|
|
132
|
+
id: 'times',
|
|
133
|
+
q: t('routes_order.schema.times_q', cities),
|
|
134
|
+
a: t('routes_order.schema.times_a', { first: facts.departure_first, last: facts.departure_last })
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Asked only where the answer is a real count. `direct` is meaningless
|
|
139
|
+
// without a total to read it against, and `departures` is that total.
|
|
140
|
+
if (facts.departures > 0) {
|
|
141
|
+
all.push({
|
|
142
|
+
id: 'direct',
|
|
143
|
+
q: t('routes_order.schema.direct_q', cities),
|
|
144
|
+
a: facts.direct === 0
|
|
145
|
+
? t('routes_order.schema.direct_a_none', cities)
|
|
146
|
+
: (facts.direct === facts.departures
|
|
147
|
+
? t('routes_order.schema.direct_a_all', cities)
|
|
148
|
+
: t('routes_order.schema.direct_a', { ...cities, count: facts.direct, total: facts.departures }))
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Only when there IS a night service. "No, none of these run overnight" is
|
|
153
|
+
// a question asked to be answered no, which is padding.
|
|
154
|
+
if (facts.overnight > 0) {
|
|
155
|
+
all.push({
|
|
156
|
+
id: 'overnight',
|
|
157
|
+
q: t('routes_order.schema.overnight_q', cities),
|
|
158
|
+
a: facts.overnight === facts.departures
|
|
159
|
+
? t('routes_order.schema.overnight_a_all', cities)
|
|
160
|
+
: t('routes_order.schema.overnight_a', { ...cities, count: facts.overnight, total: facts.departures })
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (facts.via && facts.via.cities.length > 0) {
|
|
165
|
+
all.push({
|
|
166
|
+
id: 'via',
|
|
167
|
+
q: t('routes_order.schema.via_q', cities),
|
|
168
|
+
|
|
169
|
+
// The same sentence the facts block shows, deliberately - it is the
|
|
170
|
+
// one wording that distinguishes "every coach calls here" from "one of
|
|
171
|
+
// them does", and the answer must not be a looser paraphrase of it.
|
|
172
|
+
a: t(facts.via.every ? 'routes_order.facts.via_every' : 'routes_order.facts.via_some', {
|
|
173
|
+
cities: facts.via.cities.join(', ')
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (facts.amenities && facts.amenities.names.length > 0) {
|
|
179
|
+
all.push({
|
|
180
|
+
id: 'amenities',
|
|
181
|
+
q: t('routes_order.schema.amenities_q', cities),
|
|
182
|
+
a: t(facts.amenities.every ? 'routes_order.facts.amenities_every' : 'routes_order.facts.amenities_some', {
|
|
183
|
+
amenities: facts.amenities.names.join(', ')
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (facts.operators.length > 0) {
|
|
189
|
+
all.push({
|
|
190
|
+
id: 'operators',
|
|
191
|
+
q: t('routes_order.schema.operators_q', cities),
|
|
192
|
+
a: t('routes_order.facts.operators', { operators: facts.operators.join(', ') })
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (facts.distance) {
|
|
197
|
+
all.push({
|
|
198
|
+
id: 'distance',
|
|
199
|
+
q: t('routes_order.schema.distance_q', cities),
|
|
200
|
+
|
|
201
|
+
// The approximation gets its own sentence rather than the same one
|
|
202
|
+
// with a hedge bolted on. It is a sum of straight lines and it is
|
|
203
|
+
// ALWAYS short - 309 km against 412 km of tarmac on
|
|
204
|
+
// Tirana-Thessaloniki - so an answer that called it the road distance
|
|
205
|
+
// "approximately" would be wrong by a quarter on every pair.
|
|
206
|
+
a: facts.distance.road !== null
|
|
207
|
+
? t('routes_order.schema.distance_a', { ...cities, km: facts.distance.road })
|
|
208
|
+
: t('routes_order.schema.distance_a_approx', { ...cities, km: facts.distance.approx })
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return all;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export default questions;
|
package/Facts/styles.ts
CHANGED
|
@@ -46,3 +46,29 @@ export const Operators = styled.p`
|
|
|
46
46
|
font-size: ${ props => props.theme.size.s };
|
|
47
47
|
line-height: 1.5;
|
|
48
48
|
`;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The readable half of the facts block.
|
|
52
|
+
*
|
|
53
|
+
* Edited: Claude - Date: 2026-08-20
|
|
54
|
+
*
|
|
55
|
+
* The grid above answers "what are the numbers"; this answers "what is this
|
|
56
|
+
* journey like" in sentences, which is what a search engine quotes and what
|
|
57
|
+
* a reader actually takes away. Sized as body copy rather than as the faded
|
|
58
|
+
* footnote the operators line used to be on its own - it is content now, not
|
|
59
|
+
* an attribution.
|
|
60
|
+
*/
|
|
61
|
+
export const Prose = styled.div`
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
gap: 8px;
|
|
65
|
+
margin-top: 20px;
|
|
66
|
+
|
|
67
|
+
/* One rule for the spacing, so the paragraphs below - which include the
|
|
68
|
+
operators line and its own older margin - cannot each have an opinion
|
|
69
|
+
about the gap between them. */
|
|
70
|
+
p {
|
|
71
|
+
margin: 0;
|
|
72
|
+
line-height: 1.6;
|
|
73
|
+
}
|
|
74
|
+
`;
|
package/Facts/types.ts
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edited: Claude - Date: 2026-08-20
|
|
3
|
+
*
|
|
4
|
+
* A list of things that are true of the pair, plus whether they are true of
|
|
5
|
+
* EVERY service on it. Buses on one route are not interchangeable - six of
|
|
6
|
+
* the ten Tirana-Thessaloniki coaches are non-stop and they carry different
|
|
7
|
+
* equipment - so "the bus has Wi-Fi" and "one of these buses has Wi-Fi" are
|
|
8
|
+
* different claims and the copy has to be able to tell them apart.
|
|
9
|
+
*/
|
|
10
|
+
export interface FactsList {
|
|
11
|
+
every: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
1
14
|
export interface FactsData {
|
|
2
15
|
from: string
|
|
3
16
|
to: string
|
|
17
|
+
// Edited: Claude - Date: 2026-08-20
|
|
18
|
+
// Names only, and null for a city whose country is not recorded. Lets the
|
|
19
|
+
// page say whether this journey crosses a border, which changes what a
|
|
20
|
+
// traveller has to bring.
|
|
21
|
+
from_country: string | null
|
|
22
|
+
to_country: string | null
|
|
4
23
|
// cheapest adult fare anybody sells this leg for
|
|
5
24
|
price_from: number | null
|
|
6
25
|
// formatted by the API with the brand's own currency - the PUBLIC settings
|
|
7
26
|
// payload carries no currency, so a frontend has nothing to format with
|
|
8
27
|
price_from_display: string | null
|
|
28
|
+
// Edited: Claude - Date: 2026-08-20
|
|
29
|
+
// The dearest fare on the pair, so "how much is a ticket" can answer with
|
|
30
|
+
// a range. Equal to price_from where every service costs the same, and
|
|
31
|
+
// the copy collapses to the single-price sentence rather than printing
|
|
32
|
+
// "from X to X".
|
|
33
|
+
price_to: number | null
|
|
34
|
+
price_to_display: string | null
|
|
9
35
|
// ISO 4217, for schema.org's Offer - the display string has the symbol
|
|
10
36
|
// baked in and guessing a code back out of it would be confidently wrong
|
|
11
37
|
currency: string | null
|
|
@@ -17,6 +43,34 @@ export interface FactsData {
|
|
|
17
43
|
// how many coaches serve the pair in the TIMETABLE, not on a given date
|
|
18
44
|
departures: number
|
|
19
45
|
operators: string[]
|
|
46
|
+
/**
|
|
47
|
+
* Edited: Claude - Date: 2026-08-20
|
|
48
|
+
*
|
|
49
|
+
* How often, which `departures` cannot say - ten services means something
|
|
50
|
+
* very different once a week than it does every day.
|
|
51
|
+
*
|
|
52
|
+
* `days` is the UNION of the days a traveller can leave on, ISO 1 Monday
|
|
53
|
+
* to 7 Sunday. `weekly` is the SUM across services, so three daily coaches
|
|
54
|
+
* is 21 rather than 7. Neither is recoverable from the other.
|
|
55
|
+
*
|
|
56
|
+
* NULL when no service on the pair has a usable timetable row - including
|
|
57
|
+
* the case that matters, a season that has already ENDED. A summer coach
|
|
58
|
+
* whose window closed last September does not "run three times a week",
|
|
59
|
+
* and obtapi withholds the whole object rather than counting it.
|
|
60
|
+
*/
|
|
61
|
+
frequency: { days: number[], weekly: number, daily: boolean } | null
|
|
62
|
+
// how many of the `departures` run non-stop, and how many are still
|
|
63
|
+
// rolling the next morning - counted out of the total rather than reported
|
|
64
|
+
// as a yes/no, because "one of ten is direct" is the honest version
|
|
65
|
+
direct: number
|
|
66
|
+
overnight: number
|
|
67
|
+
// the cities in between, across every service on the pair - `every` says
|
|
68
|
+
// whether all of them call at all of these, which on a busy pair they
|
|
69
|
+
// usually do not
|
|
70
|
+
via: (FactsList & { cities: string[] }) | null
|
|
71
|
+
// what is on board, resolved to display names by obtapi (the ids are
|
|
72
|
+
// inventory keys and the names come from its lang files)
|
|
73
|
+
amenities: (FactsList & { names: string[] }) | null
|
|
20
74
|
// Edited: Claude - Date: 2026-08-20
|
|
21
75
|
// The pair's own review score - the published reviews of every route in
|
|
22
76
|
// this very timetable, aggregated by obtapi with the same threshold rule
|
|
@@ -73,5 +127,11 @@ export interface FactsResponse {
|
|
|
73
127
|
facts: FactsData | null
|
|
74
128
|
// Tier 3.4 - pairs leaving the origin, and pairs arriving at the
|
|
75
129
|
// destination. Present even when `facts` is null.
|
|
76
|
-
|
|
130
|
+
//
|
|
131
|
+
// Edited: Claude - Date: 2026-08-20
|
|
132
|
+
// `reverse` is the journey home. Pairs are directional, so it is a
|
|
133
|
+
// different page with its own timetable and fares - and it belongs to
|
|
134
|
+
// neither of the two blocks above, being a pair from the DESTINATION back
|
|
135
|
+
// to the origin. Null when the return leg is not sold.
|
|
136
|
+
links: { from: LinkRow[], to: LinkRow[], reverse: LinkRow | null }
|
|
77
137
|
}
|
package/Faq/Faq.tsx
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import { Container, Heading, List, Item, Question, Answer } from './styles';
|
|
3
|
+
import { Question as QuestionData } from '../Facts/questions';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
id: string
|
|
7
|
+
from: string
|
|
8
|
+
to: string
|
|
9
|
+
// Edited: Claude - Date: 2026-08-20
|
|
10
|
+
// Handed in already built, from Facts/questions - the same array the
|
|
11
|
+
// FAQPage structured data is emitted from. Building them here as well
|
|
12
|
+
// would give the page two lists that agree today and drift the first time
|
|
13
|
+
// one of them is edited, and the whole value of an FAQ rich result is that
|
|
14
|
+
// the answer Google quotes is the answer the reader finds.
|
|
15
|
+
questions: QuestionData[]
|
|
16
|
+
t: TFunction<'common'>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The questions this pair page answers, for a human.
|
|
21
|
+
*
|
|
22
|
+
* Edited: Claude - Date: 2026-08-20
|
|
23
|
+
*
|
|
24
|
+
* Every answer is a fact obtapi computed off the timetable - how long, how
|
|
25
|
+
* much, how often, who runs it, where it stops - so a pair served by one
|
|
26
|
+
* coach a week gets a short honest section rather than a long padded one.
|
|
27
|
+
* Nothing is asked that the data cannot answer, which is why this renders
|
|
28
|
+
* whatever it is handed and never composes a fallback.
|
|
29
|
+
*/
|
|
30
|
+
const Faq = ({ id, from, to, questions, t }: Props): (JSX.Element | null) => {
|
|
31
|
+
if (questions.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Container id={ id } className="box">
|
|
37
|
+
<Heading>{ t('routes_order.faq.title', { from, to }) }</Heading>
|
|
38
|
+
|
|
39
|
+
<List>
|
|
40
|
+
{ questions.map(item => (
|
|
41
|
+
<Item key={ item.id }>
|
|
42
|
+
<Question>{ item.q }</Question>
|
|
43
|
+
|
|
44
|
+
<Answer>{ item.a }</Answer>
|
|
45
|
+
</Item>
|
|
46
|
+
)) }
|
|
47
|
+
</List>
|
|
48
|
+
</Container>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Faq;
|