mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
b7951baf23
- RTL: the measured pills and centred controls use logical forms or a marked line - i18n: the two native widget numbers are positions, not counts (NOT_PLURAL) - Types: styleOverride on the lazy GL map, the location and shared-file payloads, the capabilities fallback, the transport sheet's stay metadata - ESLint: latest-value refs move to layout effects, usePresence keeps the last open state in state, the booking import opens clean with a shared document kept in the list (the reset effect used to clear it again) - Layers: the phone import sheet lives under mobile/ and reads through tripRepo; the offline host check moves to utils/tileUrl - Sizes: plugin layer geometry, hardNavigate and the exit animations get modules of their own - Tests follow the status radios, the stay chip overview, the dock + button for the first list and the field token; store registry lists the new stores
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { Day } from '../../types';
|
|
|
|
/** A day as the pager needs it: only its id, so the plan and Vacay can both page. */
|
|
export type PagerItem = Pick<Day, 'id'>;
|
|
|
|
interface Page {
|
|
key: string;
|
|
dayId: number | null;
|
|
active: boolean;
|
|
}
|
|
|
|
/** The window of pages around the selection. A selection that points at no
|
|
* day (the whole-trip view, or a day deleted remotely) still gets its page,
|
|
* with the first day next to it as a way back. */
|
|
export function pagesFor(days: PagerItem[], selectedDayId: number | null): Page[] {
|
|
const i = days.findIndex((d) => d.id === selectedDayId);
|
|
if (i < 0) {
|
|
const first = days[0];
|
|
return [
|
|
{ key: 'none', dayId: selectedDayId, active: true },
|
|
...(first ? [{ key: `d${first.id}`, dayId: first.id, active: false }] : []),
|
|
];
|
|
}
|
|
const pages: Page[] = [];
|
|
const prev = days[i - 1];
|
|
const next = days[i + 1];
|
|
if (prev) pages.push({ key: `d${prev.id}`, dayId: prev.id, active: false });
|
|
pages.push({ key: `d${days[i].id}`, dayId: days[i].id, active: true });
|
|
if (next) pages.push({ key: `d${next.id}`, dayId: next.id, active: false });
|
|
return pages;
|
|
}
|