fix(tours): explain a kept tour without a line, and say the take-over once

Taking a tour kept in a collection into a trip left the user guessing in
two places when the tour had no line. The map box stayed an empty grey
square that read as a broken map; it now says that there is no line yet,
only the waypoints. Why "Line only" is dimmed was only in the tooltip of a
disabled button, which never shows on hover, focus or touch; the reason now
stands under the two choices, and a disabled tile sits in a span so its
tooltip can show as well.

A successful take-over said the same sentence twice, as a toast and as the
dialog's last word with "Open trip". The toast is gone.

The collection strings move out of tours.ts into a tourCollection.ts per
locale, keeping their keys, so no locale's tours file grows past the
1000-line limit. The tours locale spec now holds both files to their own
counts.
This commit is contained in:
Maurice
2026-10-20 13:22:44 +02:00
parent 3fe34061fd
commit 65fe8cd6e5
86 changed files with 1565 additions and 1261 deletions
@@ -1,5 +1,5 @@
import type { TourLibraryItem } from '@trek/shared';
import { ArrowUp, Clock, Loader2, Ruler } from 'lucide-react';
import { ArrowUp, Clock, Loader2, Ruler, Spline } from 'lucide-react';
import { useMemo } from 'react';
import { OFM_POSITRON } from '../../../constants/mapDefaults';
import { useTileUrl } from '../../../hooks/useTileUrl';
@@ -113,19 +113,23 @@ type PreviewStatus = 'loading' | 'ready' | 'error' | 'offline' | null;
/**
* A tour's line on a small map, the way a preview shows it before anything is
* taken over: drawn once its points are in, a spinner while they load, a short
* line of text when they cannot be read.
* line of text when they cannot be read, and, where the caller names it, what
* a tour without a line has instead, so an empty box never reads as a broken map.
*/
export function TourLinePreview({
line,
focusKey,
status,
failedText,
emptyText,
}: {
line: ReadonlyArray<readonly unknown[]> | undefined;
focusKey: string;
status: PreviewStatus;
/** What a preview that could not be read says; offline says that it is offline. */
failedText: string;
/** What a tour read in full but without a line says in the box; without it the box stays empty. */
emptyText?: string;
}) {
const { t } = useTranslation();
const tileUrl = useTileUrl(OFM_POSITRON);
@@ -160,6 +164,18 @@ export function TourLinePreview({
{status === 'offline' ? t('tours.library.offline') : failedText}
</span>
)}
{status === 'ready' && route.length === 0 && emptyText && (
<span
className="absolute inset-0 flex flex-col items-center justify-center gap-2 px-6 text-center text-content-muted"
style={fs(12, 'body')}
data-testid="tour-preview-no-line"
>
<span className="grid h-9 w-9 place-items-center rounded-full bg-surface-card text-content-faint shadow-sm ring-1 ring-edge-faint">
<Spline size={16} strokeWidth={2} />
</span>
{emptyText}
</span>
)}
</div>
);
}