mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
de86e6383a
PAD-06 and PAD-09 on screen. A paddle tour open in the planner or shown as recorded carries a checklist card: the obstacles of the data along its route in route order with the paddler's own portages and locks among them, each with its status, its paddling rule and the SUP advice at a lock, and the earlier decisions the route or the data no longer carries behind a fold. A row moves the camera onto the obstacle and the other parts of its lock and opens its card on the map, where the decision panel sits: four choices, the notices that stay after a choice (a ban, the SUP advice, a portage still to plan), the date of the last check on site, a note and who decided when. An object the map does not hold opens in a dialog instead. Deciding waits while the route has unsaved changes, and a stale or dirty list is dimmed, never hidden. The tours list, the desktop day plan and the phone day plan show the bench as one pill, the tour detail shows it with the data's date, and every paddle tour reaches the safety note from its footer. Nothing reads as safe where TREK knows nothing, and nothing blocks.
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
import type { TourObstacleEntry } from '@trek/shared';
|
|
import { ExternalLink } from 'lucide-react';
|
|
import { useId } from 'react';
|
|
import { useTranslation } from '../../../i18n';
|
|
import { useSettingsStore } from '../../../store/settingsStore';
|
|
import { formatDistance } from '../../../utils/units';
|
|
import { DialogHeader, DialogShell, DialogTile, NEUTRAL_TINT, PILL } from '../../shared/DialogShell';
|
|
import { ChecklistEntryPanel } from './ObstacleDecisionPanel';
|
|
import { ChecklistGlyph } from './PaddleCheckBadges';
|
|
import { osmUrlOf } from './paddleObstacleModel';
|
|
import type { PaddleChecklist } from './usePaddleChecklist';
|
|
|
|
/** The pills of the head band: how far along the route the object lies and the object on OpenStreetMap. */
|
|
function EntryPills({ entry }: { entry: TourObstacleEntry }) {
|
|
const { t } = useTranslation();
|
|
const unit = useSettingsStore((state) => state.settings.distance_unit) ?? 'metric';
|
|
const ref = entry.refs[0];
|
|
return (
|
|
<>
|
|
{entry.along_m !== null && (
|
|
<span className={`${PILL} tabular-nums`}>{formatDistance(entry.along_m / 1000, unit)}</span>
|
|
)}
|
|
{ref && (
|
|
<a href={osmUrlOf(ref)} target="_blank" rel="noopener noreferrer" className={`${PILL} hover:underline`}>
|
|
{t('ferratas.viewInOsm')}
|
|
<ExternalLink size={12} strokeWidth={2.2} aria-hidden="true" />
|
|
</a>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
/** The dialog for an entry the checklist holds: its head band, then the decision panel. */
|
|
function EntryDialog({ checklist, entry }: { checklist: PaddleChecklist; entry: TourObstacleEntry }) {
|
|
const { t } = useTranslation();
|
|
const labelId = useId();
|
|
const kind = t(`tours.paddle.obstacle.kind.${entry.kind}`);
|
|
return (
|
|
<DialogShell
|
|
onClose={checklist.closeDialog}
|
|
labelledBy={labelId}
|
|
width="narrow"
|
|
header={
|
|
<DialogHeader
|
|
tile={
|
|
<DialogTile>
|
|
<ChecklistGlyph kind={entry.kind} dashed={entry.relation === 'near'} />
|
|
</DialogTile>
|
|
}
|
|
tint={NEUTRAL_TINT}
|
|
labelId={labelId}
|
|
onClose={checklist.closeDialog}
|
|
title={entry.name ?? kind}
|
|
sub={entry.name ? kind : undefined}
|
|
pills={<EntryPills entry={entry} />}
|
|
/>
|
|
}
|
|
>
|
|
<ChecklistEntryPanel checklist={checklist} entry={entry} />
|
|
</DialogShell>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* PAD-06: one entry of the checklist in a narrow dialog, for an object the
|
|
* map holds no card for (offline, or an earlier decision the data or the
|
|
* route no longer carries): what it is, how far along the route it lies, its
|
|
* object on OpenStreetMap and the same decision panel the map card carries.
|
|
*/
|
|
export function ObstacleEntryDialog({ checklist }: { checklist: PaddleChecklist }) {
|
|
const { check, dialogKey } = checklist;
|
|
const entry = dialogKey === null ? null : (check?.entries.find((item) => item.key === dialogKey) ?? null);
|
|
if (!entry) return null;
|
|
return <EntryDialog checklist={checklist} entry={entry} />;
|
|
}
|