mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 01:12:16 +00:00
164a3633ac
Ski becomes "Ski & winter", a type the planner plans with six disciplines (alpine, snowboard, cross-country, ski touring, snowshoeing, winter hiking), nothing preselected; saving needs a discipline, and a technique for cross-country. Every leg is drawn straight between the points through planner/skiRouting.ts, the one place the piste router will plug in, with its heights from the elevation source and no ski time worked out. The hike's winter label goes entirely: its migration, column, field, marks, GPX rule, MCP field and strings. A hike is summer only; a ski tour with the snowshoe discipline exports as snowshoeing. The unreleased ski migration takes the six disciplines and the collection migration loses the winter column. The pistes are offered for a ski tour, shown until switched off, and with no tour open, never for a hike. Export, copy, collections, stages (untimed), actual tracks, the atlas, list and day marks (one glyph per discipline), 3D, planning over a ski import and list_tours/get_tour_plan know the planned ski tour.
84 lines
3.4 KiB
TypeScript
84 lines
3.4 KiB
TypeScript
import { SKI_DISCIPLINES, SKI_TECHNIQUES, type SkiDiscipline, type SkiTechnique } from '@trek/shared';
|
|
import { Info } from 'lucide-react';
|
|
import { useTranslation } from '../../../i18n';
|
|
import { LABEL, Segmented } from '../../shared/dialogParts';
|
|
import { InfoDot, TourNotice } from '../tourParts';
|
|
import { skiChoiceMissing, type SkiChoice } from './skiChoice';
|
|
import { SKI_DISCIPLINE_ICON } from './skiDiscipline';
|
|
|
|
/**
|
|
* SKI-02: what a ski tour is, chosen on purpose: the discipline, none until
|
|
* one is picked, six of them in two columns, and for cross-country the
|
|
* technique, Unknown among its answers. The technique stays in sight but
|
|
* dimmed while another discipline is chosen. The info dot says what TREK does
|
|
* with the tour. The GPX import, the classification dialog and the planner
|
|
* share it; `planned` says the choice is asked for a tour to save rather than
|
|
* a track to import.
|
|
*/
|
|
export function SkiClassificationFields({
|
|
choice,
|
|
onChange,
|
|
planned = false,
|
|
}: {
|
|
choice: SkiChoice;
|
|
onChange: (choice: SkiChoice) => void;
|
|
planned?: boolean;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const crossCountry = choice.discipline === 'cross_country';
|
|
const missing = skiChoiceMissing(choice);
|
|
return (
|
|
<div data-testid="tour-ski-fields" className="flex min-w-0 flex-col gap-3">
|
|
<div className="min-w-0">
|
|
<div className="mb-[5px] flex min-h-5 min-w-0 items-center gap-1">
|
|
<span className={`${LABEL} !mb-0 min-w-0 truncate leading-5`}>{t('tours.ski.discipline')}</span>
|
|
<InfoDot label={t('tours.ski.infoLabel')} description={t('tours.ski.info')} />
|
|
</div>
|
|
<Segmented<SkiDiscipline>
|
|
value={(choice.discipline ?? '') as SkiDiscipline}
|
|
onChange={(discipline) => onChange({ ...choice, discipline })}
|
|
label={t('tours.ski.discipline')}
|
|
columns={2}
|
|
options={SKI_DISCIPLINES.map((discipline) => {
|
|
const Icon = SKI_DISCIPLINE_ICON[discipline];
|
|
return {
|
|
value: discipline,
|
|
// Two columns in a narrow rail: a long name ends in an ellipsis rather than spilling out.
|
|
label: <span className="min-w-0 truncate">{t(`tours.ski.discipline.${discipline}`)}</span>,
|
|
icon: <Icon size={13} strokeWidth={2} aria-hidden="true" className="flex-none" />,
|
|
};
|
|
})}
|
|
/>
|
|
</div>
|
|
<fieldset
|
|
data-testid="tour-ski-technique"
|
|
disabled={!crossCountry}
|
|
className={`m-0 min-w-0 border-0 p-0 transition-opacity ${crossCountry ? '' : 'opacity-50'}`}
|
|
>
|
|
<span className={LABEL}>{t('tours.ski.technique')}</span>
|
|
<Segmented<SkiTechnique>
|
|
value={(crossCountry ? (choice.technique ?? '') : '') as SkiTechnique}
|
|
onChange={(technique) => onChange({ ...choice, technique })}
|
|
label={t('tours.ski.technique')}
|
|
fill
|
|
options={SKI_TECHNIQUES.map((technique) => ({
|
|
value: technique,
|
|
label: t(`tours.ski.technique.${technique}`),
|
|
}))}
|
|
/>
|
|
</fieldset>
|
|
{missing && (
|
|
<TourNotice role="status" icon={<Info size={13} strokeWidth={2} />}>
|
|
{t(
|
|
missing === 'technique'
|
|
? 'tours.ski.chooseTechnique'
|
|
: planned
|
|
? 'tours.ski.chooseDisciplineToSave'
|
|
: 'tours.ski.chooseDiscipline'
|
|
)}
|
|
</TourNotice>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|