mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(ci): repair mobile client checks
Split mobile view logic at existing UI boundaries and keep shared calendar hooks outside component modules. Register the phone-only files and make the sheet gesture and final budget assertions independent of scheduling.
This commit is contained in:
@@ -1236,6 +1236,7 @@
|
||||
"src/mobile/screens/collections/MCollListPickerSheet.tsx": "Phone list picker sheet; the move or copy action comes through onPick from useCollections.",
|
||||
"src/mobile/screens/collections/MCollSheetKit.tsx": "Phone only sheet UI primitives for the collections screens (header, footer, pill, eyebrow).",
|
||||
"src/mobile/screens/collections/collectionsMobileModel.ts": "Visual constants only the phone collections screens use (category and status specs, swatches, cover gradient).",
|
||||
"src/mobile/screens/collections/savedListFilterCount.ts": "Counts the active filters shown on the phone saved-list toolbar and filter sheet.",
|
||||
"src/mobile/screens/dashboard/MUserMenu.tsx": "Phone avatar menu with a three state theme cycle the desktop navbar does not have.",
|
||||
"src/mobile/screens/journey/MDawarichDaySheet.tsx": "Markup only; the phone frame the Dawarich day sheets (route and stays) render their shared review in.",
|
||||
"src/mobile/screens/journey/MJourneyCreateSheet.tsx": "The phone form receives the journey and trip selection state from MJourney, which shares useJourney with the desktop list.",
|
||||
@@ -1311,6 +1312,7 @@
|
||||
"src/mobile/screens/trip/sheets/PlSheetChrome.tsx": "Phone form sheet chrome primitives (header, footer, field classes).",
|
||||
"src/mobile/screens/trip/sheets/PlTags.tsx": "Markup only; the tag picker's state comes through props from MPlaceEditSheet, which runs usePlaceTags, and the chips of the place sheet draw the tags the place carries.",
|
||||
"src/mobile/screens/trip/sheets/PlTimeFields.tsx": "Phone time fields that already share timeCollisions with the desktop PlaceFormModal.",
|
||||
"src/mobile/screens/trip/sheets/formOptionClass.ts": "Phone-only styling for the shared sheet option buttons.",
|
||||
"src/mobile/screens/trip/sheets/tourSheetOpen.ts": "Phone only context for MTourDetailShell: whether the tour sheet is open and the name it carries.",
|
||||
"src/mobile/screens/trip/tabs/MCollabTab.tsx": "Phone collab sub-tab router for the chat and boards.",
|
||||
"src/mobile/screens/trip/tabs/MFilesBoard.tsx": "Markup only; the trip's files as tiles and the picked file's preview on a wide window, with the files and their actions handed in through props from MFilesTab.",
|
||||
@@ -1322,6 +1324,7 @@
|
||||
"src/mobile/screens/trip/tabs/MTripTabPanel.tsx": "Phone tab router that mounts the per tab screens and plugin frames, with no logic of its own.",
|
||||
"src/mobile/screens/trip/tabs/collabPanes.ts": "Phone only; decides whether the collab tab shows the chat beside a board on a wide window, a layout question of the touch shell that the desktop planner does not have.",
|
||||
"src/mobile/screens/trip/tabs/listsModel.ts": "Priority colour and label constants only the phone to-do list and task sheet use.",
|
||||
"src/mobile/screens/trip/tabs/reservationHeaderTint.ts": "Renders the header tint used by the phone booking and transport cards.",
|
||||
"src/mobile/screens/trip/tabs/tabChrome.tsx": "Phone tab chrome primitives (scroller, section headers, fields, traveler chips, plugin slots).",
|
||||
"src/mobile/screens/trip/tabs/tabModel.ts": "Phone tab prop type and status colour tokens only the phone tabs use.",
|
||||
"src/mobile/screens/trip/tabs/transportsModel.ts": "Phone transport card readers (metadata, day and time cells) for MTransportsTab and MBookingsTab.",
|
||||
|
||||
@@ -2443,7 +2443,7 @@ describe('CostsPanel: a bill entered in the display currency (#2525)', () => {
|
||||
|
||||
const card = (await screen.findByRole('region', { name: 'Final budget' })) as HTMLElement
|
||||
await user.click(await within(card).findByRole('button', { name: /You/ }))
|
||||
expect(within(card).getAllByText('+$791.55')).toHaveLength(2)
|
||||
await waitFor(() => expect(within(card).getAllByText('+$791.55')).toHaveLength(2))
|
||||
expect(within(card).getByText('Aparthotel Silver')).toBeInTheDocument()
|
||||
expect(within(card).getByText('$801.76')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -87,17 +87,27 @@ function failureOf(err: unknown, t: TranslationFn): { error: string | null; offl
|
||||
}
|
||||
|
||||
/** The filters of "All places". */
|
||||
function useLibraryFilters(initial?: PlacesLibraryFilters) {
|
||||
const [search, setSearch] = useState(initial?.search ?? '');
|
||||
const [query, setQuery] = useState(initial?.search.trim() ?? '');
|
||||
const [kind, setKind] = useState<LibraryKindFilter>(initial?.kind ?? 'all');
|
||||
const [categoryId, setCategoryId] = useState<number | 'all'>(initial?.categoryId ?? 'all');
|
||||
const [sort, setSort] = useState<PlacesLibrarySort>(initial?.sort ?? 'name');
|
||||
const [status, setStatus] = useState<CollectionStatus | 'all'>(initial?.status ?? 'all');
|
||||
const DEFAULT_LIBRARY_FILTERS: PlacesLibraryFilters = {
|
||||
search: '',
|
||||
kind: 'all',
|
||||
categoryId: 'all',
|
||||
sort: 'name',
|
||||
status: 'all',
|
||||
minRating: 'all',
|
||||
tagNames: [],
|
||||
};
|
||||
|
||||
function useLibraryFilters(initial = DEFAULT_LIBRARY_FILTERS) {
|
||||
const [search, setSearch] = useState(initial.search);
|
||||
const [query, setQuery] = useState(initial.search.trim());
|
||||
const [kind, setKind] = useState(initial.kind);
|
||||
const [categoryId, setCategoryId] = useState(initial.categoryId);
|
||||
const [sort, setSort] = useState(initial.sort);
|
||||
const [status, setStatus] = useState(initial.status);
|
||||
// At least this many stars on the average of the votes, as the lists filter; unrated places drop out.
|
||||
const [minRating, setMinRating] = useState<number | 'all'>(initial?.minRating ?? 'all');
|
||||
const [minRating, setMinRating] = useState(initial.minRating);
|
||||
// PLC-21: tag names of the lists and trips, any of which an entry must carry, whatever their case.
|
||||
const [tagNames, setTagNames] = useState<string[]>(initial?.tagNames ?? []);
|
||||
const [tagNames, setTagNames] = useState(initial.tagNames);
|
||||
const toggleTagName = useCallback(
|
||||
(name: string) =>
|
||||
setTagNames((names) => {
|
||||
|
||||
@@ -35,6 +35,27 @@ interface Props {
|
||||
mobile?: boolean;
|
||||
}
|
||||
|
||||
const COMMENT_APPEARANCE = {
|
||||
phone: {
|
||||
toggle:
|
||||
'flex min-h-11 w-full items-center gap-2 rounded-xl bg-m-sheetop px-3 text-start text-control font-medium text-m-ink',
|
||||
controls: 'flex flex-none items-center gap-0.5',
|
||||
controlSize: 'size-11',
|
||||
field: 'min-h-11 border-m-rowbr bg-m-sheetop text-m-ink placeholder:text-m-muted',
|
||||
submit: 'size-11 bg-m-act text-m-actfg',
|
||||
hint: 'font-normal text-m-muted',
|
||||
},
|
||||
desktop: {
|
||||
toggle:
|
||||
'inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content',
|
||||
controls: 'flex flex-none items-center gap-0.5 opacity-40 transition-opacity group-hover:opacity-100',
|
||||
controlSize: 'size-7',
|
||||
field: 'min-h-[38px] border-edge bg-surface text-content placeholder:text-content-faint focus:border-content-faint',
|
||||
submit: 'size-[38px] bg-accent text-accent-text hover:bg-accent-hover',
|
||||
hint: 'text-content-faint',
|
||||
},
|
||||
};
|
||||
|
||||
const GUEST_NAME_KEY = 'trek.journey.guestName';
|
||||
|
||||
function rememberedName(): string {
|
||||
@@ -80,11 +101,15 @@ export default function JourneyEntryComments({
|
||||
const [message, setMessage] = useState<string | null>(null);
|
||||
|
||||
if (!canWrite && comments.length === 0) return null;
|
||||
const appearance = COMMENT_APPEARANCE[mobile ? 'phone' : 'desktop'];
|
||||
const open = expanded ?? Boolean(defaultOpen || (mobile && comments.length));
|
||||
|
||||
const needsGuestName = guest && !name.trim();
|
||||
const cannotSubmit = busy || !body.trim() || needsGuestName;
|
||||
|
||||
const submit = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (busy || !body.trim() || (guest && !name.trim())) return;
|
||||
if (cannotSubmit) return;
|
||||
// Only a bot fills the field people never see: it is told all went well.
|
||||
if (trap) {
|
||||
setBody('');
|
||||
@@ -105,7 +130,10 @@ export default function JourneyEntryComments({
|
||||
const dateOf = (iso: string | null | undefined) =>
|
||||
iso ? new Date(iso).toLocaleDateString(locale || undefined, { day: 'numeric', month: 'short' }) : '';
|
||||
|
||||
const toggle = (
|
||||
const renderPublicHint = () =>
|
||||
publicHint && !guest && <p className={`text-caption ${appearance.hint}`}>{t('journey.comments.publicHint')}</p>;
|
||||
|
||||
const renderCollapsed = () => (
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
@@ -113,22 +141,18 @@ export default function JourneyEntryComments({
|
||||
e.stopPropagation();
|
||||
setExpanded(!open);
|
||||
}}
|
||||
className={
|
||||
mobile
|
||||
? 'flex min-h-11 w-full items-center gap-2 rounded-xl bg-m-sheetop px-3 text-start text-control font-medium text-m-ink'
|
||||
: 'inline-flex items-center gap-1.5 self-start text-caption font-medium text-content-faint transition-colors hover:text-content'
|
||||
}
|
||||
className={appearance.toggle}
|
||||
>
|
||||
<MessageCircle size={13} />
|
||||
{comments.length > 0 ? t('journey.comments.count', { count: comments.length }) : t('journey.comments.write')}
|
||||
</button>
|
||||
);
|
||||
if (!open) return toggle;
|
||||
if (!open) return renderCollapsed();
|
||||
|
||||
return (
|
||||
// The thread sits inside clickable cards: a click in it must not open the entry.
|
||||
<div className="flex flex-col gap-3" onClick={(e) => e.stopPropagation()} role="presentation">
|
||||
{!defaultOpen && !mobile && toggle}
|
||||
{!defaultOpen && !mobile && renderCollapsed()}
|
||||
{comments.length > 0 && (
|
||||
<ul className="flex flex-col gap-2.5">
|
||||
{comments.map((c) => {
|
||||
@@ -156,13 +180,7 @@ export default function JourneyEntryComments({
|
||||
<p className="mt-0.5 whitespace-pre-wrap break-words text-body text-content-muted">{c.body}</p>
|
||||
</div>
|
||||
{(mayHide || mayDelete) && (
|
||||
<div
|
||||
className={
|
||||
mobile
|
||||
? 'flex flex-none items-center gap-0.5'
|
||||
: 'flex flex-none items-center gap-0.5 opacity-40 transition-opacity group-hover:opacity-100'
|
||||
}
|
||||
>
|
||||
<div className={appearance.controls}>
|
||||
{mayHide && (
|
||||
<Tooltip
|
||||
label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
||||
@@ -172,7 +190,7 @@ export default function JourneyEntryComments({
|
||||
type="button"
|
||||
aria-label={c.hidden ? t('journey.comments.show') : t('journey.comments.hide')}
|
||||
onClick={() => void onHide?.(c.id, !c.hidden)}
|
||||
className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content`}
|
||||
className={`flex ${appearance.controlSize} items-center justify-center rounded-full text-content-faint hover:bg-surface-secondary hover:text-content`}
|
||||
>
|
||||
{c.hidden ? <Eye size={13} /> : <EyeOff size={13} />}
|
||||
</button>
|
||||
@@ -184,7 +202,7 @@ export default function JourneyEntryComments({
|
||||
type="button"
|
||||
aria-label={t('common.delete')}
|
||||
onClick={() => void onDelete?.(c.id)}
|
||||
className={`flex ${mobile ? 'size-11' : 'size-7'} items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger`}
|
||||
className={`flex ${appearance.controlSize} items-center justify-center rounded-full text-content-faint hover:bg-danger-soft hover:text-danger`}
|
||||
>
|
||||
<Trash2 size={13} />
|
||||
</button>
|
||||
@@ -230,20 +248,16 @@ export default function JourneyEntryComments({
|
||||
placeholder={t('journey.comments.write')}
|
||||
aria-label={t('journey.comments.write')}
|
||||
className={`max-h-40 min-w-0 flex-1 resize-none rounded-xl border px-3 py-2 text-body outline-none [field-sizing:content] ${
|
||||
mobile
|
||||
? 'min-h-11 border-m-rowbr bg-m-sheetop text-m-ink placeholder:text-m-muted'
|
||||
: 'min-h-[38px] border-edge bg-surface text-content placeholder:text-content-faint focus:border-content-faint'
|
||||
appearance.field
|
||||
}`}
|
||||
/>
|
||||
<Tooltip label={t('journey.comments.send')} placement="top">
|
||||
<button
|
||||
type="submit"
|
||||
aria-label={t('journey.comments.send')}
|
||||
disabled={busy || !body.trim() || (guest && !name.trim())}
|
||||
disabled={cannotSubmit}
|
||||
className={`flex flex-none items-center justify-center rounded-full transition-opacity disabled:opacity-40 ${
|
||||
mobile
|
||||
? 'size-11 bg-m-act text-m-actfg'
|
||||
: 'size-[38px] bg-accent text-accent-text hover:bg-accent-hover'
|
||||
appearance.submit
|
||||
}`}
|
||||
>
|
||||
<SendHorizontal size={15} />
|
||||
@@ -251,11 +265,7 @@ export default function JourneyEntryComments({
|
||||
</Tooltip>
|
||||
</div>
|
||||
{message && <p className="text-caption text-danger">{message}</p>}
|
||||
{publicHint && !guest && (
|
||||
<p className={`text-caption ${mobile ? 'font-normal text-m-muted' : 'text-content-faint'}`}>
|
||||
{t('journey.comments.publicHint')}
|
||||
</p>
|
||||
)}
|
||||
{renderPublicHint()}
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState, useEffect, useId, type ReactNode } from 'react'
|
||||
import { useId, type ReactNode } from 'react'
|
||||
import { useIcsSubscription } from './useIcsSubscription'
|
||||
import { RefreshCw, Calendar, Power } from 'lucide-react'
|
||||
import { SubscribeLinks } from './SubscribeLinks'
|
||||
import ToggleSwitch from '../Settings/ToggleSwitch'
|
||||
@@ -13,24 +14,6 @@ export interface IcsSubscribeModalProps {
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
// A server that has no APP_URL configured hands back a host-relative path; the
|
||||
// webcal:// handoff and Google deep link need an absolute URL, so resolve it
|
||||
// against the current origin as a fallback.
|
||||
function absolutize(url: string): string {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
if (url.startsWith('/')) return window.location.origin + url
|
||||
return url
|
||||
}
|
||||
|
||||
// The feeds take days=0 to leave out the all-day summary every day with
|
||||
// untimed places or notes gets (#2602). The choice lives in the link itself,
|
||||
// so a calendar keeps what it subscribed to and the token stays one per trip.
|
||||
function withDayEvents(url: string, dayEvents: boolean): string {
|
||||
if (!url || dayEvents) return url
|
||||
return `${url}${url.includes('?') ? '&' : '?'}days=0`
|
||||
}
|
||||
|
||||
/** The switch for those summaries, above the links it changes, on both shells. */
|
||||
export function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () => void }) {
|
||||
const { t } = useTranslation()
|
||||
@@ -48,46 +31,6 @@ export function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () =>
|
||||
)
|
||||
}
|
||||
|
||||
/** Opening reads the token. Creating or changing it always takes an explicit action. */
|
||||
export function useIcsSubscription(endpoint: string) {
|
||||
const tokenUrl = `${endpoint}/token`
|
||||
const [feedUrl, setFeedUrl] = useState<string | null>(null)
|
||||
const [loadedTokenUrl, setLoadedTokenUrl] = useState<string | null>(null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [dayEvents, setDayEvents] = useState(true)
|
||||
const toggleDayEvents = () => setDayEvents(on => !on)
|
||||
|
||||
const httpsUrl = feedUrl ? withDayEvents(absolutize(feedUrl), dayEvents) : ''
|
||||
const webcalUrl = httpsUrl ? httpsUrl.replace(/^https?:\/\//, 'webcal://') : ''
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
void fetch(tokenUrl, { credentials: 'include' })
|
||||
.then(async res => res.ok ? (await res.json() as { feed_url: string | null }).feed_url : null)
|
||||
.catch(() => null)
|
||||
.then(url => {
|
||||
if (!active) return
|
||||
setFeedUrl(url)
|
||||
setLoadedTokenUrl(tokenUrl)
|
||||
})
|
||||
return () => { active = false }
|
||||
}, [tokenUrl])
|
||||
|
||||
const mutate = async (method: 'POST' | 'PUT' | 'DELETE') => {
|
||||
setBusy(true)
|
||||
try {
|
||||
const res = await fetch(tokenUrl, { method, credentials: 'include' })
|
||||
if (res.ok) {
|
||||
const data = await res.json() as { feed_url: string | null }
|
||||
setFeedUrl(data.feed_url)
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
setBusy(false)
|
||||
}
|
||||
|
||||
return { loading: loadedTokenUrl !== tokenUrl, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, toggleDayEvents }
|
||||
}
|
||||
|
||||
export function IcsSubscribeModal({ endpoint, title, description, onClose }: IcsSubscribeModalProps) {
|
||||
const titleId = useId()
|
||||
const { loading, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, toggleDayEvents } = useIcsSubscription(endpoint)
|
||||
|
||||
@@ -89,51 +89,59 @@ export default function PlaceImagePicker({
|
||||
/>
|
||||
);
|
||||
const showUploadRow = mobile && !own?.pendingPreview;
|
||||
const showTiles = Boolean(current || attached.length || photos.length || (upload && !showUploadRow));
|
||||
|
||||
const renderGallery = () => {
|
||||
const showTiles = Boolean(current || attached.length || photos.length || (upload && !showUploadRow));
|
||||
return (
|
||||
<>
|
||||
{showTiles && (
|
||||
<div className={`grid grid-cols-3 gap-1.5 ${showUploadRow && upload ? 'mt-2' : ''}`}>
|
||||
{!showUploadRow && upload}
|
||||
{current && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => (chosen.kind === 'current' ? own?.onRemove() : onPickUrl(current))}
|
||||
aria-pressed={chosen.kind === 'current'}
|
||||
aria-label={t('places.image.current')}
|
||||
onMouseEnter={() => setHovered({ kind: 'own', label: t('places.image.current') })}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
className={`${TILE} ${ring(chosen.kind === 'current', dialog)}`}
|
||||
>
|
||||
<img src={current} alt="" className="h-full w-full object-cover" />
|
||||
{chosen.kind === 'current' && <Picked />}
|
||||
</button>
|
||||
)}
|
||||
{attached.map((file) => (
|
||||
<AttachedTile
|
||||
key={file.id}
|
||||
file={file}
|
||||
selected={chosen.kind === 'attached' && chosen.fileId === file.id}
|
||||
onPick={() => own?.onPickAttached(file)}
|
||||
onHover={(on) => setHovered(on ? { kind: 'own', label: file.original_name } : null)}
|
||||
dialog={dialog}
|
||||
/>
|
||||
))}
|
||||
{photos.map((photo) => (
|
||||
<PhotoTile
|
||||
key={photo.key}
|
||||
photo={photo}
|
||||
selected={chosen.kind === 'url' && chosen.url === photo.url}
|
||||
onPick={onPickUrl}
|
||||
onHover={(on) => setHovered(on ? { kind: 'photo', photo } : null)}
|
||||
dialog={dialog}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{showUploadRow && upload}
|
||||
{showTiles && (
|
||||
<div className={`grid grid-cols-3 gap-1.5 ${showUploadRow && upload ? 'mt-2' : ''}`}>
|
||||
{!showUploadRow && upload}
|
||||
{current && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => (chosen.kind === 'current' ? own?.onRemove() : onPickUrl(current))}
|
||||
aria-pressed={chosen.kind === 'current'}
|
||||
aria-label={t('places.image.current')}
|
||||
onMouseEnter={() => setHovered({ kind: 'own', label: t('places.image.current') })}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
className={`${TILE} ${ring(chosen.kind === 'current', dialog)}`}
|
||||
>
|
||||
<img src={current} alt="" className="h-full w-full object-cover" />
|
||||
{chosen.kind === 'current' && <Picked />}
|
||||
</button>
|
||||
)}
|
||||
{attached.map((file) => (
|
||||
<AttachedTile
|
||||
key={file.id}
|
||||
file={file}
|
||||
selected={chosen.kind === 'attached' && chosen.fileId === file.id}
|
||||
onPick={() => own?.onPickAttached(file)}
|
||||
onHover={(on) => setHovered(on ? { kind: 'own', label: file.original_name } : null)}
|
||||
dialog={dialog}
|
||||
/>
|
||||
))}
|
||||
{photos.map((photo) => (
|
||||
<PhotoTile
|
||||
key={photo.key}
|
||||
photo={photo}
|
||||
selected={chosen.kind === 'url' && chosen.url === photo.url}
|
||||
onPick={onPickUrl}
|
||||
onHover={(on) => setHovered(on ? { kind: 'photo', photo } : null)}
|
||||
dialog={dialog}
|
||||
t={t}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{renderGallery()}
|
||||
{(shown || removable) && (
|
||||
<CreditLine shown={shown} onRemove={removable ? own?.onRemove : undefined} dialog={dialog} t={t} />
|
||||
)}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useSubscribeLinks } from './useSubscribeLinks'
|
||||
import { Copy, Check, CalendarPlus, Calendar } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
|
||||
@@ -7,45 +7,6 @@ interface SubscribeLinksProps {
|
||||
webcalUrl: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The provider links and clipboard behavior shared by both subscription dialogs.
|
||||
*/
|
||||
export function useSubscribeLinks(httpsUrl: string, webcalUrl: string) {
|
||||
const { t } = useTranslation()
|
||||
const [copied, setCopied] = useState<'https' | 'webcal' | null>(null)
|
||||
|
||||
// Google Calendar's add-by-URL deep link. The cid must carry the webcal://
|
||||
// scheme (not https), URL-encoded, and the feed must be served over HTTPS.
|
||||
const googleUrl = `https://www.google.com/calendar/render?cid=${encodeURIComponent(webcalUrl)}`
|
||||
|
||||
const copy = async (url: string, which: 'https' | 'webcal') => {
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(url)
|
||||
} else {
|
||||
// Fallback for non-secure contexts (plain HTTP) where navigator.clipboard is unavailable
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = url
|
||||
ta.style.position = 'fixed'
|
||||
ta.style.left = '-9999px'
|
||||
document.body.appendChild(ta)
|
||||
ta.focus()
|
||||
ta.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(ta)
|
||||
}
|
||||
setCopied(which)
|
||||
setTimeout(() => setCopied(null), 2000)
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
const manualLinks = [
|
||||
{ label: 'Google Calendar', hint: t('dashboard.ics.pasteFromUrl'), url: httpsUrl, copied: copied === 'https', onCopy: () => void copy(httpsUrl, 'https') },
|
||||
{ label: 'Apple Calendar / Outlook', hint: 'webcal://', url: webcalUrl, copied: copied === 'webcal', onCopy: () => void copy(webcalUrl, 'webcal') },
|
||||
]
|
||||
return { googleUrl, manualLinks }
|
||||
}
|
||||
|
||||
export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
||||
const { t } = useTranslation()
|
||||
const { googleUrl, manualLinks } = useSubscribeLinks(httpsUrl, webcalUrl)
|
||||
|
||||
@@ -483,6 +483,36 @@ function ItineraryCard({ it, tzFrom, tzTo, is12h, expanded, onToggle, onAdd, add
|
||||
// the TransportModal (and could embed anywhere else). The host owns the modal
|
||||
// chrome and closes itself once onAdd resolves.
|
||||
|
||||
function TransitStopFields({ mobile, isMobile, from, to, setFrom, setTo, quickPicks, near }: {
|
||||
mobile: boolean
|
||||
isMobile: boolean
|
||||
from: PickedPlace | null
|
||||
to: PickedPlace | null
|
||||
setFrom: (place: PickedPlace | null) => void
|
||||
setTo: (place: PickedPlace | null) => void
|
||||
quickPicks: PickedPlace[]
|
||||
near: string | null
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<div className={mobile ? 'flex flex-col gap-2.5 rounded-[14px] bg-m-ic p-3' : `flex gap-2 ${isMobile ? 'flex-col' : 'items-end'}`}>
|
||||
<StopPicker mobile={mobile} label={t('transit.from')} value={from} onPick={setFrom} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||
{!mobile && !isMobile && (
|
||||
<button type="button"
|
||||
onClick={() => { const f = from; setFrom(to); setTo(f) }}
|
||||
aria-label={t('transit.swap')}
|
||||
title={t('transit.swap')}
|
||||
className="bg-surface-secondary text-content-muted"
|
||||
style={{ border: 'none', borderRadius: 10, width: 38, height: 38, display: 'grid', placeItems: 'center', cursor: 'pointer', flexShrink: 0 }}
|
||||
>
|
||||
<ArrowLeftRight size={15} />
|
||||
</button>
|
||||
)}
|
||||
<StopPicker mobile={mobile} label={t('transit.to')} value={to} onPick={setTo} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface TransitSearchPanelProps {
|
||||
day: Day
|
||||
days: Day[]
|
||||
@@ -688,22 +718,8 @@ export default function TransitSearchPanel({ day, days, places, accommodations =
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, fontFamily: 'var(--font-system)' }}>
|
||||
<WalkTransitNote walk={walkHere} />
|
||||
{/* from / to — stacked tight on mobile, swap button on desktop only */}
|
||||
<div className={mobile ? 'flex flex-col gap-2.5 rounded-[14px] bg-m-ic p-3' : `flex gap-2 ${isMobile ? 'flex-col' : 'items-end'}`}>
|
||||
<StopPicker mobile={mobile} label={t('transit.from')} value={from} onPick={setFrom} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||
{!mobile && !isMobile && (
|
||||
<button type="button"
|
||||
onClick={() => { const f = from; setFrom(to); setTo(f) }}
|
||||
aria-label={t('transit.swap')}
|
||||
title={t('transit.swap')}
|
||||
className="bg-surface-secondary text-content-muted"
|
||||
style={{ border: 'none', borderRadius: 10, width: 38, height: 38, display: 'grid', placeItems: 'center', cursor: 'pointer', flexShrink: 0 }}
|
||||
>
|
||||
<ArrowLeftRight size={15} />
|
||||
</button>
|
||||
)}
|
||||
<StopPicker mobile={mobile} label={t('transit.to')} value={to} onPick={setTo} quickPicks={quickPicks} near={near} placeholder={t('transit.searchStop')} />
|
||||
</div>
|
||||
<TransitStopFields mobile={mobile} isMobile={isMobile} from={from} to={to}
|
||||
setFrom={setFrom} setTo={setTo} quickPicks={quickPicks} near={near} />
|
||||
|
||||
{mobile ? (
|
||||
<>
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
// A server that has no APP_URL configured hands back a host-relative path; the
|
||||
// webcal:// handoff and Google deep link need an absolute URL, so resolve it
|
||||
// against the current origin as a fallback.
|
||||
function absolutize(url: string): string {
|
||||
if (!url) return '';
|
||||
if (/^https?:\/\//i.test(url)) return url;
|
||||
if (url.startsWith('/')) return window.location.origin + url;
|
||||
return url;
|
||||
}
|
||||
|
||||
// The feeds take days=0 to leave out the all-day summary every day with
|
||||
// untimed places or notes gets (#2602). The choice lives in the link itself,
|
||||
// so a calendar keeps what it subscribed to and the token stays one per trip.
|
||||
function withDayEvents(url: string, dayEvents: boolean): string {
|
||||
if (!url || dayEvents) return url;
|
||||
return `${url}${url.includes('?') ? '&' : '?'}days=0`;
|
||||
}
|
||||
|
||||
/** Opening reads the token. Creating or changing it always takes an explicit action. */
|
||||
export function useIcsSubscription(endpoint: string) {
|
||||
const tokenUrl = `${endpoint}/token`;
|
||||
const [feedUrl, setFeedUrl] = useState<string | null>(null);
|
||||
const [loadedTokenUrl, setLoadedTokenUrl] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [dayEvents, setDayEvents] = useState(true);
|
||||
const toggleDayEvents = () => setDayEvents((on) => !on);
|
||||
|
||||
const httpsUrl = feedUrl ? withDayEvents(absolutize(feedUrl), dayEvents) : '';
|
||||
const webcalUrl = httpsUrl ? httpsUrl.replace(/^https?:\/\//, 'webcal://') : '';
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
void fetch(tokenUrl, { credentials: 'include' })
|
||||
.then(async (res) => (res.ok ? ((await res.json()) as { feed_url: string | null }).feed_url : null))
|
||||
.catch(() => null)
|
||||
.then((url) => {
|
||||
if (!active) return;
|
||||
setFeedUrl(url);
|
||||
setLoadedTokenUrl(tokenUrl);
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [tokenUrl]);
|
||||
|
||||
const mutate = async (method: 'POST' | 'PUT' | 'DELETE') => {
|
||||
setBusy(true);
|
||||
try {
|
||||
const res = await fetch(tokenUrl, { method, credentials: 'include' });
|
||||
if (res.ok) {
|
||||
const data = (await res.json()) as { feed_url: string | null };
|
||||
setFeedUrl(data.feed_url);
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
setBusy(false);
|
||||
};
|
||||
|
||||
return {
|
||||
loading: loadedTokenUrl !== tokenUrl,
|
||||
busy,
|
||||
feedUrl,
|
||||
httpsUrl,
|
||||
webcalUrl,
|
||||
mutate,
|
||||
dayEvents,
|
||||
toggleDayEvents,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
|
||||
/**
|
||||
* The provider links and clipboard behavior shared by both subscription dialogs.
|
||||
*/
|
||||
export function useSubscribeLinks(httpsUrl: string, webcalUrl: string) {
|
||||
const { t } = useTranslation();
|
||||
const [copied, setCopied] = useState<'https' | 'webcal' | null>(null);
|
||||
|
||||
// Google Calendar's add-by-URL deep link. The cid must carry the webcal://
|
||||
// scheme (not https), URL-encoded, and the feed must be served over HTTPS.
|
||||
const googleUrl = `https://www.google.com/calendar/render?cid=${encodeURIComponent(webcalUrl)}`;
|
||||
|
||||
const copy = async (url: string, which: 'https' | 'webcal') => {
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(url);
|
||||
} else {
|
||||
// Fallback for non-secure contexts (plain HTTP) where navigator.clipboard is unavailable
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = url;
|
||||
ta.style.position = 'fixed';
|
||||
ta.style.left = '-9999px';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
setCopied(which);
|
||||
setTimeout(() => setCopied(null), 2000);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
};
|
||||
|
||||
const manualLinks = [
|
||||
{
|
||||
label: 'Google Calendar',
|
||||
hint: t('dashboard.ics.pasteFromUrl'),
|
||||
url: httpsUrl,
|
||||
copied: copied === 'https',
|
||||
onCopy: () => void copy(httpsUrl, 'https'),
|
||||
},
|
||||
{
|
||||
label: 'Apple Calendar / Outlook',
|
||||
hint: 'webcal://',
|
||||
url: webcalUrl,
|
||||
copied: copied === 'webcal',
|
||||
onCopy: () => void copy(webcalUrl, 'webcal'),
|
||||
},
|
||||
];
|
||||
return { googleUrl, manualLinks };
|
||||
}
|
||||
@@ -167,9 +167,23 @@ export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments
|
||||
}
|
||||
}, [enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viasByDay, tourStageStops, includeLocatedBookings])
|
||||
|
||||
const transportSignature = useTransportSignature(reservationsForSignature, selectedDayId, includeLocatedBookings)
|
||||
|
||||
// Recalculate when assignments or transport positions for the SELECTED day change
|
||||
const selectedDayAssignments = selectedDayId ? tripStore.assignments?.[String(selectedDayId)] : null
|
||||
useEffect(() => {
|
||||
if (!selectedDayId) { setRoute(null); setRouteWalking([]); setRouteSegments([]); setRouteVias([]); return }
|
||||
updateRouteForDay(selectedDayId)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedDayId, selectedDayAssignments, transportSignature, enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viaKey, tourStageStops, includeLocatedBookings])
|
||||
|
||||
return { route, routeWalking, routeSegments, routeVias, routeInfo, setRoute, setRouteInfo, updateRouteForDay }
|
||||
}
|
||||
|
||||
function useTransportSignature(reservationsForSignature: TripStoreState['reservations'], selectedDayId: number | null, includeLocatedBookings?: boolean) {
|
||||
// Stable signature for transport reservations on the selected day — changes when a transport
|
||||
// is added, removed, or repositioned, ensuring route recalc fires even on transport-only reorders.
|
||||
const transportSignature = useMemo(() => {
|
||||
return useMemo(() => {
|
||||
if (!selectedDayId) return ''
|
||||
return reservationsForSignature
|
||||
.filter(r => TRANSPORT_TYPES.includes(r.type) || (includeLocatedBookings && r.place_id != null))
|
||||
@@ -182,14 +196,4 @@ export function useRouteCalculation(tripStore: Pick<TripStoreState, 'assignments
|
||||
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
||||
.join('|')
|
||||
}, [reservationsForSignature, selectedDayId, includeLocatedBookings])
|
||||
|
||||
// Recalculate when assignments or transport positions for the SELECTED day change
|
||||
const selectedDayAssignments = selectedDayId ? tripStore.assignments?.[String(selectedDayId)] : null
|
||||
useEffect(() => {
|
||||
if (!selectedDayId) { setRoute(null); setRouteWalking([]); setRouteSegments([]); setRouteVias([]); return }
|
||||
updateRouteForDay(selectedDayId)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedDayId, selectedDayAssignments, transportSignature, enabled, profile, accommodations, optimizeFromAccommodation, distanceUnit, selectedDayDefaultMode, mirrorServiceStops, toursEnabled, places, viaKey, tourStageStops, includeLocatedBookings])
|
||||
|
||||
return { route, routeWalking, routeSegments, routeVias, routeInfo, setRoute, setRouteInfo, updateRouteForDay }
|
||||
}
|
||||
|
||||
@@ -256,23 +256,9 @@ export default function NativeImportSheet(): React.ReactElement | null {
|
||||
const sourceName = link?.title ?? file?.name;
|
||||
const close = () => setFile(null);
|
||||
const back = picked && choices.length > 1 && savingTrip == null ? () => setPick(null) : undefined;
|
||||
const loading = tripsStatus === 'loading' || (!asking && !showTrips && !nowhere);
|
||||
return (
|
||||
<MSheet open={open} onClose={back ?? close} variant="bottom" ariaLabel={title} form>
|
||||
<FormSheetHeader
|
||||
icon={link ? Link2 : FileText}
|
||||
leading={
|
||||
back && (
|
||||
<MIconBtn variant="neutral" size={40} ariaLabel={t('common.back')} onClick={back}>
|
||||
<ChevronLeft size={19} className="rtl:rotate-180" aria-hidden />
|
||||
</MIconBtn>
|
||||
)
|
||||
}
|
||||
title={title}
|
||||
subtitle={sourceName && <bdi>{sourceName}</bdi>}
|
||||
onClose={close}
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
const renderImportStep = () => {
|
||||
const loading = tripsStatus === 'loading' || (!asking && !showTrips && !nowhere);
|
||||
return (
|
||||
<FormSheetBody className="space-y-3">
|
||||
{tripsStatus === 'error' ? (
|
||||
<div className="space-y-3 rounded-[14px] bg-m-ic p-3">
|
||||
@@ -303,6 +289,30 @@ export default function NativeImportSheet(): React.ReactElement | null {
|
||||
)
|
||||
)}
|
||||
</FormSheetBody>
|
||||
);
|
||||
};
|
||||
|
||||
const renderImportHeader = () => (
|
||||
<FormSheetHeader
|
||||
icon={link ? Link2 : FileText}
|
||||
leading={
|
||||
back && (
|
||||
<MIconBtn variant="neutral" size={40} ariaLabel={t('common.back')} onClick={back}>
|
||||
<ChevronLeft size={19} className="rtl:rotate-180" aria-hidden />
|
||||
</MIconBtn>
|
||||
)
|
||||
}
|
||||
title={title}
|
||||
subtitle={sourceName && <bdi>{sourceName}</bdi>}
|
||||
onClose={close}
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<MSheet open={open} onClose={back ?? close} variant="bottom" ariaLabel={title} form>
|
||||
{renderImportHeader()}
|
||||
{renderImportStep()}
|
||||
</MSheet>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ export function useSheetDrag({ enabled, panelRef, scrimRef, onDismiss }: SheetDr
|
||||
useEffect(() => {
|
||||
const panel = panelRef.current;
|
||||
if (!enabled || !panel) return;
|
||||
return attachContentDrag(panel, drag, frame, follow, release, cancelDrag);
|
||||
return attachContentDrag({ panel, drag, frame, follow, release, cancelDrag });
|
||||
}, [enabled, panelRef, follow, release, cancelDrag]);
|
||||
|
||||
return {
|
||||
@@ -197,14 +197,21 @@ export function useSheetDrag({ enabled, panelRef, scrimRef, onDismiss }: SheetDr
|
||||
* The content's half of the drag: a finger (touch events) or a mouse or pen
|
||||
* (pointer events), claimed on the first move or let go. Returns the detach.
|
||||
*/
|
||||
function attachContentDrag(
|
||||
panel: HTMLElement,
|
||||
drag: MutableRefObject<Drag | null>,
|
||||
frame: MutableRefObject<number>,
|
||||
follow: (dy: number) => void,
|
||||
release: (d: Drag, lastY: number, time: number) => void,
|
||||
cancelDrag: () => void
|
||||
): () => void {
|
||||
function attachContentDrag({
|
||||
panel,
|
||||
drag,
|
||||
frame,
|
||||
follow,
|
||||
release,
|
||||
cancelDrag,
|
||||
}: {
|
||||
panel: HTMLElement;
|
||||
drag: MutableRefObject<Drag | null>;
|
||||
frame: MutableRefObject<number>;
|
||||
follow: (dy: number) => void;
|
||||
release: (d: Drag, lastY: number, time: number) => void;
|
||||
cancelDrag: () => void;
|
||||
}): () => void {
|
||||
/** Set by a claimed drag: the click the browser sends after it is not a tap. */
|
||||
let swallowClick = false;
|
||||
|
||||
|
||||
@@ -61,6 +61,48 @@ export default function MAtlasCountryPopup({ atlas }: MAtlasCountryPopupProps) {
|
||||
const unmarking = a?.type === 'unmark' || unmarkingRegion
|
||||
const confirming = a?.type === 'mark' || unmarking
|
||||
|
||||
const renderActions = (action: NonNullable<typeof a>) => (
|
||||
<FormSheetBody>
|
||||
{(action.type === 'choose' || choosingRegion) && (
|
||||
<div className="divide-y divide-m-rowbr overflow-hidden rounded-[14px] bg-m-ic">
|
||||
<OptionRow
|
||||
icon={MapPin} tint={markTint}
|
||||
title={t('atlas.markVisited')}
|
||||
hint={t(choosingRegion ? 'atlas.markRegionVisitedHint' : 'atlas.markVisitedHint')}
|
||||
onClick={choosingRegion ? () => void markRegion(true) : () => void markCountry()}
|
||||
/>
|
||||
<OptionRow
|
||||
icon={Star} tint={bucketTint}
|
||||
title={t('atlas.addToBucket')} hint={t('atlas.addToBucketHint')}
|
||||
onClick={() => setConfirmAction({ ...action, type: 'bucket' })}
|
||||
/>
|
||||
{!choosingRegion && onWishlist && (
|
||||
<OptionRow
|
||||
icon={Trash2} tint={removeTint}
|
||||
title={t('atlas.removeFromBucket')} hint={t('atlas.removeFromBucketHint')}
|
||||
onClick={() => void removeBucket()}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{confirming && (
|
||||
<FormSheetSection>
|
||||
<p className="text-control text-m-muted">
|
||||
{t(unmarkingRegion ? 'atlas.confirmUnmarkRegion' : unmarking ? 'atlas.confirmUnmark' : 'atlas.confirmMark')}
|
||||
</p>
|
||||
</FormSheetSection>
|
||||
)}
|
||||
{action.type === 'bucket' && (
|
||||
<FormSheetSection>
|
||||
<label className="block space-y-1.5">
|
||||
<span className={FORM_LABEL_CLS}>{t('atlas.bucketWhen')}</span>
|
||||
<input type="month" value={bucketDate} onChange={(e) => setBucketDate(e.target.value)} className={FIELD_CLS} />
|
||||
</label>
|
||||
</FormSheetSection>
|
||||
)}
|
||||
</FormSheetBody>
|
||||
)
|
||||
|
||||
return (
|
||||
<MSheet open={!!a} onClose={close} variant="card" form ariaLabel={a?.name}>
|
||||
{a && (
|
||||
@@ -76,45 +118,7 @@ export default function MAtlasCountryPopup({ atlas }: MAtlasCountryPopupProps) {
|
||||
onClose={close}
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
<FormSheetBody>
|
||||
{(a.type === 'choose' || choosingRegion) && (
|
||||
<div className="divide-y divide-m-rowbr overflow-hidden rounded-[14px] bg-m-ic">
|
||||
<OptionRow
|
||||
icon={MapPin} tint={markTint}
|
||||
title={t('atlas.markVisited')}
|
||||
hint={t(choosingRegion ? 'atlas.markRegionVisitedHint' : 'atlas.markVisitedHint')}
|
||||
onClick={choosingRegion ? () => void markRegion(true) : () => void markCountry()}
|
||||
/>
|
||||
<OptionRow
|
||||
icon={Star} tint={bucketTint}
|
||||
title={t('atlas.addToBucket')} hint={t('atlas.addToBucketHint')}
|
||||
onClick={() => setConfirmAction({ ...a, type: 'bucket' })}
|
||||
/>
|
||||
{!choosingRegion && onWishlist && (
|
||||
<OptionRow
|
||||
icon={Trash2} tint={removeTint}
|
||||
title={t('atlas.removeFromBucket')} hint={t('atlas.removeFromBucketHint')}
|
||||
onClick={() => void removeBucket()}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{confirming && (
|
||||
<FormSheetSection>
|
||||
<p className="text-control text-m-muted">
|
||||
{t(unmarkingRegion ? 'atlas.confirmUnmarkRegion' : unmarking ? 'atlas.confirmUnmark' : 'atlas.confirmMark')}
|
||||
</p>
|
||||
</FormSheetSection>
|
||||
)}
|
||||
{a.type === 'bucket' && (
|
||||
<FormSheetSection>
|
||||
<label className="block space-y-1.5">
|
||||
<span className={FORM_LABEL_CLS}>{t('atlas.bucketWhen')}</span>
|
||||
<input type="month" value={bucketDate} onChange={(e) => setBucketDate(e.target.value)} className={FIELD_CLS} />
|
||||
</label>
|
||||
</FormSheetSection>
|
||||
)}
|
||||
</FormSheetBody>
|
||||
{renderActions(a)}
|
||||
{a.type === 'mark' && (
|
||||
<FormSheetFooter onCancel={close} cancelLabel={t('common.cancel')}
|
||||
onSubmit={() => void executeConfirmAction()} submitLabel={t('atlas.markVisited')} />
|
||||
|
||||
@@ -133,6 +133,25 @@ export default function MLibraryPlaceSheet({
|
||||
const tags = usePlaceTags({ data, onChanged: onNotesSaved, t });
|
||||
const edit = usePlaceEdit({ data, onSaved: onNotesSaved, t });
|
||||
const rating = usePlaceRating({ data, onChanged: onNotesSaved, t });
|
||||
const renderControls = () =>
|
||||
entry &&
|
||||
edit.canEdit &&
|
||||
!edit.editing && (
|
||||
<MIconBtn variant="neutral" size={36} ariaLabel={t('common.edit')} onClick={edit.start}>
|
||||
<Pencil size={16} aria-hidden />
|
||||
</MIconBtn>
|
||||
);
|
||||
const renderEditFooter = () =>
|
||||
entry &&
|
||||
edit.editing && (
|
||||
<FormSheetFooter
|
||||
onCancel={edit.cancel}
|
||||
cancelLabel={t('common.cancel')}
|
||||
onSubmit={() => void edit.save()}
|
||||
submitLabel={t('common.save')}
|
||||
submitDisabled={edit.saving}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<MPlaceSheetShell
|
||||
open={open}
|
||||
@@ -144,27 +163,8 @@ export default function MLibraryPlaceSheet({
|
||||
lng={entry?.lng}
|
||||
onClose={edit.editing ? edit.cancel : onClose}
|
||||
t={t}
|
||||
controls={
|
||||
entry &&
|
||||
edit.canEdit &&
|
||||
!edit.editing && (
|
||||
<MIconBtn variant="neutral" size={36} ariaLabel={t('common.edit')} onClick={edit.start}>
|
||||
<Pencil size={16} aria-hidden />
|
||||
</MIconBtn>
|
||||
)
|
||||
}
|
||||
editFooter={
|
||||
entry &&
|
||||
edit.editing && (
|
||||
<FormSheetFooter
|
||||
onCancel={edit.cancel}
|
||||
cancelLabel={t('common.cancel')}
|
||||
onSubmit={() => void edit.save()}
|
||||
submitLabel={t('common.save')}
|
||||
submitDisabled={edit.saving}
|
||||
/>
|
||||
)
|
||||
}
|
||||
controls={renderControls()}
|
||||
editFooter={renderEditFooter()}
|
||||
footer={
|
||||
entry &&
|
||||
!edit.editing && (
|
||||
|
||||
@@ -106,57 +106,63 @@ export default function MPlaceSheetShell({
|
||||
</bdi>
|
||||
);
|
||||
const closeLabel = t('common.close');
|
||||
const renderPlaceHeader = () => (
|
||||
<>
|
||||
{cover ? (
|
||||
<header className="relative isolate h-[clamp(10rem,49vw,13.5rem)] flex-none overflow-hidden short:h-32">
|
||||
<button
|
||||
type="button"
|
||||
aria-label={coverLabel}
|
||||
aria-haspopup="dialog"
|
||||
onClick={() => setViewingSrc(cover)}
|
||||
className="m-libcover-photo absolute inset-0 size-full border-0 bg-m-ic p-0"
|
||||
>
|
||||
<img src={cover} alt="" className="size-full object-cover" />
|
||||
</button>
|
||||
<div className="m-libcover-scrim pointer-events-none absolute inset-0 z-[1]" />
|
||||
<div className="m-libcover-actions absolute end-3 top-3 z-[2] flex items-center gap-2">
|
||||
{controls}
|
||||
<MIconBtn variant="neutral" size={36} onClick={onClose} ariaLabel={closeLabel}>
|
||||
<X size={16} aria-hidden />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
<div className="m-libcover-name pointer-events-none absolute inset-x-4 bottom-3 z-[2]">
|
||||
{head ? (
|
||||
<div className="pointer-events-auto">{head}</div>
|
||||
) : (
|
||||
placeName && (
|
||||
<>
|
||||
<h2 className="m-0 line-clamp-2 break-words text-title font-bold leading-tight">{placeName}</h2>
|
||||
<PlaceLocationBadge address={address} lat={lat} lng={lng} t={t} />
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
) : (
|
||||
<FormSheetHeader
|
||||
icon={meta.icon}
|
||||
title={head ?? placeName}
|
||||
subtitle={
|
||||
location && (
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
<MapPin size={13} className="flex-none" aria-hidden />
|
||||
<bdi className="truncate">{location}</bdi>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
trailing={controls && <div className="flex flex-none gap-1">{controls}</div>}
|
||||
onClose={onClose}
|
||||
closeLabel={closeLabel}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MSheet open={open} onClose={onClose} ariaLabel={name ?? undefined} covered={viewingCover}>
|
||||
{cover ? (
|
||||
<header className="relative isolate h-[clamp(10rem,49vw,13.5rem)] flex-none overflow-hidden short:h-32">
|
||||
<button
|
||||
type="button"
|
||||
aria-label={coverLabel}
|
||||
aria-haspopup="dialog"
|
||||
onClick={() => setViewingSrc(cover)}
|
||||
className="m-libcover-photo absolute inset-0 size-full border-0 bg-m-ic p-0"
|
||||
>
|
||||
<img src={cover} alt="" className="size-full object-cover" />
|
||||
</button>
|
||||
<div className="m-libcover-scrim pointer-events-none absolute inset-0 z-[1]" />
|
||||
<div className="m-libcover-actions absolute end-3 top-3 z-[2] flex items-center gap-2">
|
||||
{controls}
|
||||
<MIconBtn variant="neutral" size={36} onClick={onClose} ariaLabel={closeLabel}>
|
||||
<X size={16} aria-hidden />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
<div className="m-libcover-name pointer-events-none absolute inset-x-4 bottom-3 z-[2]">
|
||||
{head ? (
|
||||
<div className="pointer-events-auto">{head}</div>
|
||||
) : (
|
||||
placeName && (
|
||||
<>
|
||||
<h2 className="m-0 line-clamp-2 break-words text-title font-bold leading-tight">{placeName}</h2>
|
||||
<PlaceLocationBadge address={address} lat={lat} lng={lng} t={t} />
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
) : (
|
||||
<FormSheetHeader
|
||||
icon={meta.icon}
|
||||
title={head ?? placeName}
|
||||
subtitle={
|
||||
location && (
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
<MapPin size={13} className="flex-none" aria-hidden />
|
||||
<bdi className="truncate">{location}</bdi>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
trailing={controls && <div className="flex flex-none gap-1">{controls}</div>}
|
||||
onClose={onClose}
|
||||
closeLabel={closeLabel}
|
||||
/>
|
||||
)}
|
||||
{renderPlaceHeader()}
|
||||
<FormSheetBody>
|
||||
{category && (
|
||||
<span
|
||||
|
||||
@@ -85,6 +85,36 @@ export default function MJourneyEntryRead({
|
||||
</button>
|
||||
);
|
||||
|
||||
const renderPhotosAndLocation = () => (
|
||||
<>
|
||||
{lead && (
|
||||
<div className="space-y-2">
|
||||
<figure>
|
||||
{photoTile(lead, 0, 'block aspect-video max-h-[34vh] w-full')}
|
||||
{lead.caption && (
|
||||
<figcaption className="mt-1.5 text-caption text-m-muted">
|
||||
<bdi>{lead.caption}</bdi>
|
||||
</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
{photos.length > 1 && (
|
||||
<div className="m-no-scrollbar flex gap-2 overflow-x-auto pb-1">
|
||||
{photos.slice(1).map((photo, index) => photoTile(photo, index + 1, 'size-16 shrink-0'))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{entry.location_name && entry.location_name !== title && (
|
||||
<p
|
||||
className={`flex w-full items-center gap-2 rounded-xl bg-m-ic px-3 py-2 text-control text-m-ink ${lead ? '!mt-2' : ''}`}
|
||||
>
|
||||
<MapPin size={14} className="shrink-0 text-m-muted" aria-hidden />
|
||||
<bdi className="min-w-0 [overflow-wrap:anywhere]">{entry.location_name}</bdi>
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MSheet open onClose={onClose} covered={photoIndex !== null} material="glass" form ariaLabel={title}>
|
||||
@@ -103,31 +133,7 @@ export default function MJourneyEntryRead({
|
||||
}
|
||||
/>
|
||||
<FormSheetBody className="space-y-4">
|
||||
{lead && (
|
||||
<div className="space-y-2">
|
||||
<figure>
|
||||
{photoTile(lead, 0, 'block aspect-video max-h-[34vh] w-full')}
|
||||
{lead.caption && (
|
||||
<figcaption className="mt-1.5 text-caption text-m-muted">
|
||||
<bdi>{lead.caption}</bdi>
|
||||
</figcaption>
|
||||
)}
|
||||
</figure>
|
||||
{photos.length > 1 && (
|
||||
<div className="m-no-scrollbar flex gap-2 overflow-x-auto pb-1">
|
||||
{photos.slice(1).map((photo, index) => photoTile(photo, index + 1, 'size-16 shrink-0'))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{entry.location_name && entry.location_name !== title && (
|
||||
<p
|
||||
className={`flex w-full items-center gap-2 rounded-xl bg-m-ic px-3 py-2 text-control text-m-ink ${lead ? '!mt-2' : ''}`}
|
||||
>
|
||||
<MapPin size={14} className="shrink-0 text-m-muted" aria-hidden />
|
||||
<bdi className="min-w-0 [overflow-wrap:anywhere]">{entry.location_name}</bdi>
|
||||
</p>
|
||||
)}
|
||||
{renderPhotosAndLocation()}
|
||||
{entry.story?.trim() && (
|
||||
<FormSheetSection>
|
||||
<div className="min-w-0 overflow-x-auto rounded-xl border border-m-rowbr bg-m-sheetop p-3 text-body font-normal text-m-ink [--journal-accent:var(--m-ink)] [--journal-border:var(--m-rowbr)] [--journal-muted:var(--m-muted)] [overflow-wrap:anywhere]">
|
||||
|
||||
@@ -53,13 +53,12 @@ interface MJourneySettingsSheetProps {
|
||||
export default function MJourneySettingsSheet({
|
||||
journey, onClose, onSaved, onOpenInvite, inviteOpen, onRefresh, onRestoreSuggestions, recordingPrep,
|
||||
}: MJourneySettingsSheetProps) {
|
||||
const { t, locale } = useTranslation()
|
||||
const { t } = useTranslation()
|
||||
const settings = useJourneySettings({ journey, onSaved, onRefresh, onContentChanged: onRefresh })
|
||||
const {
|
||||
title, setTitle, subtitle, setSubtitle, saving, archiving, unlinkTarget, setUnlinkTarget, showDeleteConfirm,
|
||||
setShowDeleteConfirm, savingTracks, savingField, handleSave, handleCoverUpload, handleArchiveToggle,
|
||||
handleTracksToggle, handleFieldToggle, handleDelete, handleRemoveContributor, confirmUnlink,
|
||||
statusChoice, savingStatus, handleStatusChange, savingPhotoLocation, handlePhotoLocationToggle,
|
||||
} = useJourneySettings({ journey, onSaved, onRefresh, onContentChanged: onRefresh })
|
||||
title, setTitle, setSubtitle, saving, unlinkTarget, setUnlinkTarget, showDeleteConfirm,
|
||||
setShowDeleteConfirm, handleSave, handleDelete, handleRemoveContributor, confirmUnlink,
|
||||
} = settings
|
||||
const [area, setArea] = useState<SettingsArea | null>(null)
|
||||
const [pendingContributor, setPendingContributor] = useState<JourneyDetail['contributors'][number] | null>(null)
|
||||
const formId = useId()
|
||||
@@ -71,8 +70,6 @@ export default function MJourneySettingsSheet({
|
||||
onRefresh()
|
||||
},
|
||||
})
|
||||
const coverRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const coverSrc = journeyCoverSrc(journey.cover_image)
|
||||
|
||||
const openAddTrip = async () => {
|
||||
@@ -107,12 +104,98 @@ export default function MJourneySettingsSheet({
|
||||
setSubtitle(journey.subtitle ?? '')
|
||||
back()
|
||||
}
|
||||
const statusOptions: Array<{ value: JourneyStatusChoice; label: string }> = [
|
||||
{ value: 'auto', label: t('journey.settings.statusAuto') },
|
||||
{ value: 'draft', label: t('journey.status.draft') },
|
||||
{ value: 'live', label: t('journey.frontpage.live') },
|
||||
{ value: 'completed', label: t('journey.status.completed') },
|
||||
]
|
||||
|
||||
const renderArea = () => {
|
||||
switch (area) {
|
||||
case null:
|
||||
return (
|
||||
<nav aria-label={t('journey.settings.title')} className="space-y-4">
|
||||
{groups.map(({ title, ids }) => (
|
||||
<FormSheetSection key={title} title={title}>
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{ids.map(id => {
|
||||
const { label, Icon, count } = areas[id]
|
||||
return (
|
||||
<button key={id} type="button" onClick={() => setArea(id)} className="flex min-h-11 w-full items-center gap-3 py-1.5 text-start first:pt-0 last:pb-0">
|
||||
<span className="grid size-8 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted" aria-hidden><Icon size={16} /></span>
|
||||
<span className="min-w-0 flex-1 break-words text-control font-semibold">{label}</span>
|
||||
{count != null && <span className="text-caption tabular-nums text-m-muted">{count}</span>}
|
||||
<ChevronRight size={16} className="flex-none text-m-muted rtl:rotate-180" aria-hidden />
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
))}
|
||||
</nav>
|
||||
)
|
||||
case 'profile':
|
||||
return <JourneyProfileFields formId={formId} coverSrc={coverSrc} settings={settings} />
|
||||
case 'trips':
|
||||
return <JourneyLinkedTrips trips={journey.trips} onUnlink={setUnlinkTarget} />
|
||||
case 'linkTrip':
|
||||
return (
|
||||
<FormSheetSection>
|
||||
{loadingTrips || unlinkedTrips.length === 0 ? (
|
||||
<p role="status" className="py-2 text-center text-control text-m-muted">
|
||||
{t(loadingTrips ? 'common.loading' : 'journey.trips.noTripsAvailable')}
|
||||
</p>
|
||||
) : (
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{unlinkedTrips.map(trip => (
|
||||
<div key={trip.id} className="flex min-h-12 items-center gap-2.5 py-1.5">
|
||||
<span className={LIST_ICON}><Luggage size={17} aria-hidden /></span>
|
||||
<bdi className="min-w-0 flex-1 break-words text-control font-semibold">{trip.title}</bdi>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => linkTrip(trip.id)}
|
||||
disabled={linkingTripId != null}
|
||||
className={SHEET_SECONDARY}
|
||||
>
|
||||
{t('journey.trips.link')}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</FormSheetSection>
|
||||
)
|
||||
case 'people':
|
||||
return (
|
||||
<>
|
||||
<div className={LIST_PANEL}>
|
||||
{journey.contributors.map(c => (
|
||||
<div key={c.user_id} className="flex min-h-14 items-center gap-3 py-2.5">
|
||||
<JourneyPersonAvatar username={c.username} avatar={c.avatar} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<bdi className="block break-words text-control font-semibold">{c.username}</bdi>
|
||||
<span className="text-caption text-m-muted">{t(c.role === 'owner' ? 'members.owner' : c.role === 'editor' ? 'journey.invite.editor' : 'journey.invite.viewer')}</span>
|
||||
</div>
|
||||
{c.role !== 'owner' && (
|
||||
<MIconBtn variant="neutral" size={36}
|
||||
onClick={() => setPendingContributor(c)}
|
||||
ariaLabel={t('journey.contributors.remove')}
|
||||
>
|
||||
<UserMinus size={15} strokeWidth={2} aria-hidden />
|
||||
</MIconBtn>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<MTripAccessList access={journey.trip_access} />
|
||||
</>
|
||||
)
|
||||
case 'share':
|
||||
return <MShareSection journeyId={journey.id} />
|
||||
case 'entries':
|
||||
return <JourneyEntryFields journey={journey} onRestoreSuggestions={onRestoreSuggestions} settings={settings} />
|
||||
case 'map':
|
||||
return <JourneyMapSettings journey={journey} recordingPrep={recordingPrep} settings={settings} />
|
||||
case 'status':
|
||||
return <JourneyStatusSettings journey={journey} settings={settings} />
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -129,229 +212,7 @@ export default function MJourneySettingsSheet({
|
||||
/>
|
||||
|
||||
<FormSheetBody key={area ?? 'overview'} className="space-y-4">
|
||||
{!area && (
|
||||
<nav aria-label={t('journey.settings.title')} className="space-y-4">
|
||||
{groups.map(({ title, ids }) => (
|
||||
<FormSheetSection key={title} title={title}>
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{ids.map(id => {
|
||||
const { label, Icon, count } = areas[id]
|
||||
return (
|
||||
<button key={id} type="button" onClick={() => setArea(id)} className="flex min-h-11 w-full items-center gap-3 py-1.5 text-start first:pt-0 last:pb-0">
|
||||
<span className="grid size-8 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted" aria-hidden><Icon size={16} /></span>
|
||||
<span className="min-w-0 flex-1 break-words text-control font-semibold">{label}</span>
|
||||
{count != null && <span className="text-caption tabular-nums text-m-muted">{count}</span>}
|
||||
<ChevronRight size={16} className="flex-none text-m-muted rtl:rotate-180" aria-hidden />
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
))}
|
||||
</nav>
|
||||
)}
|
||||
|
||||
{area === 'profile' && (
|
||||
<>
|
||||
<FormSheetSection>
|
||||
<div className="space-y-3">
|
||||
<label htmlFor={`${formId}-name`} className="block space-y-2">
|
||||
<span className={FORM_LABEL_CLS}>{t('journey.settings.name')}</span>
|
||||
<input id={`${formId}-name`} value={title} onChange={event => setTitle(event.target.value)} className={FIELD_CLS} />
|
||||
</label>
|
||||
<label htmlFor={`${formId}-subtitle`} className="block space-y-2">
|
||||
<span className={FORM_LABEL_CLS}>{t('journey.settings.subtitle')}</span>
|
||||
<input id={`${formId}-subtitle`} value={subtitle} onChange={event => setSubtitle(event.target.value)}
|
||||
placeholder={t('journey.settings.subtitlePlaceholder')} className={FIELD_CLS} />
|
||||
</label>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
|
||||
<FormSheetSection title={t('journey.settings.coverImage')}>
|
||||
<input ref={coverRef} type="file" accept="image/*" className="hidden" onChange={handleCoverUpload} />
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => coverRef.current?.click()}
|
||||
className={`relative flex w-full items-center justify-center gap-2 overflow-hidden rounded-xl border border-m-rowbr bg-m-sheetop px-3 py-2 text-control font-semibold ${coverSrc ? 'min-h-28' : 'min-h-11'}`}
|
||||
>
|
||||
{coverSrc && <img src={coverSrc} alt="" className="absolute inset-0 size-full object-cover" />}
|
||||
<span className={`relative flex items-center justify-center gap-2 ${coverSrc ? 'rounded-full bg-m-sheetop px-3 py-2' : ''}`}>
|
||||
<Image size={16} className="flex-none" aria-hidden />
|
||||
{coverSrc ? t('journey.settings.changeCover') : t('journey.settings.addCover')}
|
||||
</span>
|
||||
</button>
|
||||
</FormSheetSection>
|
||||
</>
|
||||
)}
|
||||
|
||||
{area === 'trips' && (
|
||||
<div className={LIST_PANEL}>
|
||||
{journey.trips.map(trip => (
|
||||
<div key={trip.trip_id} className="flex min-h-14 items-center gap-3 py-2.5">
|
||||
<span className={LIST_ICON}><Luggage size={17} aria-hidden /></span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<bdi className="block break-words text-control font-semibold">{trip.title}</bdi>
|
||||
<div className="mt-1 flex flex-wrap gap-1">
|
||||
{trip.start_date && <span className={META_BADGE}>{formatDate(trip.start_date, locale)}</span>}
|
||||
<span className={META_BADGE}>{t('mobileJourney.placesCount', { count: trip.place_count ?? 0 })}</span>
|
||||
</div>
|
||||
</div>
|
||||
<MIconBtn variant="neutral" size={36}
|
||||
onClick={() => setUnlinkTarget({ trip_id: trip.trip_id, title: trip.title })}
|
||||
ariaLabel={t('journey.trips.unlinkTrip')}
|
||||
>
|
||||
<Unlink size={15} strokeWidth={2} aria-hidden />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
))}
|
||||
{journey.trips.length === 0 && (
|
||||
<p className="py-3 text-control text-m-muted">{t('journey.trips.noTripsLinkedSettings')}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{area === 'linkTrip' && (
|
||||
<FormSheetSection>
|
||||
{loadingTrips || unlinkedTrips.length === 0 ? (
|
||||
<p role="status" className="py-2 text-center text-control text-m-muted">
|
||||
{t(loadingTrips ? 'common.loading' : 'journey.trips.noTripsAvailable')}
|
||||
</p>
|
||||
) : (
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{unlinkedTrips.map(trip => (
|
||||
<div key={trip.id} className="flex min-h-12 items-center gap-2.5 py-1.5">
|
||||
<span className={LIST_ICON}><Luggage size={17} aria-hidden /></span>
|
||||
<bdi className="min-w-0 flex-1 break-words text-control font-semibold">{trip.title}</bdi>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => linkTrip(trip.id)}
|
||||
disabled={linkingTripId != null}
|
||||
className={SHEET_SECONDARY}
|
||||
>
|
||||
{t('journey.trips.link')}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</FormSheetSection>
|
||||
)}
|
||||
|
||||
{area === 'people' && (
|
||||
<>
|
||||
<div className={LIST_PANEL}>
|
||||
{journey.contributors.map(c => (
|
||||
<div key={c.user_id} className="flex min-h-14 items-center gap-3 py-2.5">
|
||||
<JourneyPersonAvatar username={c.username} avatar={c.avatar} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<bdi className="block break-words text-control font-semibold">{c.username}</bdi>
|
||||
<span className="text-caption text-m-muted">{t(c.role === 'owner' ? 'members.owner' : c.role === 'editor' ? 'journey.invite.editor' : 'journey.invite.viewer')}</span>
|
||||
</div>
|
||||
{c.role !== 'owner' && (
|
||||
<MIconBtn variant="neutral" size={36}
|
||||
onClick={() => setPendingContributor(c)}
|
||||
ariaLabel={t('journey.contributors.remove')}
|
||||
>
|
||||
<UserMinus size={15} strokeWidth={2} aria-hidden />
|
||||
</MIconBtn>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<MTripAccessList access={journey.trip_access} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{area === 'share' && <MShareSection journeyId={journey.id} />}
|
||||
|
||||
{area === 'entries' && (
|
||||
<>
|
||||
<SheetSection hint={t('journey.settings.entryFieldsHint')}>
|
||||
{([
|
||||
['show_verdict', t('journey.settings.showVerdict')],
|
||||
['show_mood', t('journey.settings.showMood')],
|
||||
['show_weather', t('journey.settings.showWeather')],
|
||||
] as const).map(([field, label]) => (
|
||||
<ToggleRow
|
||||
key={field}
|
||||
label={label}
|
||||
checked={journey[field] !== 0}
|
||||
onChange={next => handleFieldToggle(field, next)}
|
||||
disabled={savingField !== null}
|
||||
/>
|
||||
))}
|
||||
{/* Only when there is something to bring back */}
|
||||
{onRestoreSuggestions && (journey.dismissed_count ?? 0) > 0 && (
|
||||
<button type="button" onClick={() => { void onRestoreSuggestions() }} className={SHEET_SECONDARY}>
|
||||
<Undo2 size={14} strokeWidth={2.2} />
|
||||
{t('journey.suggestions.restore')}
|
||||
<span className="text-m-muted">{journey.dismissed_count ?? 0}</span>
|
||||
</button>
|
||||
)}
|
||||
</SheetSection>
|
||||
<SheetSection title={t('journey.settings.photosSection')}>
|
||||
<ToggleRow
|
||||
label={t('journey.settings.photoLocation')}
|
||||
hint={t('journey.settings.photoLocationHint')}
|
||||
checked={!!journey.photo_location}
|
||||
onChange={() => { void handlePhotoLocationToggle() }}
|
||||
disabled={savingPhotoLocation}
|
||||
/>
|
||||
</SheetSection>
|
||||
</>
|
||||
)}
|
||||
|
||||
{area === 'map' && (
|
||||
<>
|
||||
<SheetSection title={t('journey.settings.tracks')}>
|
||||
<ToggleRow
|
||||
label={t('journey.settings.showTripTracks')}
|
||||
hint={t('journey.settings.showTripTracksHint')}
|
||||
checked={!!journey.show_trip_tracks}
|
||||
onChange={handleTracksToggle}
|
||||
disabled={savingTracks}
|
||||
/>
|
||||
</SheetSection>
|
||||
|
||||
{recordingPrep && (
|
||||
<SheetSection title={t('journey.settings.recordings')}>
|
||||
<MRecordingPrepRow prep={recordingPrep} enabled={!!journey.auto_prepare_recordings} />
|
||||
</SheetSection>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{area === 'status' && (
|
||||
<>
|
||||
<FormSheetSection>
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{statusOptions.map(({ value, label }) => (
|
||||
<button key={value} type="button" aria-pressed={statusChoice === value} disabled={savingStatus}
|
||||
className="flex min-h-11 w-full items-center justify-between gap-3 px-1 py-2 text-start text-control font-medium disabled:opacity-60"
|
||||
onClick={() => { void handleStatusChange(value) }}>
|
||||
{label}
|
||||
{statusChoice === value && <Check size={17} className="flex-none" aria-hidden />}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-2 px-1 text-caption text-m-muted">
|
||||
{t(statusChoice === 'auto' ? 'journey.settings.statusAutoHint' : 'journey.settings.statusManualHint')}
|
||||
</p>
|
||||
</FormSheetSection>
|
||||
<FormSheetSection>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button type="button" onClick={handleArchiveToggle} disabled={archiving} className={SHEET_SECONDARY}>
|
||||
{journey.status === 'archived' ? <ArchiveRestore size={16} aria-hidden /> : <Archive size={16} aria-hidden />}
|
||||
{t(journey.status === 'archived' ? 'journey.settings.reopenJourney' : 'journey.settings.endJourney')}
|
||||
</button>
|
||||
<button type="button" onClick={() => setShowDeleteConfirm(true)} className={SHEET_DANGER}>
|
||||
<Trash2 size={16} aria-hidden /> {t('journey.settings.delete')}
|
||||
</button>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
</>
|
||||
)}
|
||||
{renderArea()}
|
||||
</FormSheetBody>
|
||||
|
||||
{(area === 'trips' || area === 'people') && (
|
||||
@@ -411,6 +272,199 @@ export default function MJourneySettingsSheet({
|
||||
)
|
||||
}
|
||||
|
||||
type JourneySettings = ReturnType<typeof useJourneySettings>
|
||||
|
||||
function JourneyProfileFields({ formId, coverSrc, settings }: {
|
||||
formId: string
|
||||
coverSrc: string | null
|
||||
settings: JourneySettings
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { title, setTitle, subtitle, setSubtitle, handleCoverUpload } = settings
|
||||
const coverRef = useRef<HTMLInputElement>(null)
|
||||
return (
|
||||
<>
|
||||
<FormSheetSection>
|
||||
<div className="space-y-3">
|
||||
<label htmlFor={`${formId}-name`} className="block space-y-2">
|
||||
<span className={FORM_LABEL_CLS}>{t('journey.settings.name')}</span>
|
||||
<input id={`${formId}-name`} value={title} onChange={event => setTitle(event.target.value)} className={FIELD_CLS} />
|
||||
</label>
|
||||
<label htmlFor={`${formId}-subtitle`} className="block space-y-2">
|
||||
<span className={FORM_LABEL_CLS}>{t('journey.settings.subtitle')}</span>
|
||||
<input id={`${formId}-subtitle`} value={subtitle} onChange={event => setSubtitle(event.target.value)}
|
||||
placeholder={t('journey.settings.subtitlePlaceholder')} className={FIELD_CLS} />
|
||||
</label>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
|
||||
<FormSheetSection title={t('journey.settings.coverImage')}>
|
||||
<input ref={coverRef} type="file" accept="image/*" className="hidden" onChange={handleCoverUpload} />
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => coverRef.current?.click()}
|
||||
className={`relative flex w-full items-center justify-center gap-2 overflow-hidden rounded-xl border border-m-rowbr bg-m-sheetop px-3 py-2 text-control font-semibold ${coverSrc ? 'min-h-28' : 'min-h-11'}`}
|
||||
>
|
||||
{coverSrc && <img src={coverSrc} alt="" className="absolute inset-0 size-full object-cover" />}
|
||||
<span className={`relative flex items-center justify-center gap-2 ${coverSrc ? 'rounded-full bg-m-sheetop px-3 py-2' : ''}`}>
|
||||
<Image size={16} className="flex-none" aria-hidden />
|
||||
{coverSrc ? t('journey.settings.changeCover') : t('journey.settings.addCover')}
|
||||
</span>
|
||||
</button>
|
||||
</FormSheetSection>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyLinkedTrips({ trips, onUnlink }: {
|
||||
trips: JourneyDetail['trips']
|
||||
onUnlink: JourneySettings['setUnlinkTarget']
|
||||
}) {
|
||||
const { t, locale } = useTranslation()
|
||||
return (
|
||||
<div className={LIST_PANEL}>
|
||||
{trips.map(trip => (
|
||||
<div key={trip.trip_id} className="flex min-h-14 items-center gap-3 py-2.5">
|
||||
<span className={LIST_ICON}><Luggage size={17} aria-hidden /></span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<bdi className="block break-words text-control font-semibold">{trip.title}</bdi>
|
||||
<div className="mt-1 flex flex-wrap gap-1">
|
||||
{trip.start_date && <span className={META_BADGE}>{formatDate(trip.start_date, locale)}</span>}
|
||||
<span className={META_BADGE}>{t('mobileJourney.placesCount', { count: trip.place_count ?? 0 })}</span>
|
||||
</div>
|
||||
</div>
|
||||
<MIconBtn variant="neutral" size={36}
|
||||
onClick={() => onUnlink({ trip_id: trip.trip_id, title: trip.title })}
|
||||
ariaLabel={t('journey.trips.unlinkTrip')}
|
||||
>
|
||||
<Unlink size={15} strokeWidth={2} aria-hidden />
|
||||
</MIconBtn>
|
||||
</div>
|
||||
))}
|
||||
{trips.length === 0 && (
|
||||
<p className="py-3 text-control text-m-muted">{t('journey.trips.noTripsLinkedSettings')}</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyEntryFields({ journey, onRestoreSuggestions, settings }: {
|
||||
journey: JourneyDetail
|
||||
onRestoreSuggestions: MJourneySettingsSheetProps['onRestoreSuggestions']
|
||||
settings: JourneySettings
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { savingField, handleFieldToggle, savingPhotoLocation, handlePhotoLocationToggle } = settings
|
||||
return (
|
||||
<>
|
||||
<SheetSection hint={t('journey.settings.entryFieldsHint')}>
|
||||
{([
|
||||
['show_verdict', t('journey.settings.showVerdict')],
|
||||
['show_mood', t('journey.settings.showMood')],
|
||||
['show_weather', t('journey.settings.showWeather')],
|
||||
] as const).map(([field, label]) => (
|
||||
<ToggleRow
|
||||
key={field}
|
||||
label={label}
|
||||
checked={journey[field] !== 0}
|
||||
onChange={next => handleFieldToggle(field, next)}
|
||||
disabled={savingField !== null}
|
||||
/>
|
||||
))}
|
||||
{/* Only when there is something to bring back */}
|
||||
{onRestoreSuggestions && (journey.dismissed_count ?? 0) > 0 && (
|
||||
<button type="button" onClick={() => { void onRestoreSuggestions() }} className={SHEET_SECONDARY}>
|
||||
<Undo2 size={14} strokeWidth={2.2} />
|
||||
{t('journey.suggestions.restore')}
|
||||
<span className="text-m-muted">{journey.dismissed_count ?? 0}</span>
|
||||
</button>
|
||||
)}
|
||||
</SheetSection>
|
||||
<SheetSection title={t('journey.settings.photosSection')}>
|
||||
<ToggleRow
|
||||
label={t('journey.settings.photoLocation')}
|
||||
hint={t('journey.settings.photoLocationHint')}
|
||||
checked={!!journey.photo_location}
|
||||
onChange={() => { void handlePhotoLocationToggle() }}
|
||||
disabled={savingPhotoLocation}
|
||||
/>
|
||||
</SheetSection>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyMapSettings({ journey, recordingPrep, settings }: {
|
||||
journey: JourneyDetail
|
||||
recordingPrep: MJourneySettingsSheetProps['recordingPrep']
|
||||
settings: JourneySettings
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { savingTracks, handleTracksToggle } = settings
|
||||
return (
|
||||
<>
|
||||
<SheetSection title={t('journey.settings.tracks')}>
|
||||
<ToggleRow
|
||||
label={t('journey.settings.showTripTracks')}
|
||||
hint={t('journey.settings.showTripTracksHint')}
|
||||
checked={!!journey.show_trip_tracks}
|
||||
onChange={handleTracksToggle}
|
||||
disabled={savingTracks}
|
||||
/>
|
||||
</SheetSection>
|
||||
|
||||
{recordingPrep && (
|
||||
<SheetSection title={t('journey.settings.recordings')}>
|
||||
<MRecordingPrepRow prep={recordingPrep} enabled={!!journey.auto_prepare_recordings} />
|
||||
</SheetSection>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyStatusSettings({ journey, settings }: {
|
||||
journey: JourneyDetail
|
||||
settings: JourneySettings
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { archiving, setShowDeleteConfirm, handleArchiveToggle, statusChoice, savingStatus, handleStatusChange } = settings
|
||||
const statusOptions: Array<{ value: JourneyStatusChoice; label: string }> = [
|
||||
{ value: 'auto', label: t('journey.settings.statusAuto') },
|
||||
{ value: 'draft', label: t('journey.status.draft') },
|
||||
{ value: 'live', label: t('journey.frontpage.live') },
|
||||
{ value: 'completed', label: t('journey.status.completed') },
|
||||
]
|
||||
return (
|
||||
<>
|
||||
<FormSheetSection>
|
||||
<div className="divide-y divide-m-rowbr">
|
||||
{statusOptions.map(({ value, label }) => (
|
||||
<button key={value} type="button" aria-pressed={statusChoice === value} disabled={savingStatus}
|
||||
className="flex min-h-11 w-full items-center justify-between gap-3 px-1 py-2 text-start text-control font-medium disabled:opacity-60"
|
||||
onClick={() => { void handleStatusChange(value) }}>
|
||||
{label}
|
||||
{statusChoice === value && <Check size={17} className="flex-none" aria-hidden />}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-2 px-1 text-caption text-m-muted">
|
||||
{t(statusChoice === 'auto' ? 'journey.settings.statusAutoHint' : 'journey.settings.statusManualHint')}
|
||||
</p>
|
||||
</FormSheetSection>
|
||||
<FormSheetSection>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button type="button" onClick={handleArchiveToggle} disabled={archiving} className={SHEET_SECONDARY}>
|
||||
{journey.status === 'archived' ? <ArchiveRestore size={16} aria-hidden /> : <Archive size={16} aria-hidden />}
|
||||
{t(journey.status === 'archived' ? 'journey.settings.reopenJourney' : 'journey.settings.endJourney')}
|
||||
</button>
|
||||
<button type="button" onClick={() => setShowDeleteConfirm(true)} className={SHEET_DANGER}>
|
||||
<Trash2 size={16} aria-hidden /> {t('journey.settings.delete')}
|
||||
</button>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function JourneyPersonAvatar({ username, avatar }: { username: string; avatar?: string | null }) {
|
||||
const src = avatarSrc(avatar)
|
||||
return src ? <img src={src} alt="" className="size-9 flex-none rounded-full object-cover" /> : (
|
||||
|
||||
@@ -31,15 +31,7 @@ export default function MNotificationRow({ notification }: MNotificationRowProps
|
||||
|
||||
const summary = (
|
||||
<>
|
||||
{notification.sender_avatar ? (
|
||||
<img src={notification.sender_avatar} alt="" className="size-9 flex-none rounded-full object-cover" />
|
||||
) : (
|
||||
<span className="grid size-9 flex-none place-items-center rounded-full bg-m-ic text-caption font-semibold text-m-muted">
|
||||
{notification.sender_username
|
||||
? notification.sender_username.charAt(0).toUpperCase()
|
||||
: <Bell size={16} aria-hidden />}
|
||||
</span>
|
||||
)}
|
||||
<NotificationAvatar notification={notification} />
|
||||
<span className="min-w-0 flex-1">
|
||||
<span dir="auto" className={`block break-words text-body leading-tight text-m-ink ${read ? 'font-medium' : 'font-semibold'}`}>{title}</span>
|
||||
{body && <span dir="auto" className="mt-1 block break-words text-caption text-m-muted">{body}</span>}
|
||||
@@ -109,3 +101,19 @@ export default function MNotificationRow({ notification }: MNotificationRowProps
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
function NotificationAvatar({ notification }: MNotificationRowProps) {
|
||||
return (
|
||||
<>
|
||||
{notification.sender_avatar ? (
|
||||
<img src={notification.sender_avatar} alt="" className="size-9 flex-none rounded-full object-cover" />
|
||||
) : (
|
||||
<span className="grid size-9 flex-none place-items-center rounded-full bg-m-ic text-caption font-semibold text-m-muted">
|
||||
{notification.sender_username
|
||||
? notification.sender_username.charAt(0).toUpperCase()
|
||||
: <Bell size={16} aria-hidden />}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -418,41 +418,13 @@ function PlanDayPage({ planner, shell, dayId: pageDayId, active, editing, legMen
|
||||
)}
|
||||
|
||||
{tl.rows.length === 0 && !editing && (
|
||||
<div className="flex min-h-full flex-1 flex-col items-center justify-center py-8 text-center">
|
||||
<MDancingTrek scene="guide" className="mb-2" />
|
||||
<p className="font-geist text-[0.8125rem] font-medium text-m-muted">{t('dayplan.emptyDay')}</p>
|
||||
{day && planner.can('place_edit', planner.trip) && planner.can('day_edit', planner.trip) && (
|
||||
<button type="button" onClick={tl.addPlace}
|
||||
className="mt-4 inline-flex min-h-11 items-center gap-2 rounded-full bg-m-act px-4 text-body font-semibold text-m-actfg">
|
||||
<MapPin size={17} aria-hidden />
|
||||
{t('dayplan.addPlaceHere')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<EmptyDayGuide allowAdd={Boolean(day && canEditPlaces && canEdit)} onAddPlace={tl.addPlace} t={t} />
|
||||
)}
|
||||
|
||||
</div>
|
||||
{editing && day && (
|
||||
<div className="flex flex-none items-center gap-2 border-t border-m-rowbr px-3 py-2">
|
||||
{canEditPlaces && (
|
||||
<button type="button" onClick={tl.addPlace} className={DAY_PRIMARY}>
|
||||
<MapPin size={16} strokeWidth={2} className="shrink-0" aria-hidden />
|
||||
<span>{t('dayplan.addPlaceHere')}</span>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('common.add')}
|
||||
aria-haspopup="dialog"
|
||||
onClick={() => setDayMenu({ kind: 'add', open: true })}
|
||||
className={canEditPlaces
|
||||
? 'm-round-control grid size-11 shrink-0 place-items-center rounded-full border border-m-rowbr bg-m-ic text-m-ink'
|
||||
: DAY_PRIMARY}
|
||||
>
|
||||
<Plus size={19} strokeWidth={2} className="shrink-0" aria-hidden />
|
||||
{!canEditPlaces && <span>{t('common.add')}</span>}
|
||||
</button>
|
||||
</div>
|
||||
<DayEditFooter canEditPlaces={canEditPlaces} onAddPlace={tl.addPlace}
|
||||
onOpenMenu={() => setDayMenu({ kind: 'add', open: true })} t={t} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -460,6 +432,56 @@ function PlanDayPage({ planner, shell, dayId: pageDayId, active, editing, legMen
|
||||
)
|
||||
}
|
||||
|
||||
function EmptyDayGuide({ allowAdd, onAddPlace, t }: {
|
||||
allowAdd: boolean
|
||||
onAddPlace: () => void
|
||||
t: MPlanTimelineProps['planner']['t']
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-h-full flex-1 flex-col items-center justify-center py-8 text-center">
|
||||
<MDancingTrek scene="guide" className="mb-2" />
|
||||
<p className="font-geist text-[0.8125rem] font-medium text-m-muted">{t('dayplan.emptyDay')}</p>
|
||||
{allowAdd && (
|
||||
<button type="button" onClick={onAddPlace}
|
||||
className="mt-4 inline-flex min-h-11 items-center gap-2 rounded-full bg-m-act px-4 text-body font-semibold text-m-actfg">
|
||||
<MapPin size={17} aria-hidden />
|
||||
{t('dayplan.addPlaceHere')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function DayEditFooter({ canEditPlaces, onAddPlace, onOpenMenu, t }: {
|
||||
canEditPlaces: boolean
|
||||
onAddPlace: () => void
|
||||
onOpenMenu: () => void
|
||||
t: MPlanTimelineProps['planner']['t']
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-none items-center gap-2 border-t border-m-rowbr px-3 py-2">
|
||||
{canEditPlaces && (
|
||||
<button type="button" onClick={onAddPlace} className={DAY_PRIMARY}>
|
||||
<MapPin size={16} strokeWidth={2} className="shrink-0" aria-hidden />
|
||||
<span>{t('dayplan.addPlaceHere')}</span>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('common.add')}
|
||||
aria-haspopup="dialog"
|
||||
onClick={onOpenMenu}
|
||||
className={canEditPlaces
|
||||
? 'm-round-control grid size-11 shrink-0 place-items-center rounded-full border border-m-rowbr bg-m-ic text-m-ink'
|
||||
: DAY_PRIMARY}
|
||||
>
|
||||
<Plus size={19} strokeWidth={2} className="shrink-0" aria-hidden />
|
||||
{!canEditPlaces && <span>{t('common.add')}</span>}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Go mode: the next stop with a live countdown (only counting down on today's day). */
|
||||
function UpNextCard({ tl, t, onOpen }: {
|
||||
tl: MPlanTimelineController
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BedDouble, ChevronDown, ChevronRight, ChevronUp, Footprints, MoreHorizontal, Pencil, StickyNote, Ticket, TramFront, Zap } from 'lucide-react'
|
||||
import { BedDouble, ChevronDown, ChevronRight, ChevronUp, Footprints, MoreHorizontal, Ticket, TramFront, Zap } from 'lucide-react'
|
||||
import { routeModeIcon } from '../../../../components/Planner/routeModes'
|
||||
import type { ReactNode, MouseEvent, CSSProperties } from 'react'
|
||||
import PlaceAvatar from '../../../../components/shared/PlaceAvatar'
|
||||
|
||||
@@ -155,7 +155,7 @@ function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: O
|
||||
const addStop = canEditStage && stageDayId != null
|
||||
? () => planner.openNewPlaceForDay(stageDayId)
|
||||
: undefined
|
||||
const addStopButton = addStop && (
|
||||
const renderAddStop = () => addStop && (
|
||||
<button type="button" onClick={addStop}
|
||||
className="flex min-h-11 w-full items-center justify-center gap-2 rounded-[13px] bg-m-act px-4 py-2 text-body font-semibold text-m-actfg">
|
||||
<Plus size={18} aria-hidden />
|
||||
@@ -210,6 +210,32 @@ function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: O
|
||||
else planner.handlePlaceClick(reading.placeId)
|
||||
}
|
||||
|
||||
const renderStageStop = (row: StopRow, i: number) => {
|
||||
const group = bookings.atRow?.get(i)
|
||||
const previous = rt.rows[i - 1]?.kind
|
||||
const beforeLeg = previous === 'leg' || previous === 'arriving'
|
||||
const afterLeg = rt.rows[i + 1]?.kind === 'leg'
|
||||
return (
|
||||
<div key={`s${i}`}>
|
||||
<RtStopRow
|
||||
row={row}
|
||||
chrome={chrome}
|
||||
connectBefore={beforeLeg}
|
||||
connectAfter={afterLeg || Boolean(group?.linked || group?.bookings.some(booking => approaches?.has(booking.id)))}
|
||||
onOpen={() => openStop(row)}
|
||||
onPickKind={canEditPlaces && !row.stop.carrier
|
||||
? () => shell.openSheet('rtkind', {
|
||||
placeId: row.stop.placeId,
|
||||
stopType: row.stop.stopType ?? null,
|
||||
name: row.stop.name,
|
||||
})
|
||||
: undefined}
|
||||
/>
|
||||
{bookingRows(i, afterLeg)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Room for the search bar, which only stands over a stage.
|
||||
return (
|
||||
<div
|
||||
@@ -223,7 +249,7 @@ function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: O
|
||||
) : rt.empty || !stage ? (
|
||||
<div className="mx-auto max-w-sm">
|
||||
<EmptyStage planner={planner} loading={rt.loading} />
|
||||
{!rt.loading && addStopButton}
|
||||
{!rt.loading && renderAddStop()}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
@@ -278,31 +304,7 @@ function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: O
|
||||
if (row.kind === 'stop' && row.bookend) {
|
||||
return <RtBookendRow key={`s${i}`} row={row} bookend={row.bookend} chrome={chrome} onOpen={() => openStop(row)} />
|
||||
}
|
||||
if (row.kind === 'stop') {
|
||||
const group = bookings.atRow?.get(i)
|
||||
const previous = rt.rows[i - 1]?.kind
|
||||
const beforeLeg = previous === 'leg' || previous === 'arriving'
|
||||
const afterLeg = rt.rows[i + 1]?.kind === 'leg'
|
||||
return (
|
||||
<div key={`s${i}`}>
|
||||
<RtStopRow
|
||||
row={row}
|
||||
chrome={chrome}
|
||||
connectBefore={beforeLeg}
|
||||
connectAfter={afterLeg || Boolean(group?.linked || group?.bookings.some(booking => approaches?.has(booking.id)))}
|
||||
onOpen={() => openStop(row)}
|
||||
onPickKind={canEditPlaces && !row.stop.carrier
|
||||
? () => shell.openSheet('rtkind', {
|
||||
placeId: row.stop.placeId,
|
||||
stopType: row.stop.stopType ?? null,
|
||||
name: row.stop.name,
|
||||
})
|
||||
: undefined}
|
||||
/>
|
||||
{bookingRows(i, afterLeg)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (row.kind === 'stop') return renderStageStop(row, i)
|
||||
if (row.kind === 'leg' || row.kind === 'arriving') {
|
||||
// Only where the desk rail offers it too (legReroutable, arrivingReroutable),
|
||||
// and with the card's day id, the one the desk passes: the planner finds the
|
||||
|
||||
@@ -20,12 +20,7 @@ export default function MExportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
const { t, locale } = useTranslation()
|
||||
const open = shell.sheet?.id === 'export'
|
||||
const dayNotes = useTripStore(s => s.dayNotes)
|
||||
const [subscribeOpen, setSubscribeOpen] = useState(false)
|
||||
const [formatsOpen, setFormatsOpen] = useState(false)
|
||||
if (!open && (subscribeOpen || formatsOpen)) {
|
||||
setSubscribeOpen(false)
|
||||
setFormatsOpen(false)
|
||||
}
|
||||
const { subscribeOpen, setSubscribeOpen, formatsOpen, setFormatsOpen } = useExportDisclosures(open)
|
||||
// The iOS Home Screen app hands the PDF to Safari, which lands here with ?export=pdf.
|
||||
useExportDeepLink(() => shell.openSheet('export'))
|
||||
// Fed the way the desktop dialog feeds it: the store's assignments, and the export
|
||||
@@ -159,3 +154,13 @@ function ExportRow({ icon: Icon, title, sub, onClick }: {
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function useExportDisclosures(open: boolean) {
|
||||
const [subscribeOpen, setSubscribeOpen] = useState(false)
|
||||
const [formatsOpen, setFormatsOpen] = useState(false)
|
||||
if (!open && (subscribeOpen || formatsOpen)) {
|
||||
setSubscribeOpen(false)
|
||||
setFormatsOpen(false)
|
||||
}
|
||||
return { subscribeOpen, setSubscribeOpen, formatsOpen, setFormatsOpen }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Calendar, LockKeyhole, Power, RefreshCw } from 'lucide-react';
|
||||
import {
|
||||
DayEventsSwitch,
|
||||
useIcsSubscription,
|
||||
type IcsSubscribeModalProps,
|
||||
} from '../../../../components/Planner/IcsSubscribeModal';
|
||||
import { DayEventsSwitch, type IcsSubscribeModalProps } from '../../../../components/Planner/IcsSubscribeModal';
|
||||
import { useIcsSubscription } from '../../../../components/Planner/useIcsSubscription';
|
||||
import { useTranslation } from '../../../../i18n';
|
||||
import MSheet from '../../../components/MSheet';
|
||||
import MSubscribeLinks from './MSubscribeLinks';
|
||||
|
||||
@@ -118,6 +118,96 @@ export default function MNoteSheet({ planner, open, payload, onClose }: MNoteShe
|
||||
}
|
||||
}
|
||||
|
||||
const renderNoteFields = () => (
|
||||
<FormSheetSection>
|
||||
<label htmlFor={`${id}-title`} className={`mb-1.5 block ${FORM_LABEL_CLS}`}>{t('common.title')}</label>
|
||||
<input id={`${id}-title`} type="text" value={title} onChange={e => setTitle(e.target.value)}
|
||||
required maxLength={500} className={FIELD_CLS} />
|
||||
|
||||
<div className="mt-2 flex min-h-11 items-center justify-between gap-2">
|
||||
<label htmlFor={`${id}-detail`} className={FORM_LABEL_CLS}>{t('dayplan.noteSubtitle')}</label>
|
||||
<button type="button" onMouseDown={e => e.preventDefault()}
|
||||
onClick={() => setFormatOpen(value => !value)} aria-expanded={formatOpen} aria-controls={`${id}-format`}
|
||||
className="flex min-h-10 items-center gap-1.5 rounded-full border border-m-rowbr bg-m-sheetop px-3 text-caption font-medium text-m-ink">
|
||||
{t('notes.format.toolbar')}
|
||||
<ChevronDown size={14} aria-hidden className={formatOpen ? 'rotate-180' : ''} />
|
||||
</button>
|
||||
</div>
|
||||
<div id={`${id}-format`} hidden={!formatOpen}
|
||||
className="mb-2 [&>div]:grid [&>div]:grid-cols-4 [&_button]:!size-10 [&_button]:justify-self-center [@container(min-width:344px)]:[&>div]:grid-cols-8">
|
||||
<NoteFormatToolbar textareaRef={detailRef} onChange={setDetail} variant="mobile" />
|
||||
</div>
|
||||
<textarea id={`${id}-detail`} ref={detailRef} value={detail} onChange={e => setDetail(e.target.value)}
|
||||
rows={3} maxLength={DAY_NOTE_DETAIL_MAX} placeholder={t('notes.bodyPlaceholder')}
|
||||
aria-invalid={tooLong || undefined} aria-describedby={dayNoteNearLimit(storedDetail.length) ? `${id}-count` : undefined}
|
||||
className={FIELD_AREA_CLS} />
|
||||
{dayNoteNearLimit(storedDetail.length) && (
|
||||
<p id={`${id}-count`} className="mt-1 text-end text-caption tabular-nums text-[color:var(--m-st-pending)]">
|
||||
{storedDetail.length}/{DAY_NOTE_DETAIL_MAX}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-3 flex min-h-11 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-m-rowbr pt-3">
|
||||
<label htmlFor={`${id}-time`} className={FORM_LABEL_CLS}>{t('planner.noteTimePlaceholder')}</label>
|
||||
<div className="flex items-center gap-1">
|
||||
<input id={`${id}-time`} type="time" dir="ltr" value={time} onChange={e => setTime(e.target.value)}
|
||||
className={`${FIELD_CLS} !w-auto max-w-full`} />
|
||||
{time && (
|
||||
<MIconBtn ariaLabel={t('common.clear')} onClick={() => setTime('')} variant="neutral" size={44}>
|
||||
<X size={15} aria-hidden />
|
||||
</MIconBtn>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
)
|
||||
|
||||
const renderAppearance = () => (
|
||||
<FormSheetDisclosure label={t('notes.appearance')} open={appearanceOpen} onOpenChange={setAppearanceOpen}>
|
||||
<div className="px-2 py-2">
|
||||
<button type="button" onClick={() => setIconOpen(v => !v)} aria-expanded={iconOpen}
|
||||
className="flex min-h-11 items-center gap-2 rounded-full border px-3 text-caption font-medium"
|
||||
style={{ borderColor: skin.border, background: skin.iconBackground }}>
|
||||
<ChosenIcon size={19} strokeWidth={1.9} style={{ color: skin.iconColor }} aria-hidden />
|
||||
{t('dayplan.noteIcon')}
|
||||
<ChevronDown size={14} aria-hidden className={iconOpen ? 'rotate-180' : ''} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{iconOpen && (
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(44px,1fr))] gap-1.5 px-2 pb-3">
|
||||
{NOTE_ICONS.map(({ id, Icon }) => (
|
||||
<button key={id} type="button" onClick={() => { setIcon(id); setIconOpen(false) }}
|
||||
aria-label={id} aria-pressed={icon === id}
|
||||
className={`flex min-h-11 items-center justify-center rounded-xl border border-[color:var(--m-rowbr)] ${
|
||||
icon === id ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'
|
||||
}`}>
|
||||
<Icon size={17} strokeWidth={1.8} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2 px-2 pb-2" role="group" aria-labelledby={`${id}-color`}>
|
||||
<div id={`${id}-color`} className="text-caption font-medium text-m-muted">{t('notes.color.label')}</div>
|
||||
<div className="[&>div]:grid [&>div]:grid-cols-4 [&_button]:size-10 [&_button]:justify-self-center [@container(min-width:400px)]:[&>div]:grid-cols-8">
|
||||
<NoteColorPicker value={color} onChange={setColor} />
|
||||
</div>
|
||||
</div>
|
||||
</FormSheetDisclosure>
|
||||
)
|
||||
|
||||
const renderNoteFooter = () => (
|
||||
<FormSheetFooter
|
||||
onDelete={note && !isSaving ? () => setConfirmDeleteOpen(true) : undefined}
|
||||
deleteLabel={t('common.delete')}
|
||||
onCancel={onClose}
|
||||
cancelLabel={t('common.cancel')}
|
||||
onSubmit={() => { void handleSubmit() }}
|
||||
submitLabel={note ? t('common.save') : t('common.add')}
|
||||
submitDisabled={!title.trim() || !dayId || isSaving || tooLong}
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<MSheet open={open} onClose={onClose} form ariaLabel={note ? t('dayplan.noteEdit') : t('dayplan.noteAdd')}
|
||||
@@ -131,90 +221,11 @@ export default function MNoteSheet({ planner, open, payload, onClose }: MNoteShe
|
||||
/>
|
||||
|
||||
<FormSheetBody>
|
||||
<FormSheetSection>
|
||||
<label htmlFor={`${id}-title`} className={`mb-1.5 block ${FORM_LABEL_CLS}`}>{t('common.title')}</label>
|
||||
<input id={`${id}-title`} type="text" value={title} onChange={e => setTitle(e.target.value)}
|
||||
required maxLength={500} className={FIELD_CLS} />
|
||||
|
||||
<div className="mt-2 flex min-h-11 items-center justify-between gap-2">
|
||||
<label htmlFor={`${id}-detail`} className={FORM_LABEL_CLS}>{t('dayplan.noteSubtitle')}</label>
|
||||
<button type="button" onMouseDown={e => e.preventDefault()}
|
||||
onClick={() => setFormatOpen(value => !value)} aria-expanded={formatOpen} aria-controls={`${id}-format`}
|
||||
className="flex min-h-10 items-center gap-1.5 rounded-full border border-m-rowbr bg-m-sheetop px-3 text-caption font-medium text-m-ink">
|
||||
{t('notes.format.toolbar')}
|
||||
<ChevronDown size={14} aria-hidden className={formatOpen ? 'rotate-180' : ''} />
|
||||
</button>
|
||||
</div>
|
||||
<div id={`${id}-format`} hidden={!formatOpen}
|
||||
className="mb-2 [&>div]:grid [&>div]:grid-cols-4 [&_button]:!size-10 [&_button]:justify-self-center [@container(min-width:344px)]:[&>div]:grid-cols-8">
|
||||
<NoteFormatToolbar textareaRef={detailRef} onChange={setDetail} variant="mobile" />
|
||||
</div>
|
||||
<textarea id={`${id}-detail`} ref={detailRef} value={detail} onChange={e => setDetail(e.target.value)}
|
||||
rows={3} maxLength={DAY_NOTE_DETAIL_MAX} placeholder={t('notes.bodyPlaceholder')}
|
||||
aria-invalid={tooLong || undefined} aria-describedby={dayNoteNearLimit(storedDetail.length) ? `${id}-count` : undefined}
|
||||
className={FIELD_AREA_CLS} />
|
||||
{dayNoteNearLimit(storedDetail.length) && (
|
||||
<p id={`${id}-count`} className="mt-1 text-end text-caption tabular-nums text-[color:var(--m-st-pending)]">
|
||||
{storedDetail.length}/{DAY_NOTE_DETAIL_MAX}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-3 flex min-h-11 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-m-rowbr pt-3">
|
||||
<label htmlFor={`${id}-time`} className={FORM_LABEL_CLS}>{t('planner.noteTimePlaceholder')}</label>
|
||||
<div className="flex items-center gap-1">
|
||||
<input id={`${id}-time`} type="time" dir="ltr" value={time} onChange={e => setTime(e.target.value)}
|
||||
className={`${FIELD_CLS} !w-auto max-w-full`} />
|
||||
{time && (
|
||||
<MIconBtn ariaLabel={t('common.clear')} onClick={() => setTime('')} variant="neutral" size={44}>
|
||||
<X size={15} aria-hidden />
|
||||
</MIconBtn>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
|
||||
<FormSheetDisclosure label={t('notes.appearance')} open={appearanceOpen} onOpenChange={setAppearanceOpen}>
|
||||
<div className="px-2 py-2">
|
||||
<button type="button" onClick={() => setIconOpen(v => !v)} aria-expanded={iconOpen}
|
||||
className="flex min-h-11 items-center gap-2 rounded-full border px-3 text-caption font-medium"
|
||||
style={{ borderColor: skin.border, background: skin.iconBackground }}>
|
||||
<ChosenIcon size={19} strokeWidth={1.9} style={{ color: skin.iconColor }} aria-hidden />
|
||||
{t('dayplan.noteIcon')}
|
||||
<ChevronDown size={14} aria-hidden className={iconOpen ? 'rotate-180' : ''} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{iconOpen && (
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(44px,1fr))] gap-1.5 px-2 pb-3">
|
||||
{NOTE_ICONS.map(({ id, Icon }) => (
|
||||
<button key={id} type="button" onClick={() => { setIcon(id); setIconOpen(false) }}
|
||||
aria-label={id} aria-pressed={icon === id}
|
||||
className={`flex min-h-11 items-center justify-center rounded-xl border border-[color:var(--m-rowbr)] ${
|
||||
icon === id ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'
|
||||
}`}>
|
||||
<Icon size={17} strokeWidth={1.8} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2 px-2 pb-2" role="group" aria-labelledby={`${id}-color`}>
|
||||
<div id={`${id}-color`} className="text-caption font-medium text-m-muted">{t('notes.color.label')}</div>
|
||||
<div className="[&>div]:grid [&>div]:grid-cols-4 [&_button]:size-10 [&_button]:justify-self-center [@container(min-width:400px)]:[&>div]:grid-cols-8">
|
||||
<NoteColorPicker value={color} onChange={setColor} />
|
||||
</div>
|
||||
</div>
|
||||
</FormSheetDisclosure>
|
||||
{renderNoteFields()}
|
||||
{renderAppearance()}
|
||||
</FormSheetBody>
|
||||
|
||||
<FormSheetFooter
|
||||
onDelete={note && !isSaving ? () => setConfirmDeleteOpen(true) : undefined}
|
||||
deleteLabel={t('common.delete')}
|
||||
onCancel={onClose}
|
||||
cancelLabel={t('common.cancel')}
|
||||
onSubmit={() => { void handleSubmit() }}
|
||||
submitLabel={note ? t('common.save') : t('common.add')}
|
||||
submitDisabled={!title.trim() || !dayId || isSaving || tooLong}
|
||||
/>
|
||||
{renderNoteFooter()}
|
||||
</MSheet>
|
||||
<MConfirmSheet open={open && confirmDeleteOpen} onClose={() => setConfirmDeleteOpen(false)}
|
||||
title={t('dayplan.confirmDeleteNoteTitle')} message={t('dayplan.confirmDeleteNoteBody')}
|
||||
|
||||
@@ -228,20 +228,22 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh
|
||||
// point opened the sheet.
|
||||
const hasTimeError = endsBeforeStart(form.place_time, form.end_time)
|
||||
|
||||
const assignExistingPlace = async (placeId: number, dayId: number) => {
|
||||
if (!canAssignSelected) return
|
||||
setIsSaving(true)
|
||||
try {
|
||||
if (await planner.handleAssignToDay(placeId, dayId) !== false) handleClose()
|
||||
} catch (err: unknown) {
|
||||
toast.error(err instanceof Error ? err.message : t('places.saveError'))
|
||||
} finally {
|
||||
setIsSaving(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (isSaving || resolvingPick) return
|
||||
if (selectedTripPlace && day) {
|
||||
if (!canAssignSelected) return
|
||||
setIsSaving(true)
|
||||
try {
|
||||
if (await planner.handleAssignToDay(selectedTripPlace.id, day.id) !== false) handleClose()
|
||||
} catch (err: unknown) {
|
||||
toast.error(err instanceof Error ? err.message : t('places.saveError'))
|
||||
} finally {
|
||||
setIsSaving(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (selectedTripPlace && day) return assignExistingPlace(selectedTripPlace.id, day.id)
|
||||
|
||||
if (!form.name.trim()) {
|
||||
toast.error(t('places.nameRequired'))
|
||||
@@ -340,36 +342,8 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh
|
||||
|
||||
<div hidden={Boolean(selectedTripPlace)}>
|
||||
<FormSheetSection className="mt-3">
|
||||
<Eyebrow className="mb-1.5"><label htmlFor={nameId}>{t('places.formName')} *</label></Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
id={nameId}
|
||||
aria-required="true"
|
||||
value={form.name}
|
||||
onChange={e => handleChange('name', e.target.value)}
|
||||
placeholder={t('places.formNamePlaceholder')}
|
||||
className={`${FIELD_CLS} ${resolvingPick ? 'opacity-60' : ''}`}
|
||||
/>
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase"><label htmlFor={addressId}>{t('places.formAddress')}</label></Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
id={addressId}
|
||||
value={form.address}
|
||||
onChange={e => handleChange('address', e.target.value)}
|
||||
placeholder={t('places.formAddressPlaceholder')}
|
||||
className={FIELD_CLS}
|
||||
/>
|
||||
{/* An address typed without coordinates puts nothing on the map (#2837). */}
|
||||
{addressWithoutCoordinates(form) && (
|
||||
<p className="mt-1.5 flex items-start gap-1.5 text-caption text-m-muted">
|
||||
<MapPinOff size={13} strokeWidth={2} aria-hidden="true" className="mt-px flex-none text-[color:var(--m-st-pending)]" />
|
||||
{t('places.noCoordinatesFormHint')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('places.formCategory')}</Eyebrow>
|
||||
<PlCategoryPicker planner={planner} value={form.category_id} onChange={id => handleChange('category_id', id)} />
|
||||
<PlaceIdentityFields planner={planner} form={form} onChange={handleChange}
|
||||
nameId={nameId} addressId={addressId} resolvingPick={resolvingPick} />
|
||||
|
||||
{/* Times live per day-assignment, only editable when one is in context (#2163). */}
|
||||
{sheetPlace && sheetAssignmentId && (
|
||||
@@ -407,54 +381,10 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('places.formWebsite')}</Eyebrow>
|
||||
<label className={AMOUNT_FIELD_CLS}>
|
||||
<Globe size={14} strokeWidth={2} aria-hidden="true" className="flex-none text-m-faint" />
|
||||
<input
|
||||
type="url"
|
||||
dir="ltr"
|
||||
value={form.website}
|
||||
onChange={e => handleChange('website', e.target.value)}
|
||||
placeholder="https://"
|
||||
aria-label={t('places.formWebsite')}
|
||||
className="min-w-0 flex-1 bg-transparent font-[inherit] font-medium text-m-ink outline-none placeholder:text-m-faint"
|
||||
style={fs(13.5, 'body')}
|
||||
/>
|
||||
</label>
|
||||
<PlaceContactAndCoordinates form={form} onChange={handleChange} onCoordinatePaste={handleCoordPaste}
|
||||
detailsHours={detailsHours} t={t} locale={locale} />
|
||||
|
||||
<PlContactFields
|
||||
phone={form.phone ?? ''}
|
||||
email={form.email ?? ''}
|
||||
openingHours={form.opening_hours ?? ''}
|
||||
suggestedHours={detailsHours}
|
||||
onChange={(field, value, origin) => handleChange(field, value, origin)}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<div className="mt-2 flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
value={form.lat}
|
||||
onChange={e => handleChange('lat', e.target.value.replace(/[^0-9.-]/g, ''))}
|
||||
onPaste={handleCoordPaste}
|
||||
aria-label={t('places.formLatLabel')}
|
||||
placeholder={t('places.formLatLabel')}
|
||||
className={`${FIELD_CLS} flex-1 tabular-nums`}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
value={form.lng}
|
||||
onChange={e => handleChange('lng', e.target.value.replace(/[^0-9.-]/g, ''))}
|
||||
aria-label={t('places.formLngLabel')}
|
||||
placeholder={t('places.formLngLabel')}
|
||||
className={`${FIELD_CLS} flex-1 tabular-nums`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{placesEnrichEnabled && (
|
||||
{placesEnrichEnabled ? (
|
||||
<div className="mt-3">
|
||||
<PlaceDetailsColumn
|
||||
selection={detailsSelection}
|
||||
@@ -472,12 +402,7 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{!placesEnrichEnabled && (
|
||||
<div className="mt-3">
|
||||
<PlaceImageSection image={image} onPickUrl={pickImage} mobile t={t} />
|
||||
</div>
|
||||
)}
|
||||
) : <PlaceImageSection image={image} onPickUrl={pickImage} mobile t={t} />}
|
||||
|
||||
{/* COSTS — same block, same flow as the booking sheet (#1298) */}
|
||||
{isBudgetEnabled && (
|
||||
@@ -508,3 +433,110 @@ export default function MPlaceEditSheet({ planner, onOpenExpense }: MPlaceEditSh
|
||||
</MSheet>
|
||||
)
|
||||
}
|
||||
|
||||
type ChangePlaceField = ReturnType<typeof usePlaceForm>['handleChange']
|
||||
|
||||
function PlaceIdentityFields({ planner, form, onChange, nameId, addressId, resolvingPick }: {
|
||||
planner: TripPlanner
|
||||
form: PlaceFormData
|
||||
onChange: ChangePlaceField
|
||||
nameId: string
|
||||
addressId: string
|
||||
resolvingPick: boolean
|
||||
}) {
|
||||
const { t } = planner
|
||||
return (
|
||||
<>
|
||||
<Eyebrow className="mb-1.5"><label htmlFor={nameId}>{t('places.formName')} *</label></Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
id={nameId}
|
||||
aria-required="true"
|
||||
value={form.name}
|
||||
onChange={e => onChange('name', e.target.value)}
|
||||
placeholder={t('places.formNamePlaceholder')}
|
||||
className={`${FIELD_CLS} ${resolvingPick ? 'opacity-60' : ''}`}
|
||||
/>
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase"><label htmlFor={addressId}>{t('places.formAddress')}</label></Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
id={addressId}
|
||||
value={form.address}
|
||||
onChange={e => onChange('address', e.target.value)}
|
||||
placeholder={t('places.formAddressPlaceholder')}
|
||||
className={FIELD_CLS}
|
||||
/>
|
||||
{/* An address typed without coordinates puts nothing on the map (#2837). */}
|
||||
{addressWithoutCoordinates(form) && (
|
||||
<p className="mt-1.5 flex items-start gap-1.5 text-caption text-m-muted">
|
||||
<MapPinOff size={13} strokeWidth={2} aria-hidden="true" className="mt-px flex-none text-[color:var(--m-st-pending)]" />
|
||||
{t('places.noCoordinatesFormHint')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('places.formCategory')}</Eyebrow>
|
||||
<PlCategoryPicker planner={planner} value={form.category_id} onChange={id => onChange('category_id', id)} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function PlaceContactAndCoordinates({ form, onChange, onCoordinatePaste, detailsHours, t, locale }: {
|
||||
form: PlaceFormData
|
||||
onChange: ChangePlaceField
|
||||
onCoordinatePaste: (event: ClipboardEvent<HTMLInputElement>) => void
|
||||
detailsHours: PlaceOpeningHours | null
|
||||
t: TripPlanner['t']
|
||||
locale: string
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('places.formWebsite')}</Eyebrow>
|
||||
<label className={AMOUNT_FIELD_CLS}>
|
||||
<Globe size={14} strokeWidth={2} aria-hidden="true" className="flex-none text-m-faint" />
|
||||
<input
|
||||
type="url"
|
||||
dir="ltr"
|
||||
value={form.website}
|
||||
onChange={e => onChange('website', e.target.value)}
|
||||
placeholder="https://"
|
||||
aria-label={t('places.formWebsite')}
|
||||
className="min-w-0 flex-1 bg-transparent font-[inherit] font-medium text-m-ink outline-none placeholder:text-m-faint"
|
||||
style={fs(13.5, 'body')}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<PlContactFields
|
||||
phone={form.phone ?? ''}
|
||||
email={form.email ?? ''}
|
||||
openingHours={form.opening_hours ?? ''}
|
||||
suggestedHours={detailsHours}
|
||||
onChange={(field, value, origin) => onChange(field, value, origin)}
|
||||
locale={locale}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<div className="mt-2 flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
value={form.lat}
|
||||
onChange={e => onChange('lat', e.target.value.replace(/[^0-9.-]/g, ''))}
|
||||
onPaste={onCoordinatePaste}
|
||||
aria-label={t('places.formLatLabel')}
|
||||
placeholder={t('places.formLatLabel')}
|
||||
className={`${FIELD_CLS} flex-1 tabular-nums`}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
value={form.lng}
|
||||
onChange={e => onChange('lng', e.target.value.replace(/[^0-9.-]/g, ''))}
|
||||
aria-label={t('places.formLngLabel')}
|
||||
placeholder={t('places.formLngLabel')}
|
||||
className={`${FIELD_CLS} flex-1 tabular-nums`}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Calendar, CalendarPlus, Check, ChevronDown, ChevronRight, Copy } from 'lucide-react';
|
||||
import { useSubscribeLinks } from '../../../../components/Planner/SubscribeLinks';
|
||||
import { useSubscribeLinks } from '../../../../components/Planner/useSubscribeLinks';
|
||||
import { useTranslation } from '../../../../i18n';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
import { FormSheetSection, SELECT_FIELD_CLS } from './PlSheetChrome';
|
||||
|
||||
@@ -347,52 +347,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Transit itinerary (#1065): one row per leg ── */}
|
||||
{transitLegs.length > 0 && (
|
||||
<div className="mt-4 flex flex-col gap-2 rounded-[14px] bg-m-ic px-3 py-2.5">
|
||||
{transitLegs.map((leg, i) => {
|
||||
const isWalk = leg.mode === 'WALK'
|
||||
const mins = leg.duration ? Math.round(leg.duration / 60) : null
|
||||
return (
|
||||
<div key={i} className="flex items-start gap-2">
|
||||
{isWalk ? (
|
||||
<Footprints size={12} strokeWidth={2} className="mt-[2px] flex-none text-m-faint" />
|
||||
) : (
|
||||
<TransitLineBadge
|
||||
label={leg.line || leg.mode}
|
||||
besideText
|
||||
className="flex-none rounded-[5px] px-[6px] py-px text-[0.625rem] font-bold"
|
||||
style={{
|
||||
background: leg.line_color || 'var(--m-ic)',
|
||||
color: leg.line_color ? (leg.line_text_color || '#fff') : 'var(--m-ink)',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-1 text-[0.71875rem] font-medium">
|
||||
{isWalk ? (
|
||||
<span className="text-m-muted">{t('transit.walkTo', { name: leg.to?.name || '' })}</span>
|
||||
) : (
|
||||
<>
|
||||
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.from?.name}</span>
|
||||
<ArrowRight size={10} strokeWidth={2} className="flex-none text-m-faint" />
|
||||
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.to?.name}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-px font-geist text-[0.625rem] text-m-faint">
|
||||
{[
|
||||
leg.from?.time && !isWalk ? `${leg.from.time}${leg.to?.time ? ` – ${leg.to.time}` : ''}` : null,
|
||||
mins ? t('transit.min', { count: mins }) : null,
|
||||
!isWalk && leg.stops ? t('transit.stops', { count: leg.stops }) : null,
|
||||
].filter(Boolean).join(' · ')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{transitLegs.length > 0 && <TransportItinerary transitLegs={transitLegs} t={t} />}
|
||||
|
||||
{/* ── Per-segment booking codes ── */}
|
||||
{legCodes.length > 0 && (
|
||||
@@ -479,6 +434,57 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
)
|
||||
}
|
||||
|
||||
function TransportItinerary({ transitLegs, t }: {
|
||||
transitLegs: TransitLeg[]
|
||||
t: ReturnType<typeof useTranslation>['t']
|
||||
}) {
|
||||
return (
|
||||
<div className="mt-4 flex flex-col gap-2 rounded-[14px] bg-m-ic px-3 py-2.5">
|
||||
{transitLegs.map((leg, i) => {
|
||||
const isWalk = leg.mode === 'WALK'
|
||||
const mins = leg.duration ? Math.round(leg.duration / 60) : null
|
||||
return (
|
||||
<div key={i} className="flex items-start gap-2">
|
||||
{isWalk ? (
|
||||
<Footprints size={12} strokeWidth={2} className="mt-[2px] flex-none text-m-faint" />
|
||||
) : (
|
||||
<TransitLineBadge
|
||||
label={leg.line || leg.mode}
|
||||
besideText
|
||||
className="flex-none rounded-[5px] px-[6px] py-px text-[0.625rem] font-bold"
|
||||
style={{
|
||||
background: leg.line_color || 'var(--m-ic)',
|
||||
color: leg.line_color ? (leg.line_text_color || '#fff') : 'var(--m-ink)',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-1 text-[0.71875rem] font-medium">
|
||||
{isWalk ? (
|
||||
<span className="text-m-muted">{t('transit.walkTo', { name: leg.to?.name || '' })}</span>
|
||||
) : (
|
||||
<>
|
||||
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.from?.name}</span>
|
||||
<ArrowRight size={10} strokeWidth={2} className="flex-none text-m-faint" />
|
||||
<span dir="auto" className="min-w-0 break-words [overflow-wrap:anywhere]">{leg.to?.name}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-px font-geist text-[0.625rem] text-m-faint">
|
||||
{[
|
||||
leg.from?.time && !isWalk ? `${leg.from.time}${leg.to?.time ? ` – ${leg.to.time}` : ''}` : null,
|
||||
mins ? t('transit.min', { count: mins }) : null,
|
||||
!isWalk && leg.stops ? t('transit.stops', { count: leg.stops }) : null,
|
||||
].filter(Boolean).join(' · ')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ScheduleTime({ time, date, place, airport, alignEnd }: {
|
||||
time: string
|
||||
date: string | null
|
||||
|
||||
@@ -66,56 +66,57 @@ export default function MTripOfflinePage({
|
||||
? t('settings.offline.notice.offline')
|
||||
: undefined;
|
||||
|
||||
const renderDownload = () => (
|
||||
<FormSheetSection>
|
||||
<div className="space-y-3">
|
||||
{subtitle && (
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="grid size-9 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted" aria-hidden>
|
||||
{saved ? <CloudCheck size={18} /> : <CloudDownload size={18} />}
|
||||
</span>
|
||||
<p className="min-w-0 text-control font-medium text-m-ink" role="status">
|
||||
{subtitle}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{canDownload && (
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-h-11 w-full items-center justify-center gap-2 rounded-full bg-m-act px-3 py-2 text-control font-semibold text-m-actfg disabled:opacity-40"
|
||||
disabled={busy || offline}
|
||||
onClick={() => void save()}
|
||||
>
|
||||
{busy || saved ? (
|
||||
<RefreshCw size={16} className={busy ? 'animate-spin' : undefined} aria-hidden />
|
||||
) : (
|
||||
<Download size={16} aria-hidden />
|
||||
)}
|
||||
{t(
|
||||
busy
|
||||
? 'settings.offline.prepare.running'
|
||||
: saved
|
||||
? 'settings.offline.resync'
|
||||
: 'settings.offline.prepare.button'
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{busy && phase !== 'done' && (
|
||||
<p role="status" className="text-caption text-m-muted">
|
||||
{t(`settings.offline.prepare.phase.${phase}`)}
|
||||
</p>
|
||||
)}
|
||||
{message && (
|
||||
<p role="status" className="text-caption text-m-muted">
|
||||
{message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<FormSheetSection>
|
||||
<div className="space-y-3">
|
||||
{subtitle && (
|
||||
<div className="flex items-center gap-3">
|
||||
<span
|
||||
className="grid size-9 flex-none place-items-center rounded-lg bg-m-sheetop text-m-muted"
|
||||
aria-hidden
|
||||
>
|
||||
{saved ? <CloudCheck size={18} /> : <CloudDownload size={18} />}
|
||||
</span>
|
||||
<p className="min-w-0 text-control font-medium text-m-ink" role="status">
|
||||
{subtitle}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{canDownload && (
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-h-11 w-full items-center justify-center gap-2 rounded-full bg-m-act px-3 py-2 text-control font-semibold text-m-actfg disabled:opacity-40"
|
||||
disabled={busy || offline}
|
||||
onClick={() => void save()}
|
||||
>
|
||||
{busy || saved ? (
|
||||
<RefreshCw size={16} className={busy ? 'animate-spin' : undefined} aria-hidden />
|
||||
) : (
|
||||
<Download size={16} aria-hidden />
|
||||
)}
|
||||
{t(
|
||||
busy
|
||||
? 'settings.offline.prepare.running'
|
||||
: saved
|
||||
? 'settings.offline.resync'
|
||||
: 'settings.offline.prepare.button'
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
{busy && phase !== 'done' && (
|
||||
<p role="status" className="text-caption text-m-muted">
|
||||
{t(`settings.offline.prepare.phase.${phase}`)}
|
||||
</p>
|
||||
)}
|
||||
{message && (
|
||||
<p role="status" className="text-caption text-m-muted">
|
||||
{message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</FormSheetSection>
|
||||
{renderDownload()}
|
||||
<div className="overflow-hidden rounded-[14px] border border-m-rowbr bg-m-sheetop">
|
||||
<MMenuRow icon={Settings2} label={t('settings.title')} onClick={onOpenSettings} />
|
||||
</div>
|
||||
|
||||
@@ -559,6 +559,103 @@ export default function MTripSettingsSheet({
|
||||
};
|
||||
const people = m.realMembers.length + m.guests.length;
|
||||
|
||||
const renderSettingsMenu = () => (
|
||||
<>
|
||||
{page === null && (
|
||||
<nav
|
||||
aria-label={t('trip.settings.title')}
|
||||
className="flex flex-col divide-y divide-m-rowbr rounded-[14px] bg-m-ic px-1.5"
|
||||
>
|
||||
{onEdit && (
|
||||
<AreaRow icon={<Pencil size={16} strokeWidth={2} />} label={t('dashboard.editTrip')} onOpen={onEdit} />
|
||||
)}
|
||||
<AreaRow
|
||||
icon={<Users size={16} strokeWidth={2} />}
|
||||
label={pageTitle.people}
|
||||
value={m.loading ? undefined : String(people)}
|
||||
onOpen={() => setPage('people')}
|
||||
/>
|
||||
{m.canManageShare && (
|
||||
<AreaRow
|
||||
icon={<Link2 size={16} strokeWidth={2} />}
|
||||
label={pageTitle.sharing}
|
||||
onOpen={() => setPage('sharing')}
|
||||
/>
|
||||
)}
|
||||
{journalVisible && (
|
||||
<AreaRow
|
||||
icon={<LinkedJournalIcon size={16} />}
|
||||
label={pageTitle.journal}
|
||||
onOpen={() => setPage('journal')}
|
||||
/>
|
||||
)}
|
||||
{m.isCurrentOwner && (
|
||||
<AreaRow
|
||||
icon={<Puzzle size={16} strokeWidth={2} />}
|
||||
label={pageTitle.addons}
|
||||
onOpen={() => setPage('addons')}
|
||||
/>
|
||||
)}
|
||||
{costsMode.offered && (
|
||||
<AreaRow
|
||||
icon={<Wallet size={16} strokeWidth={2} />}
|
||||
label={pageTitle.costs}
|
||||
onOpen={() => setPage('costs')}
|
||||
/>
|
||||
)}
|
||||
<AreaRow
|
||||
icon={<CloudDownload size={16} strokeWidth={2} />}
|
||||
label={pageTitle.offline}
|
||||
onOpen={() => setPage('offline')}
|
||||
/>
|
||||
{onExport && (
|
||||
<AreaRow icon={<FileDown size={16} strokeWidth={2} />} label={t('mobileTrip.export')} onOpen={onExport} />
|
||||
)}
|
||||
</nav>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const renderSettingsPage = () => (
|
||||
<>
|
||||
{page === 'people' && (
|
||||
<>
|
||||
<AccessSection m={m} ask={setQuestion} />
|
||||
<GuestsSection m={m} ask={setQuestion} />
|
||||
</>
|
||||
)}
|
||||
{page === 'sharing' && m.canManageShare && (
|
||||
<>
|
||||
<ShareLinkSection tripId={tripId} />
|
||||
<InviteLinkSection tripId={tripId} />
|
||||
</>
|
||||
)}
|
||||
{page === 'journal' && (
|
||||
<TripJournalLinkSection
|
||||
tripId={tripId}
|
||||
requestUnlink={(confirm) => setQuestion({ kind: 'unlinkJournal', confirm })}
|
||||
/>
|
||||
)}
|
||||
{page === 'addons' && m.isCurrentOwner && <AddonsSection tripId={tripId} />}
|
||||
{page === 'costs' && costsMode.offered && (
|
||||
<div className="space-y-2 rounded-[14px] bg-m-ic p-3">
|
||||
<div className="flex min-h-11 items-center gap-3">
|
||||
<span className="min-w-0 flex-1 text-control font-semibold">{t('costs.mode.label')}</span>
|
||||
<MToggle
|
||||
checked={costsMode.splitting}
|
||||
onChange={(value) => void costsMode.setSplitting(value)}
|
||||
ariaLabel={t('costs.mode.label')}
|
||||
disabled={costsMode.saving}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-caption text-m-muted">
|
||||
{costsMode.splitting ? t('costs.mode.hintSplit') : t('costs.mode.hintTotals')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MSheet
|
||||
@@ -585,97 +682,8 @@ export default function MTripSettingsSheet({
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
<FormSheetBody className="space-y-4">
|
||||
{page === null && (
|
||||
<nav
|
||||
aria-label={t('trip.settings.title')}
|
||||
className="flex flex-col divide-y divide-m-rowbr rounded-[14px] bg-m-ic px-1.5"
|
||||
>
|
||||
{onEdit && (
|
||||
<AreaRow icon={<Pencil size={16} strokeWidth={2} />} label={t('dashboard.editTrip')} onOpen={onEdit} />
|
||||
)}
|
||||
<AreaRow
|
||||
icon={<Users size={16} strokeWidth={2} />}
|
||||
label={pageTitle.people}
|
||||
value={m.loading ? undefined : String(people)}
|
||||
onOpen={() => setPage('people')}
|
||||
/>
|
||||
{m.canManageShare && (
|
||||
<AreaRow
|
||||
icon={<Link2 size={16} strokeWidth={2} />}
|
||||
label={pageTitle.sharing}
|
||||
onOpen={() => setPage('sharing')}
|
||||
/>
|
||||
)}
|
||||
{journalVisible && (
|
||||
<AreaRow
|
||||
icon={<LinkedJournalIcon size={16} />}
|
||||
label={pageTitle.journal}
|
||||
onOpen={() => setPage('journal')}
|
||||
/>
|
||||
)}
|
||||
{m.isCurrentOwner && (
|
||||
<AreaRow
|
||||
icon={<Puzzle size={16} strokeWidth={2} />}
|
||||
label={pageTitle.addons}
|
||||
onOpen={() => setPage('addons')}
|
||||
/>
|
||||
)}
|
||||
{costsMode.offered && (
|
||||
<AreaRow
|
||||
icon={<Wallet size={16} strokeWidth={2} />}
|
||||
label={pageTitle.costs}
|
||||
onOpen={() => setPage('costs')}
|
||||
/>
|
||||
)}
|
||||
<AreaRow
|
||||
icon={<CloudDownload size={16} strokeWidth={2} />}
|
||||
label={pageTitle.offline}
|
||||
onOpen={() => setPage('offline')}
|
||||
/>
|
||||
{onExport && (
|
||||
<AreaRow
|
||||
icon={<FileDown size={16} strokeWidth={2} />}
|
||||
label={t('mobileTrip.export')}
|
||||
onOpen={onExport}
|
||||
/>
|
||||
)}
|
||||
</nav>
|
||||
)}
|
||||
{page === 'people' && (
|
||||
<>
|
||||
<AccessSection m={m} ask={setQuestion} />
|
||||
<GuestsSection m={m} ask={setQuestion} />
|
||||
</>
|
||||
)}
|
||||
{page === 'sharing' && m.canManageShare && (
|
||||
<>
|
||||
<ShareLinkSection tripId={tripId} />
|
||||
<InviteLinkSection tripId={tripId} />
|
||||
</>
|
||||
)}
|
||||
{page === 'journal' && (
|
||||
<TripJournalLinkSection
|
||||
tripId={tripId}
|
||||
requestUnlink={(confirm) => setQuestion({ kind: 'unlinkJournal', confirm })}
|
||||
/>
|
||||
)}
|
||||
{page === 'addons' && m.isCurrentOwner && <AddonsSection tripId={tripId} />}
|
||||
{page === 'costs' && costsMode.offered && (
|
||||
<div className="space-y-2 rounded-[14px] bg-m-ic p-3">
|
||||
<div className="flex min-h-11 items-center gap-3">
|
||||
<span className="min-w-0 flex-1 text-control font-semibold">{t('costs.mode.label')}</span>
|
||||
<MToggle
|
||||
checked={costsMode.splitting}
|
||||
onChange={(value) => void costsMode.setSplitting(value)}
|
||||
ariaLabel={t('costs.mode.label')}
|
||||
disabled={costsMode.saving}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-caption text-m-muted">
|
||||
{costsMode.splitting ? t('costs.mode.hintSplit') : t('costs.mode.hintTotals')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{renderSettingsMenu()}
|
||||
{renderSettingsPage()}
|
||||
<MTripOfflinePage
|
||||
key={tripId}
|
||||
trip={trip}
|
||||
|
||||
@@ -102,6 +102,20 @@ export default function MTripSheets({ planner, shell }: MTripSheetsProps) {
|
||||
tripId, tripCurrency: trip?.currency, receiptExpense: planner.receiptExpense, clearReceiptExpense: planner.clearReceiptExpense,
|
||||
})
|
||||
|
||||
const renderTripSettings = () => (
|
||||
<MTripSettingsSheet
|
||||
open={sheet?.id === 'members'}
|
||||
onClose={shell.closeSheet}
|
||||
tripId={tripId}
|
||||
tripTitle={trip?.title}
|
||||
trip={trip}
|
||||
costsMemberCount={planner.enabledAddons.budget && planner.can('budget_edit', trip) ? planner.tripMembers.length : undefined}
|
||||
onEdit={planner.can('trip_edit', trip) ? () => shell.openSheet('tripedit', 'trip-settings') : undefined}
|
||||
onExport={() => shell.openSheet('export', 'trip-settings')}
|
||||
onMembersChanged={planner.refreshMembers}
|
||||
/>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* ── Mobile sheets (shell.sheet routing + the place selection) ── */}
|
||||
@@ -195,18 +209,7 @@ export default function MTripSheets({ planner, shell }: MTripSheetsProps) {
|
||||
}}
|
||||
onCoverUpdate={applyTripCoverUpdate}
|
||||
/>
|
||||
<MTripSettingsSheet
|
||||
open={sheet?.id === 'members'}
|
||||
onClose={shell.closeSheet}
|
||||
tripId={tripId}
|
||||
tripTitle={trip?.title}
|
||||
trip={trip}
|
||||
costsMemberCount={planner.enabledAddons.budget && planner.can('budget_edit', trip) ? planner.tripMembers.length : undefined}
|
||||
onEdit={planner.can('trip_edit', trip) ? () => shell.openSheet('tripedit', 'trip-settings') : undefined}
|
||||
onExport={() => shell.openSheet('export', 'trip-settings')}
|
||||
onMembersChanged={planner.refreshMembers}
|
||||
/>
|
||||
|
||||
{renderTripSettings()}
|
||||
{/* Delete-place confirm behind handleDeletePlace (the place edit sheet
|
||||
arms the same flag for its own two-tap delete — skip it there).
|
||||
A night booked at the place goes down with it, and with the night
|
||||
|
||||
@@ -335,6 +335,58 @@ function ChatBubbleRow({ msg, own, showHeader, isLastInGroup, marginTop, is12h,
|
||||
const Bubble = canEdit ? 'button' : 'div'
|
||||
const showActions = canEdit && (isLastInGroup || !hasBubble)
|
||||
|
||||
const renderMessageBubble = () => (
|
||||
<>
|
||||
{hasBubble && <Bubble
|
||||
type={canEdit ? 'button' : undefined}
|
||||
aria-label={canEdit ? t('collab.chat.messageOptions') : undefined}
|
||||
aria-describedby={canEdit ? bodyId : undefined}
|
||||
aria-haspopup={canEdit ? 'dialog' : undefined}
|
||||
onPointerDown={onPointerDown}
|
||||
onPointerMove={onPointerMove}
|
||||
onPointerUp={onPointerUp}
|
||||
onPointerCancel={onPointerCancel}
|
||||
onClick={canEdit ? event => {
|
||||
if (event.detail === 0 || (!firedRef.current && !movedRef.current)) onOpenActions()
|
||||
} : undefined}
|
||||
className="max-w-full rounded-2xl text-start"
|
||||
>
|
||||
{bigEmoji ? (
|
||||
<span id={bodyId} className="block py-0.5 text-[2.5rem] leading-tight">{msg.text}</span>
|
||||
) : (
|
||||
<span
|
||||
className={`block px-3 py-2 text-control leading-snug ${
|
||||
own ? 'bg-m-act text-m-actfg' : 'border border-m-rowbr bg-m-sheetop text-m-ink'
|
||||
}`}
|
||||
style={own ? OWN_BUBBLE_RADIUS : OTHER_BUBBLE_RADIUS}
|
||||
>
|
||||
{hasReply && (
|
||||
<span className={`mb-1 block rounded-lg px-2.5 py-1.5 ${own ? 'bg-[color:color-mix(in_srgb,var(--m-actfg)_15%,transparent)]' : 'bg-m-ic'}`}>
|
||||
<bdi className="block text-caption font-semibold opacity-80">{msg.reply_username}</bdi>
|
||||
<bdi dir="auto" className="line-clamp-2 text-caption opacity-90">{msg.reply_text}</bdi>
|
||||
</span>
|
||||
)}
|
||||
<span id={bodyId} dir="auto" className="whitespace-pre-wrap [overflow-wrap:anywhere]">{msg.text}</span>
|
||||
</span>
|
||||
)}
|
||||
</Bubble>}
|
||||
</>
|
||||
)
|
||||
|
||||
const renderMessageActions = () => (
|
||||
(isLastInGroup || showActions) && (
|
||||
<div className="flex items-center gap-1 px-1 text-caption text-m-muted">
|
||||
{isLastInGroup && <time dateTime={msg.created_at}>{formatChatClockTime(msg.created_at, is12h)}</time>}
|
||||
{showActions && (
|
||||
<button type="button" aria-label={t('files.menu')} aria-haspopup="dialog" onClick={onOpenActions}
|
||||
className="grid size-8 place-items-center rounded-full text-m-muted active:bg-m-ic">
|
||||
<MoreHorizontal size={16} aria-hidden />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex gap-2 ${own ? 'flex-row-reverse' : 'flex-row'}`}
|
||||
@@ -364,40 +416,7 @@ function ChatBubbleRow({ msg, own, showHeader, isLastInGroup, marginTop, is12h,
|
||||
</span>
|
||||
)}
|
||||
|
||||
{hasBubble && <Bubble
|
||||
type={canEdit ? 'button' : undefined}
|
||||
aria-label={canEdit ? t('collab.chat.messageOptions') : undefined}
|
||||
aria-describedby={canEdit ? bodyId : undefined}
|
||||
aria-haspopup={canEdit ? 'dialog' : undefined}
|
||||
onPointerDown={onPointerDown}
|
||||
onPointerMove={onPointerMove}
|
||||
onPointerUp={onPointerUp}
|
||||
onPointerCancel={onPointerCancel}
|
||||
onClick={canEdit ? event => {
|
||||
if (event.detail === 0 || (!firedRef.current && !movedRef.current)) onOpenActions()
|
||||
} : undefined}
|
||||
className="max-w-full rounded-2xl text-start"
|
||||
>
|
||||
{bigEmoji ? (
|
||||
<span id={bodyId} className="block py-0.5 text-[2.5rem] leading-tight">{msg.text}</span>
|
||||
) : (
|
||||
<span
|
||||
className={`block px-3 py-2 text-control leading-snug ${
|
||||
own ? 'bg-m-act text-m-actfg' : 'border border-m-rowbr bg-m-sheetop text-m-ink'
|
||||
}`}
|
||||
style={own ? OWN_BUBBLE_RADIUS : OTHER_BUBBLE_RADIUS}
|
||||
>
|
||||
{hasReply && (
|
||||
<span className={`mb-1 block rounded-lg px-2.5 py-1.5 ${own ? 'bg-[color:color-mix(in_srgb,var(--m-actfg)_15%,transparent)]' : 'bg-m-ic'}`}>
|
||||
<bdi className="block text-caption font-semibold opacity-80">{msg.reply_username}</bdi>
|
||||
<bdi dir="auto" className="line-clamp-2 text-caption opacity-90">{msg.reply_text}</bdi>
|
||||
</span>
|
||||
)}
|
||||
<span id={bodyId} dir="auto" className="whitespace-pre-wrap [overflow-wrap:anywhere]">{msg.text}</span>
|
||||
</span>
|
||||
)}
|
||||
</Bubble>}
|
||||
|
||||
{renderMessageBubble()}
|
||||
{/* Below the bubble rather than in it: the bubble is the long-press target,
|
||||
and an image is tapped to be seen large (MImageViewer). */}
|
||||
<ChatImages
|
||||
@@ -423,17 +442,7 @@ function ChatBubbleRow({ msg, own, showHeader, isLastInGroup, marginTop, is12h,
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(isLastInGroup || showActions) && (
|
||||
<div className="flex items-center gap-1 px-1 text-caption text-m-muted">
|
||||
{isLastInGroup && <time dateTime={msg.created_at}>{formatChatClockTime(msg.created_at, is12h)}</time>}
|
||||
{showActions && (
|
||||
<button type="button" aria-label={t('files.menu')} aria-haspopup="dialog" onClick={onOpenActions}
|
||||
className="grid size-8 place-items-center rounded-full text-m-muted active:bg-m-ic">
|
||||
<MoreHorizontal size={16} aria-hidden />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{renderMessageActions()}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import { sanitizedMarkdownPlugins, sanitizedMarkdownComponents } from '../../../../components/shared/markdownSanitize'
|
||||
import { Check, ExternalLink, FileText, MoreHorizontal, Paperclip, Pencil, Pin, PinOff, Plus, StickyNote, Tag, Trash2, X } from 'lucide-react'
|
||||
import { Check, ExternalLink, FileText, MoreHorizontal, Paperclip, Pencil, Pin, PinOff, StickyNote, Tag, Trash2, X } from 'lucide-react'
|
||||
import MDancingTrek from '../../../components/MDancingTrek'
|
||||
import MChipStrip from '../../../components/MChipStrip'
|
||||
import MContextMenu from '../../../components/MContextMenu'
|
||||
|
||||
@@ -171,7 +171,7 @@ export default function MFilesTab({ planner, shell }: MTabScreenProps) {
|
||||
const filtersLabel = t('places.filters')
|
||||
const activeFilter = filter === 'all' ? undefined : FILE_FILTERS.find(f => f.id === filter)
|
||||
|
||||
const body = (
|
||||
const renderBody = () => (
|
||||
<div onPaste={onPaste} tabIndex={-1} className="flex min-h-full flex-col">
|
||||
<input ref={inputRef} type="file" multiple className="hidden" onChange={onPickFiles} />
|
||||
|
||||
@@ -261,7 +261,7 @@ export default function MFilesTab({ planner, shell }: MTabScreenProps) {
|
||||
</div>
|
||||
)
|
||||
|
||||
const sheets = (
|
||||
const renderSheets = () => (
|
||||
<>
|
||||
<MSheet open={filtersOpen && !isEmpty} onClose={() => setFiltersOpen(false)} variant="bottom" ariaLabel={filtersLabel} form>
|
||||
<FormSheetHeader icon={SlidersHorizontal} title={filtersLabel} closeLabel={t('common.close')} onClose={() => setFiltersOpen(false)} />
|
||||
@@ -322,7 +322,7 @@ export default function MFilesTab({ planner, shell }: MTabScreenProps) {
|
||||
return (
|
||||
<div className="flex h-full">
|
||||
<div className="min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden pb-[calc(var(--bottom-nav-h,84px)+22px)] pe-3 ps-6 pt-[calc(var(--m-safe-top,12px)+58px)]">
|
||||
{body}
|
||||
{renderBody()}
|
||||
</div>
|
||||
{picked && <aside
|
||||
aria-label={t('common.preview')}
|
||||
@@ -337,14 +337,14 @@ export default function MFilesTab({ planner, shell }: MTabScreenProps) {
|
||||
onMenu={() => setMenuFileId(picked.id)}
|
||||
/>
|
||||
</aside>}
|
||||
{sheets}
|
||||
{renderSheets()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<TabScroller wide={wide ? 'full' : 'readable'}>
|
||||
{body}
|
||||
{sheets}
|
||||
{renderBody()}
|
||||
{renderSheets()}
|
||||
</TabScroller>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -97,6 +97,20 @@ export default function MTodoListTab({ planner }: { planner: TripPlanner }) {
|
||||
</>
|
||||
)
|
||||
|
||||
const renderEmptyTasks = () => (
|
||||
<div className="flex min-h-[60vh] flex-col items-center justify-center px-8 py-10 text-center">
|
||||
<MDancingTrek scene="tasks" className="mb-2" />
|
||||
<p className="text-body font-medium text-m-muted">{t('todo.empty')}</p>
|
||||
{canEdit && (
|
||||
<button type="button" onClick={openCreate}
|
||||
className="mt-4 flex min-h-11 items-center gap-2 rounded-full bg-m-act px-4 text-body font-semibold text-m-actfg">
|
||||
<Plus size={17} aria-hidden />
|
||||
{t('todo.newItem')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
const progressCard = items.length > 0 && (
|
||||
// The packing list's card: how far along, a slim bar, the rest and the add.
|
||||
<div className="flex items-center gap-[10px] rounded-2xl border border-m-rowbr bg-m-sheetop px-[14px] py-[12px]">
|
||||
@@ -187,17 +201,7 @@ export default function MTodoListTab({ planner }: { planner: TripPlanner }) {
|
||||
|
||||
{/* ── Task cards (spec §4.7) ── */}
|
||||
{items.length === 0 ? (
|
||||
<div className="flex min-h-[60vh] flex-col items-center justify-center px-8 py-10 text-center">
|
||||
<MDancingTrek scene="tasks" className="mb-2" />
|
||||
<p className="text-body font-medium text-m-muted">{t('todo.empty')}</p>
|
||||
{canEdit && (
|
||||
<button type="button" onClick={openCreate}
|
||||
className="mt-4 flex min-h-11 items-center gap-2 rounded-full bg-m-act px-4 text-body font-semibold text-m-actfg">
|
||||
<Plus size={17} aria-hidden />
|
||||
{t('todo.newItem')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
renderEmptyTasks()
|
||||
) : rows.length === 0 ? (
|
||||
<div className="px-[30px] py-[26px] text-center font-geist text-[0.6875rem] leading-relaxed text-m-faint">
|
||||
{t('todo.emptyFiltered')}
|
||||
|
||||
@@ -108,9 +108,7 @@ export function useRoadtripStopEdits(options: RoadtripStopEditsOptions) {
|
||||
// reservation and the expense the server keeps against it. The popup stays open
|
||||
// behind the question, so a no leaves the traveller exactly where they were.
|
||||
if (accommodationId && !releaseStay) {
|
||||
const stay = tripAccommodations.find(s => s.id === accommodationId)
|
||||
const booking = reservations.find(r => r.accommodation_id != null && Number(r.accommodation_id) === accommodationId)?.title
|
||||
?? stay?.reservation_title ?? null
|
||||
const booking = stayBookingTitle(tripAccommodations, reservations, accommodationId)
|
||||
setStayRelease({ stop: { stopType, dwellMinutes }, name: poi.name, booking })
|
||||
return
|
||||
}
|
||||
@@ -494,3 +492,9 @@ export function useRoadtripStopEdits(options: RoadtripStopEditsOptions) {
|
||||
}
|
||||
|
||||
export type RoadtripStopEdits = ReturnType<typeof useRoadtripStopEdits>
|
||||
|
||||
function stayBookingTitle(stays: RoadtripStopEditsOptions['tripAccommodations'], reservations: RoadtripStopEditsOptions['reservations'], accommodationId: number) {
|
||||
const stay = stays.find(s => s.id === accommodationId)
|
||||
const booking = reservations.find(r => r.accommodation_id != null && Number(r.accommodation_id) === accommodationId)
|
||||
return booking?.title ?? stay?.reservation_title ?? null
|
||||
}
|
||||
|
||||
@@ -403,13 +403,7 @@ export const tripSyncManager = {
|
||||
if (skipped) return skipped
|
||||
_syncing = true
|
||||
try {
|
||||
let candidates: Trip[]
|
||||
if (selectedTrip) {
|
||||
candidates = [selectedTrip]
|
||||
} else {
|
||||
const [{ trips }, archived] = await Promise.all([tripsApi.list() as Promise<{ trips: Trip[] }>, archivedTrips()])
|
||||
candidates = await reconcileTrips(trips, archived)
|
||||
}
|
||||
const candidates = await offlineTripCandidates(selectedTrip)
|
||||
const total = candidates.length
|
||||
const prepared: Trip[] = []
|
||||
|
||||
@@ -419,12 +413,7 @@ export const tripSyncManager = {
|
||||
if (!isAuthed()) return { status: 'skipped', reason: 'signed-out' }
|
||||
onProgress?.({ phase: 'trips', current: ++i, total, label: trip.title })
|
||||
try {
|
||||
await syncTrip(trip.id)
|
||||
if (!isAuthed()) return { status: 'skipped', reason: 'signed-out' }
|
||||
if (selectedTrip) {
|
||||
setTripOfflineEnabled(trip.id, true)
|
||||
setTripPinned(trip.id, true)
|
||||
}
|
||||
if (!(await syncTripForOffline(trip, Boolean(selectedTrip)))) return { status: 'skipped', reason: 'signed-out' }
|
||||
prepared.push(trip)
|
||||
} catch (err) {
|
||||
if (selectedTrip) throw err
|
||||
@@ -483,3 +472,19 @@ export const tripSyncManager = {
|
||||
_syncing = false
|
||||
},
|
||||
}
|
||||
|
||||
async function offlineTripCandidates(selectedTrip?: Trip) {
|
||||
if (selectedTrip) return [selectedTrip]
|
||||
const [{ trips }, archived] = await Promise.all([tripsApi.list() as Promise<{ trips: Trip[] }>, archivedTrips()])
|
||||
return reconcileTrips(trips, archived)
|
||||
}
|
||||
|
||||
async function syncTripForOffline(trip: Trip, pin: boolean) {
|
||||
await syncTrip(trip.id)
|
||||
if (!isAuthed()) return false
|
||||
if (pin) {
|
||||
setTripOfflineEnabled(trip.id, true)
|
||||
setTripPinned(trip.id, true)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -214,11 +214,16 @@ describe('MSheet', () => {
|
||||
<span>Sheet content</span>
|
||||
</MSheet>,
|
||||
);
|
||||
const strip = screen.getByRole('dialog').querySelector('.cursor-grab') as HTMLElement;
|
||||
const dialog = screen.getByRole('dialog');
|
||||
Object.defineProperty(dialog, 'offsetHeight', { configurable: true, value: 400 });
|
||||
const strip = dialog.querySelector('.cursor-grab') as HTMLElement;
|
||||
|
||||
fireEvent.pointerDown(strip, { pointerId: 1, clientY: 100 });
|
||||
fireEvent.pointerMove(strip, { pointerId: 1, clientY: 130 });
|
||||
fireEvent.pointerUp(strip, { pointerId: 1, clientY: 130 });
|
||||
const down = createEvent.pointerDown(strip, { pointerId: 1, clientY: 100 });
|
||||
const move = createEvent.pointerMove(strip, { pointerId: 1, clientY: 130 });
|
||||
const up = createEvent.pointerUp(strip, { pointerId: 1, clientY: 130 });
|
||||
fireEvent(strip, Object.defineProperty(down, 'timeStamp', { value: 100 }));
|
||||
fireEvent(strip, Object.defineProperty(move, 'timeStamp', { value: 120 }));
|
||||
fireEvent(strip, Object.defineProperty(up, 'timeStamp', { value: 130 }));
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -464,7 +464,9 @@ describe('MCollabChat', () => {
|
||||
|
||||
doubleTap(bubble(0))
|
||||
expect(screen.queryByRole('button', { name: 'common.delete' })).not.toBeInTheDocument()
|
||||
fireEvent.click(screen.getByRole('dialog').closest('[role="presentation"]')!)
|
||||
const backdrop = screen.getByRole('dialog').closest('[role="presentation"]')
|
||||
if (!backdrop) throw new Error('Expected the dialog backdrop')
|
||||
fireEvent.click(backdrop)
|
||||
|
||||
doubleTap(bubble(1))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'common.delete' }))
|
||||
|
||||
Reference in New Issue
Block a user