mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cd22b91ff | |||
| 27b736a819 | |||
| 9cfad1d0d2 | |||
| 87c025024c | |||
| c32c17ca17 |
@@ -28,7 +28,7 @@ export default function AddonSetupDialog({
|
||||
icon: ReactNode;
|
||||
eyebrow: string;
|
||||
title: string;
|
||||
sub: string;
|
||||
sub?: string;
|
||||
onClose: () => void;
|
||||
/** A confirmation stacked on top holds the dialog while it is open. */
|
||||
blocked?: boolean;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import {
|
||||
import { Wrench, Link, Info,
|
||||
Blocks, AlertTriangle, RefreshCw, Trash2, Download, Bug, ShieldCheck, UploadCloud,
|
||||
ArrowUpCircle, ExternalLink, Check, Search, Link2, KeyRound, ShieldAlert,
|
||||
SlidersHorizontal, CircleDot, Database,
|
||||
@@ -711,7 +711,7 @@ function InstanceSettingsDialog({ settings, t }: { settings: ReturnType<typeof u
|
||||
)
|
||||
})}
|
||||
{form.actions.length > 0 && (
|
||||
<DialogSection label={t('admin.plugins.actions')}>
|
||||
<DialogSection icon={SlidersHorizontal} label={t('admin.plugins.actions')}>
|
||||
{!form.active && <SettingsHint className="mb-2">{t('admin.plugins.actions.inactive')}</SettingsHint>}
|
||||
<SettingRows>
|
||||
{form.actions.map(a => {
|
||||
@@ -826,7 +826,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
)}
|
||||
|
||||
{manifest && (
|
||||
<DialogSection label={t('admin.plugins.accessTitle')}>
|
||||
<DialogSection icon={ShieldCheck} label={t('admin.plugins.accessTitle')}>
|
||||
{access.length === 0 && !permissions.includes('db:own') ? (
|
||||
<SettingsHint>{t('admin.plugins.noAccess')}</SettingsHint>
|
||||
) : (
|
||||
@@ -847,7 +847,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
this dialog shows it. An admin approving the grant should read the
|
||||
names and descriptions first, not discover them in a chat. */}
|
||||
{manifest && (manifest.capabilities?.mcpTools?.length ?? 0) > 0 && (
|
||||
<DialogSection label={t('admin.plugins.mcpToolsTitle')}>
|
||||
<DialogSection icon={Wrench} label={t('admin.plugins.mcpToolsTitle')}>
|
||||
<DialogList>
|
||||
{(manifest.capabilities?.mcpTools ?? []).map(tool => (
|
||||
<DialogListItem key={tool.name} icon={<Bot size={14} />}>
|
||||
@@ -869,7 +869,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
itemClassName="text-content-secondary text-[length:calc(13px*var(--fs-scale-body,1))]" />
|
||||
|
||||
{manifest && (egress.length > 0 || manifest.operatorEgress) && (
|
||||
<DialogSection label={t('admin.plugins.connectsTitle')}>
|
||||
<DialogSection icon={Link} label={t('admin.plugins.connectsTitle')}>
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{egress.map(h => (
|
||||
<code key={h} className="rounded-full bg-info-soft px-2.5 py-1 font-mono text-info" style={fs(11.5)}>{h}</code>
|
||||
@@ -887,7 +887,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
)}
|
||||
|
||||
{manifest && settings.length > 0 && (
|
||||
<DialogSection label={t('admin.plugins.setupTitle')}>
|
||||
<DialogSection icon={SlidersHorizontal} label={t('admin.plugins.setupTitle')}>
|
||||
<DialogList>
|
||||
{settings.map(s => (
|
||||
<DialogListItem key={s.key}
|
||||
@@ -904,7 +904,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
<DialogSection label={t('admin.plugins.detailsTitle')}>
|
||||
<DialogSection icon={Info} label={t('admin.plugins.detailsTitle')}>
|
||||
<div className="grid grid-cols-2 gap-2 max-sm:grid-cols-1">
|
||||
{item.latest && <Meta k={t('admin.plugins.metaVersion')} v={`v${item.latest}`} />}
|
||||
{sizeKb !== null && <Meta k={t('admin.plugins.metaSize')} v={`${sizeKb} KB`} />}
|
||||
@@ -923,7 +923,7 @@ function PluginDetailModal({ item, installed, busy, onInstall, onClose, t, local
|
||||
{/* Every published version, installable individually. The compat verdict per
|
||||
version is SERVER-computed — an incompatible one is explained, never offered. */}
|
||||
{(detail?.versions?.length ?? 0) > 1 && (
|
||||
<DialogSection label={t('admin.plugins.versionsTitle')}>
|
||||
<DialogSection icon={History} label={t('admin.plugins.versionsTitle')}>
|
||||
<DialogList>
|
||||
{detail!.versions!.map(v => (
|
||||
<DialogListItem key={v.version}
|
||||
@@ -1105,7 +1105,7 @@ function UpdateConsentDialog({ data, unsigned, t, onApprove, onLater }: {
|
||||
this informs, it does not block. */}
|
||||
{unsigned && <WarnNote icon={<ShieldAlert size={13} />}>{t('admin.plugins.sig.consentUnsigned')}</WarnNote>}
|
||||
{data.newPermissions.length > 0 && (
|
||||
<DialogSection label={t('admin.plugins.updateNewPermissions')}>
|
||||
<DialogSection icon={ShieldCheck} label={t('admin.plugins.updateNewPermissions')}>
|
||||
<DialogList>
|
||||
{data.newPermissions.map(perm => (
|
||||
<DialogListItem key={perm} icon={<Check size={14} className="text-warning" />}><PermLabel perm={perm} t={t} /></DialogListItem>
|
||||
@@ -1114,7 +1114,7 @@ function UpdateConsentDialog({ data, unsigned, t, onApprove, onLater }: {
|
||||
</DialogSection>
|
||||
)}
|
||||
{data.newEgress.length > 0 && (
|
||||
<DialogSection label={t('admin.plugins.updateNewEgress')}>
|
||||
<DialogSection icon={Globe} label={t('admin.plugins.updateNewEgress')}>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{data.newEgress.map(host => (
|
||||
<code key={host} className="rounded-full bg-info-soft px-2.5 py-1 font-mono text-info" style={fs(11.5)}>{host}</code>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId } from 'react'
|
||||
import { Plus, Pencil, Trash2, Pipette, Tags, Loader2 } from 'lucide-react'
|
||||
import { Shapes, Palette, Eye, Plus, Pencil, Trash2, Pipette, Tags, Loader2 } from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
@@ -52,7 +52,7 @@ export default function CategoryManager() {
|
||||
</DialogFooter>
|
||||
}
|
||||
>
|
||||
<DialogSection label={t('categories.icon')}>
|
||||
<DialogSection icon={Shapes} label={t('categories.icon')}>
|
||||
<div className="max-h-52 overflow-y-auto rounded-[14px] border border-edge-faint bg-surface-secondary p-2">
|
||||
<div className="grid grid-cols-[repeat(auto-fill,minmax(38px,1fr))] gap-1">
|
||||
{ICON_NAMES.map(name => {
|
||||
@@ -79,7 +79,7 @@ export default function CategoryManager() {
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('categories.color')}>
|
||||
<DialogSection icon={Palette} label={t('categories.color')}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{PRESET_COLORS.map(color => (
|
||||
<button key={color} type="button" onClick={() => setForm(prev => ({ ...prev, color }))}
|
||||
@@ -116,7 +116,7 @@ export default function CategoryManager() {
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('categories.preview')}>
|
||||
<DialogSection icon={Eye} label={t('categories.preview')}>
|
||||
<div className="flex items-center rounded-[14px] border border-edge-faint bg-surface-secondary px-3.5 py-3">
|
||||
<span className="inline-flex min-w-0 max-w-full items-center gap-1.5 truncate rounded-full px-2.5 py-1 font-semibold"
|
||||
style={{ ...fs(12.5, 'body'), backgroundColor: `${form.color}20`, color: form.color }}>
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function PermissionsPanel(): React.ReactElement {
|
||||
>
|
||||
<div className={`flex flex-col gap-5 transition-opacity ${saving ? 'opacity-60' : ''}`}>
|
||||
{CATEGORIES.map(cat => (
|
||||
<DialogSection key={cat.id} label={t(`perm.cat.${cat.id}`)}>
|
||||
<DialogSection icon={ShieldCheck} key={cat.id} label={t(`perm.cat.${cat.id}`)}>
|
||||
<SettingRows>
|
||||
{cat.keys.map(key => {
|
||||
const entry = entryMap.get(key)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Check, Loader2, Sparkles } from 'lucide-react';
|
||||
import { Check, CreditCard, Loader2, Settings2, Sparkles, Unplug } from 'lucide-react';
|
||||
import React, { useId, useState } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import ToggleSwitch from '../../Settings/ToggleSwitch';
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
DialogButton,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogSection,
|
||||
DialogShell,
|
||||
DialogTile,
|
||||
FooterSpacer,
|
||||
@@ -25,17 +26,12 @@ import { POLICY_CHOICES, useAiAdminConfig } from './useAiAdminConfig';
|
||||
|
||||
type AiAdmin = ReturnType<typeof useAiAdminConfig>;
|
||||
|
||||
const EYEBROW = 'font-geist font-bold uppercase tracking-[.08em] text-content-faint';
|
||||
|
||||
/** Who pays, as three rows to pick one from: the labels are too long for a segmented track in a shelf. */
|
||||
/** The instance's payment policy, with room for each translated option. */
|
||||
function PolicyChoice({ A }: { A: AiAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className={EYEBROW} style={fs(9.5)}>
|
||||
{t('assistant.admin.policy')}
|
||||
</span>
|
||||
<div role="radiogroup" aria-label={t('assistant.admin.policy')} className="flex flex-col gap-1.5">
|
||||
<DialogSection icon={CreditCard} label={t('assistant.admin.policy')}>
|
||||
<div role="radiogroup" aria-label={t('assistant.admin.policy')} className="grid gap-2 sm:grid-cols-3">
|
||||
{POLICY_CHOICES.map((choice) => {
|
||||
const on = A.policy === choice.value;
|
||||
return (
|
||||
@@ -45,7 +41,7 @@ function PolicyChoice({ A }: { A: AiAdmin }) {
|
||||
role="radio"
|
||||
aria-checked={on}
|
||||
onClick={() => A.setPolicy(choice.value)}
|
||||
className={`flex items-center gap-2 rounded-[10px] border px-3 py-2 text-start transition-colors ${on ? 'border-[color:var(--text-primary)] bg-surface-card shadow-sm' : 'border-edge bg-surface-card hover:border-edge-secondary'}`}
|
||||
className={`flex min-h-11 items-center gap-2 rounded-xl border bg-surface-input px-3 py-2 text-start transition-colors ${on ? 'border-[color:var(--text-primary)]' : 'border-edge-faint hover:bg-surface-hover'}`}
|
||||
>
|
||||
<span
|
||||
className={`min-w-0 flex-1 font-medium ${on ? 'text-content' : 'text-content-muted'}`}
|
||||
@@ -58,8 +54,8 @@ function PolicyChoice({ A }: { A: AiAdmin }) {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{A.policyHintKey && <SettingsHint>{t(A.policyHintKey)}</SettingsHint>}
|
||||
</div>
|
||||
{A.policyHintKey && <SettingsHint className="mt-2">{t(A.policyHintKey)}</SettingsHint>}
|
||||
</DialogSection>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,7 +67,7 @@ function LiveConnection({ A }: { A: AiAdmin }) {
|
||||
const status = CONNECTION_STATUS[live.status];
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col gap-3 rounded-[12px] border border-edge-faint bg-surface-card p-3 ${busy ? 'opacity-60' : ''}`}
|
||||
className={`flex flex-col gap-3 rounded-[12px] border border-edge-faint bg-surface-input p-3 ${busy ? 'opacity-60' : ''}`}
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<ProviderMark kind={live.kind} />
|
||||
@@ -114,21 +110,20 @@ function InstanceConnection({ A }: { A: AiAdmin }) {
|
||||
const { t } = useTranslation();
|
||||
const { live, connection, replacing, cancelReplace, onConnected } = A.instance;
|
||||
return (
|
||||
<div className="flex flex-col gap-2.5">
|
||||
<span className={EYEBROW} style={fs(9.5)}>
|
||||
{t('assistant.admin.connection')}
|
||||
</span>
|
||||
{!replacing && <LiveConnection A={A} />}
|
||||
{!live && <SettingsHint>{t('assistant.admin.connectionNone')}</SettingsHint>}
|
||||
{A.showPanel && (
|
||||
<AiConnectPanel scope="instance" onConnected={onConnected} prefill={connection?.prefill ?? null} />
|
||||
)}
|
||||
{replacing && (
|
||||
<button type="button" onClick={cancelReplace} className={`${SETTINGS_BUTTON} self-start`}>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<DialogSection icon={Unplug} label={t('assistant.admin.connection')}
|
||||
action={!live && <StatusPill>{t('assistant.admin.connectionNone')}</StatusPill>}>
|
||||
<div className="flex flex-col gap-2.5">
|
||||
{!replacing && <LiveConnection A={A} />}
|
||||
{A.showPanel && (
|
||||
<AiConnectPanel scope="instance" onConnected={onConnected} prefill={connection?.prefill ?? null} />
|
||||
)}
|
||||
{replacing && (
|
||||
<button type="button" onClick={cancelReplace} className={`${SETTINGS_BUTTON} self-start`}>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,8 +224,6 @@ export default function AiSettingsDialog({
|
||||
labelId={labelId}
|
||||
eyebrow={t('admin.addons.ai.name')}
|
||||
title={t('admin.addons.ai.setup')}
|
||||
sub={t('admin.addons.ai.dialogSub')}
|
||||
subWraps
|
||||
onClose={onClose}
|
||||
/>
|
||||
}
|
||||
@@ -258,7 +251,11 @@ export default function AiSettingsDialog({
|
||||
{A.instancePays && <InstanceConnection A={A} />}
|
||||
</div>
|
||||
)}
|
||||
{shown === 'assistant' && <AssistantLimits A={A} />}
|
||||
{shown === 'assistant' && (
|
||||
<DialogSection icon={Settings2} label={t('admin.addons.catalog.ai_assistant.name')}>
|
||||
<AssistantLimits A={A} />
|
||||
</DialogSection>
|
||||
)}
|
||||
{shown === 'parsing' && parsing && (
|
||||
<ParsingSettings addon={parsing} A={A} onOpenConnection={() => setTab('connection')} />
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { asLlmVision, LLM_VISION_MODES, type LlmVision } from '@trek/shared';
|
||||
import { Check, RefreshCw } from 'lucide-react';
|
||||
import { Bot, Image, Check, RefreshCw } from 'lucide-react';
|
||||
import React, { useId } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { ProviderMark } from '../../Settings/ai/AiConnectPanel';
|
||||
@@ -313,15 +313,15 @@ export default function ParsingSettings({
|
||||
(P.ownConnection ? P.savedProvider : A.instance.live?.kind === 'custom' ? 'local' : 'cloud') === 'local';
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<DialogSection label={t('admin.addons.ai.parsing.readsWith')}>
|
||||
<DialogSection icon={Bot} label={t('admin.addons.ai.parsing.readsWith')}>
|
||||
<ParsingSource A={A} P={P} onOpenConnection={onOpenConnection} />
|
||||
</DialogSection>
|
||||
{P.formOpen && (
|
||||
<DialogSection label={t('admin.addons.ai.parsing.own')}>
|
||||
<DialogSection icon={Bot} label={t('admin.addons.ai.parsing.own')}>
|
||||
<OwnConnectionForm P={P} />
|
||||
</DialogSection>
|
||||
)}
|
||||
<DialogSection label={t('settings.aiParsing.multimodal')}>
|
||||
<DialogSection icon={Image} label={t('settings.aiParsing.multimodal')}>
|
||||
<Segmented<LlmVision>
|
||||
label={t('settings.aiParsing.multimodal')}
|
||||
value={P.vision}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { PaddleRegionAutoMode, PaddleRegionPending } from '@trek/shared';
|
||||
import { Ban, CloudDownload, Hand, Loader2, Power, Sparkles } from 'lucide-react';
|
||||
import { Ban, CloudDownload, Hand, Inbox, Loader2, Power, Sparkles } from 'lucide-react';
|
||||
import { useDateFormat } from '../../../hooks/useDateFormat';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { formatDisplayDate } from '../../../utils/dateFormat';
|
||||
import { ChoiceChips, SettingRows, SETTINGS_BUTTON, SettingsHint, StatusPill } from '../../Settings/settingsKit';
|
||||
import { LABEL, Segmented } from '../../shared/dialogParts';
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import { DialogSection, fs } from '../../shared/DialogShell';
|
||||
import { Tooltip } from '../../shared/Tooltip';
|
||||
import { AUTO_LOAD_MODES, autoLoadSizes, formatMegabytes } from './paddleRegionsModel';
|
||||
import type { usePaddleRegionsAdmin } from './usePaddleRegionsAdmin';
|
||||
@@ -33,39 +33,42 @@ export function AutoLoadSettings({ admin }: { admin: Admin }) {
|
||||
if (!settings) return null;
|
||||
const sizes = autoLoadSizes(settings.max_mb);
|
||||
return (
|
||||
<div data-testid="paddle-auto-load" className="flex min-w-0 flex-col gap-2.5">
|
||||
<div className="min-w-0">
|
||||
<span className={LABEL}>{t('admin.paddleRegions.auto.title')}</span>
|
||||
<fieldset disabled={saving} className="m-0 min-w-0 border-0 p-0">
|
||||
<Segmented<PaddleRegionAutoMode>
|
||||
value={settings.mode}
|
||||
onChange={(mode) => void save({ mode })}
|
||||
label={t('admin.paddleRegions.auto.title')}
|
||||
fill
|
||||
options={AUTO_LOAD_MODES.map((mode) => {
|
||||
const Icon = MODE_ICONS[mode];
|
||||
return {
|
||||
value: mode,
|
||||
label: t(`admin.paddleRegions.auto.mode.${mode}`),
|
||||
icon: <Icon size={13} strokeWidth={2} aria-hidden="true" />,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</fieldset>
|
||||
<SettingsHint className="mt-1.5">{t(`admin.paddleRegions.auto.modeHint.${settings.mode}`)}</SettingsHint>
|
||||
</div>
|
||||
{settings.mode === 'auto' && (
|
||||
<fieldset disabled={saving} className="m-0 min-w-0 border-0 p-0">
|
||||
<span className={LABEL}>{t('admin.paddleRegions.auto.maxSize')}</span>
|
||||
<ChoiceChips<string>
|
||||
value={String(settings.max_mb)}
|
||||
label={t('admin.paddleRegions.auto.maxSize')}
|
||||
onChange={(value) => void save({ max_mb: Number(value) })}
|
||||
options={sizes.map((mb) => ({ value: String(mb), label: megabytes(mb) }))}
|
||||
/>
|
||||
<SettingsHint className="mt-1.5">{t('admin.paddleRegions.auto.maxSizeHint')}</SettingsHint>
|
||||
</fieldset>
|
||||
)}
|
||||
<div data-testid="paddle-auto-load">
|
||||
<DialogSection icon={CloudDownload} label={t('admin.paddleRegions.auto.title')}>
|
||||
<div className="flex min-w-0 flex-col gap-3">
|
||||
<div className="min-w-0">
|
||||
<fieldset disabled={saving} className="m-0 min-w-0 border-0 p-0 [&>[role=group]]:bg-[color:var(--bg-selected)]">
|
||||
<Segmented<PaddleRegionAutoMode>
|
||||
value={settings.mode}
|
||||
onChange={(mode) => void save({ mode })}
|
||||
label={t('admin.paddleRegions.auto.title')}
|
||||
fill
|
||||
options={AUTO_LOAD_MODES.map((mode) => {
|
||||
const Icon = MODE_ICONS[mode];
|
||||
return {
|
||||
value: mode,
|
||||
label: t(`admin.paddleRegions.auto.mode.${mode}`),
|
||||
icon: <Icon size={13} strokeWidth={2} aria-hidden="true" />,
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</fieldset>
|
||||
<SettingsHint className="mt-1.5">{t(`admin.paddleRegions.auto.modeHint.${settings.mode}`)}</SettingsHint>
|
||||
</div>
|
||||
{settings.mode === 'auto' && (
|
||||
<fieldset disabled={saving} className="m-0 min-w-0 border-0 p-0 [&_[aria-pressed=false]]:bg-surface-input [&_[aria-pressed=true]]:bg-accent [&_[aria-pressed=true]]:text-accent-text">
|
||||
<span className={LABEL}>{t('admin.paddleRegions.auto.maxSize')}</span>
|
||||
<ChoiceChips<string>
|
||||
value={String(settings.max_mb)}
|
||||
label={t('admin.paddleRegions.auto.maxSize')}
|
||||
onChange={(value) => void save({ max_mb: Number(value) })}
|
||||
options={sizes.map((mb) => ({ value: String(mb), label: megabytes(mb) }))}
|
||||
/>
|
||||
<SettingsHint className="mt-1.5">{t('admin.paddleRegions.auto.maxSizeHint')}</SettingsHint>
|
||||
</fieldset>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -132,16 +135,15 @@ export function RequestList({ admin }: { admin: Admin }) {
|
||||
const ordered = [...admin.requests].sort((a, b) => Number(a.declined) - Number(b.declined));
|
||||
const open = admin.requests.filter((request) => !request.declined).length;
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-2" data-testid="paddle-region-requests">
|
||||
<span className={`${LABEL} mb-0 flex items-center gap-1.5`}>
|
||||
{t('admin.paddleRegions.requests.title')}
|
||||
{open > 0 && <StatusPill tone="warning">{open}</StatusPill>}
|
||||
</span>
|
||||
<SettingRows>
|
||||
{ordered.map((request) => (
|
||||
<RequestRow key={request.id} request={request} admin={admin} />
|
||||
))}
|
||||
</SettingRows>
|
||||
<div data-testid="paddle-region-requests">
|
||||
<DialogSection icon={Inbox} label={t('admin.paddleRegions.requests.title')}
|
||||
action={open > 0 && <StatusPill tone="warning">{open}</StatusPill>}>
|
||||
<SettingRows>
|
||||
{ordered.map((request) => (
|
||||
<RequestRow key={request.id} request={request} admin={admin} />
|
||||
))}
|
||||
</SettingRows>
|
||||
</DialogSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PaddleRegion, PaddleRegionCatalogEntry } from '@trek/shared';
|
||||
import { Check, ChevronRight, Loader2, Plus, RefreshCw, Search, Trash2, Waves, WifiOff } from 'lucide-react';
|
||||
import { useId, useState } from 'react';
|
||||
import { Check, ChevronRight, Info, Loader2, MapPin, Plus, RefreshCw, Search, Trash2, Waves, WifiOff } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { useDateFormat } from '../../../hooks/useDateFormat';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { formatDisplayDate } from '../../../utils/dateFormat';
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
StatusPill,
|
||||
} from '../../Settings/settingsKit';
|
||||
import ConfirmDialog from '../../shared/ConfirmDialog';
|
||||
import { EditorField, INPUT } from '../../shared/dialogParts';
|
||||
import { fs } from '../../shared/DialogShell';
|
||||
import { INPUT } from '../../shared/dialogParts';
|
||||
import { DialogSection, fs } from '../../shared/DialogShell';
|
||||
import ErrorBoundary from '../../shared/ErrorBoundary';
|
||||
import { Tooltip } from '../../shared/Tooltip';
|
||||
import AddonSetupDialog from '../AddonSetupDialog';
|
||||
@@ -64,7 +64,6 @@ function Panel() {
|
||||
icon={<Waves size={20} strokeWidth={2} />}
|
||||
eyebrow={t('admin.addons.catalog.tours.name')}
|
||||
title={title}
|
||||
sub={t('admin.paddleRegions.hint')}
|
||||
onClose={close}
|
||||
blocked={admin.removing !== null}
|
||||
>
|
||||
@@ -105,10 +104,20 @@ function PanelBody({ admin }: { admin: Admin }) {
|
||||
<fieldset disabled={admin.offline} className="m-0 flex min-w-0 flex-col gap-4 border-0 p-0">
|
||||
<AutoLoadSettings admin={admin} />
|
||||
<RequestList admin={admin} />
|
||||
<CatalogSearch admin={admin} />
|
||||
<RegionList admin={admin} />
|
||||
<DialogSection icon={MapPin} label={t('admin.paddleRegions.search')}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<CatalogSearch admin={admin} />
|
||||
<RegionList admin={admin} />
|
||||
</div>
|
||||
</DialogSection>
|
||||
</fieldset>
|
||||
<SettingsHint>{t('admin.paddleRegions.attribution')}</SettingsHint>
|
||||
<div role="note" className="flex items-start gap-2.5 px-1">
|
||||
<Info size={15} className="mt-0.5 shrink-0 text-content-muted" aria-hidden />
|
||||
<div className="flex flex-col gap-1">
|
||||
<SettingsHint>{t('admin.paddleRegions.hint')}</SettingsHint>
|
||||
<SettingsHint>{t('admin.paddleRegions.attribution')}</SettingsHint>
|
||||
</div>
|
||||
</div>
|
||||
<ConfirmDialog
|
||||
isOpen={admin.removing !== null}
|
||||
onClose={admin.cancelRemove}
|
||||
@@ -138,28 +147,25 @@ function RegionPath({ hit }: { hit: PaddleRegionCatalogEntry }) {
|
||||
|
||||
function CatalogSearch({ admin }: { admin: Admin }) {
|
||||
const { t } = useTranslation();
|
||||
const id = useId();
|
||||
const { search } = admin;
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<EditorField label={t('admin.paddleRegions.search')} htmlFor={id}>
|
||||
<div className="relative">
|
||||
<Search
|
||||
size={14}
|
||||
className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<input
|
||||
id={id}
|
||||
type="search"
|
||||
className={`${INPUT} ps-9`}
|
||||
value={search.query}
|
||||
onChange={(event) => search.setQuery(event.target.value)}
|
||||
placeholder={t('admin.paddleRegions.searchPlaceholder')}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
</EditorField>
|
||||
<div className="relative">
|
||||
<Search
|
||||
size={14}
|
||||
className="pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-content-faint"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<input
|
||||
type="search"
|
||||
aria-label={t('admin.paddleRegions.search')}
|
||||
className={`${INPUT} ps-9`}
|
||||
value={search.query}
|
||||
onChange={(event) => search.setQuery(event.target.value)}
|
||||
placeholder={t('admin.paddleRegions.searchPlaceholder')}
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
{search.searching && (
|
||||
<p role="status" className="m-0 flex items-center gap-2 text-content-muted" style={fs(12.5, 'body')}>
|
||||
<Loader2 size={14} className="flex-none animate-spin" />
|
||||
@@ -219,7 +225,7 @@ function RegionList({ admin }: { admin: Admin }) {
|
||||
}
|
||||
if (admin.regions.length === 0) {
|
||||
return (
|
||||
<div className="rounded-[12px] border border-dashed border-edge px-4 py-5 text-center">
|
||||
<div className="rounded-xl border border-edge-faint bg-surface-input px-3 py-3">
|
||||
<SettingsHint>{t('admin.paddleRegions.empty')}</SettingsHint>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ import { relativeTime } from '../../../utils/relativeTime'
|
||||
import ConfirmDialog from '../../shared/ConfirmDialog'
|
||||
import CustomSelect from '../../shared/CustomSelect'
|
||||
import { Tooltip } from '../../shared/Tooltip'
|
||||
import { NEUTRAL_TINT, fs } from '../../shared/DialogShell'
|
||||
import { DialogButton, FooterSpacer, NEUTRAL_TINT, fs } from '../../shared/DialogShell'
|
||||
import Section from '../../Settings/Section'
|
||||
import { SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, SETTINGS_ICON_BUTTON, SettingRows, SettingsHint, StatusPill, SettingsColumns } from '../../Settings/settingsKit'
|
||||
import BackendForm from './BackendForm'
|
||||
@@ -588,26 +588,11 @@ export default function AdminStoragePanel(): React.ReactElement {
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2 border-t border-edge-faint px-4 py-3">
|
||||
<button type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
onClick={closeMigratePrompt}
|
||||
>
|
||||
{t('storage.migrate.promptCancel')}
|
||||
</button>
|
||||
<span className="flex-1" />
|
||||
<button type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
onClick={() => void routeOnlySave()}
|
||||
>
|
||||
{t('storage.migrate.routeOnly')}
|
||||
</button>
|
||||
<button type="button"
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
onClick={() => void moveAndSave()}
|
||||
>
|
||||
{t('storage.migrate.move')}
|
||||
</button>
|
||||
<div className="trek-dialog-footer flex flex-wrap items-center gap-2 border-t border-edge-faint px-4 py-3">
|
||||
<DialogButton onClick={closeMigratePrompt}>{t('storage.migrate.promptCancel')}</DialogButton>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={() => void routeOnlySave()}>{t('storage.migrate.routeOnly')}</DialogButton>
|
||||
<DialogButton variant="primary" onClick={() => void moveAndSave()}>{t('storage.migrate.move')}</DialogButton>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useId } from 'react'
|
||||
import { HardDrive } from 'lucide-react'
|
||||
import { Server, HardDrive } from 'lucide-react'
|
||||
import {
|
||||
STORAGE_BACKEND_TYPE_IDS,
|
||||
type StorageBackend,
|
||||
@@ -199,7 +199,7 @@ export default function BackendForm({
|
||||
{fields.length > 0 && <div className={GRID_2}>{fields.map(renderField)}</div>}
|
||||
|
||||
{mirror && (
|
||||
<DialogSection label={t('storage.mirror.targets')}>
|
||||
<DialogSection icon={Server} label={t('storage.mirror.targets')}>
|
||||
<p className="m-0 mb-2.5 leading-normal text-content-faint" style={fs(11.5)}>{t('storage.mirror.targetsHelp')}</p>
|
||||
{visibleCandidates.length > 0 && (
|
||||
<div className={CHECK_ROWS}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NotebookPen, Plus } from 'lucide-react';
|
||||
import { Zap, NotebookPen, Plus } from 'lucide-react';
|
||||
import { useId, useState } from 'react';
|
||||
|
||||
import { useTranslation } from '../../i18n';
|
||||
@@ -75,7 +75,7 @@ export default function AssistantMemoryDialog({ tripId, onClose }: { tripId: num
|
||||
</DialogFooter>
|
||||
}
|
||||
>
|
||||
<DialogSection label={t('assistant.memory.quick')}>
|
||||
<DialogSection icon={Zap} label={t('assistant.memory.quick')}>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{QUICK.map((key, i) => {
|
||||
const line = t(`assistant.memory.quick.${key}`);
|
||||
@@ -96,7 +96,7 @@ export default function AssistantMemoryDialog({ tripId, onClose }: { tripId: num
|
||||
})}
|
||||
</div>
|
||||
</DialogSection>
|
||||
<DialogSection label={t('assistant.memory.notes')}>
|
||||
<DialogSection icon={NotebookPen} label={t('assistant.memory.notes')}>
|
||||
<textarea
|
||||
aria-label={t('assistant.memory.notes')}
|
||||
rows={6}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TourActivityTotals, TourTypeKey } from '@trek/shared';
|
||||
import { Footprints } from 'lucide-react';
|
||||
import { ChartBar, Route, Footprints } from 'lucide-react';
|
||||
import { createElement, useId } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import type { DistanceUnit } from '../../../types';
|
||||
@@ -91,7 +91,7 @@ function StatsBody({ stats }: { stats: TourActivityStats }) {
|
||||
</div>
|
||||
</div>
|
||||
{showTypes && (
|
||||
<DialogSection label={t('tours.stats.byType')}>
|
||||
<DialogSection icon={ChartBar} label={t('tours.stats.byType')}>
|
||||
<ul className="m-0 flex list-none flex-col gap-1 p-0">
|
||||
{summary.types.map(({ type, ...totals }) => (
|
||||
<TypeLine key={type} type={type} totals={totals} />
|
||||
@@ -99,7 +99,7 @@ function StatsBody({ stats }: { stats: TourActivityStats }) {
|
||||
</ul>
|
||||
</DialogSection>
|
||||
)}
|
||||
<DialogSection
|
||||
<DialogSection icon={Route}
|
||||
label={t('tours.mode.tours')}
|
||||
action={
|
||||
<span className="font-geist tabular-nums text-content-faint" style={fs(11)}>
|
||||
|
||||
@@ -27,7 +27,7 @@ export function CostsCurrencyPicker({
|
||||
options={options}
|
||||
size="sm"
|
||||
searchable
|
||||
menuFit="content"
|
||||
menuWidth={220}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -173,7 +173,7 @@ describe('CostsPanel — settlements in the ledger', () => {
|
||||
)
|
||||
render(<CostsPanel tripId={1} tripMembers={tripMembers} />)
|
||||
await screen.findByText('Hotel')
|
||||
expect(screen.getByText('Unfinished')).toBeInTheDocument()
|
||||
expect(screen.getByRole('img', { name: 'Unfinished' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
// ── Notes on an expense (#1658) ────────────────────────────────────────────
|
||||
@@ -2138,7 +2138,7 @@ describe('CostsPanel — negative amounts (#2176)', () => {
|
||||
mount([expense({ id: 320, name: 'Pending refund', category: 'misc', total_price: -50, payers: [], members: [{ user_id: 1, username: 'alice' }] })])
|
||||
|
||||
await screen.findByText('Pending refund')
|
||||
expect(screen.getByText('Unfinished')).toBeInTheDocument()
|
||||
expect(screen.getByRole('img', { name: 'Unfinished' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('FE-W5COSTS-070: the category breakdown nets refunds and keeps a net-negative category listed', async () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Fragment, useState, useMemo, useCallback, useId, type ReactNode } from 'react'
|
||||
import { ArrowDown, ArrowUp, BarChart3, Plus, Search, ArrowRight, ArrowLeftRight, Check, RotateCcw, Pencil, Trash2, AlertCircle, Download, ChevronDown, Receipt, ScanLine, Users } from 'lucide-react'
|
||||
import { Banknote, NotebookPen, Wallet, Split, ArrowDown, ArrowUp, BarChart3, Plus, Search, ArrowRight, ArrowLeftRight, Check, RotateCcw, Pencil, Trash2, AlertCircle, Download, ChevronDown, Receipt, ScanLine, Users } from 'lucide-react'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { useCanDo } from '../../store/permissionsStore'
|
||||
import { useToast } from '../shared/Toast'
|
||||
@@ -672,10 +672,9 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
|
||||
<span className="text-content" style={{ fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{e.name}</span>
|
||||
{unfinished && !isMobile && (
|
||||
<Tooltip label={t('costs.unfinishedHint')}>
|
||||
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 4, padding: '2px 8px 2px 6px', borderRadius: 999, background: 'rgba(217,119,6,0.14)', color: '#d97706', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', fontWeight: 700, flexShrink: 0 }}>
|
||||
<span style={{ width: 14, height: 14, borderRadius: '50%', background: '#d97706', color: '#fff', display: 'grid', placeItems: 'center', fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 800 }}>!</span>
|
||||
{t('costs.unfinished')}
|
||||
</span>
|
||||
<span role="img" aria-label={t('costs.unfinished')} className="grid size-5 shrink-0 place-items-center rounded-full bg-warning-soft text-warning">
|
||||
<AlertCircle size={13} strokeWidth={2.2} aria-hidden="true" />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(e.receipts || []).length > 0 && (
|
||||
@@ -1036,7 +1035,7 @@ export function ExpenseModal({ tripId, base, people, me, editing, prefill, onClo
|
||||
}
|
||||
|
||||
const payerSection = (
|
||||
<DialogSection
|
||||
<DialogSection icon={Wallet}
|
||||
label={t('costs.whoPaid')}
|
||||
className={GROUP} tallAction
|
||||
action={(
|
||||
@@ -1110,7 +1109,7 @@ export function ExpenseModal({ tripId, base, people, me, editing, prefill, onClo
|
||||
)
|
||||
|
||||
const splitSection = (
|
||||
<DialogSection
|
||||
<DialogSection icon={Split}
|
||||
label={t('costs.split') || 'Split'}
|
||||
className={GROUP} tallAction
|
||||
action={(
|
||||
@@ -1305,53 +1304,55 @@ export function ExpenseModal({ tripId, base, people, me, editing, prefill, onClo
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<div className={`${GROUP} flex flex-col gap-3`}>
|
||||
<div className={isMobile ? 'flex flex-col gap-5' : 'grid grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)_minmax(0,1fr)] items-start gap-3'}>
|
||||
<EditorField label={t('costs.totalAmount')}>
|
||||
<div className="flex items-center rounded-[10px] border border-edge bg-surface-input px-3" style={{ height: FIELD_H, opacity: isTicketMode ? 0.6 : 1 }}>
|
||||
<span className="text-content-faint" style={fs(15, 'subtitle')}>{sym(currency)}</span>
|
||||
<NumericInput mode="signed-decimal" placeholder={zeroAmountInput(currency)} value={localizeAmountInput(isTicketMode ? amountToInputString(ticketInfo.total, currency) : total, currency)}
|
||||
onValueChange={onTotalChange}
|
||||
signToggleLabel={t('costs.toggleSign')}
|
||||
disabled={isTicketMode}
|
||||
className="w-full flex-1 border-0 bg-transparent ps-1.5 font-semibold text-content outline-none dark:bg-transparent" style={fs(15, 'subtitle')} />
|
||||
<DialogSection icon={Banknote} label={t('costs.amount')} className={GROUP}>
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className={isMobile ? 'flex flex-col gap-5' : 'grid grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)_minmax(0,1fr)] items-start gap-3'}>
|
||||
<EditorField label={t('costs.totalAmount')}>
|
||||
<div className="flex items-center rounded-[10px] border border-edge bg-surface-input px-3" style={{ height: FIELD_H, opacity: isTicketMode ? 0.6 : 1 }}>
|
||||
<span className="text-content-faint" style={fs(15, 'subtitle')}>{sym(currency)}</span>
|
||||
<NumericInput mode="signed-decimal" placeholder={zeroAmountInput(currency)} value={localizeAmountInput(isTicketMode ? amountToInputString(ticketInfo.total, currency) : total, currency)}
|
||||
onValueChange={onTotalChange}
|
||||
signToggleLabel={t('costs.toggleSign')}
|
||||
disabled={isTicketMode}
|
||||
className="w-full flex-1 border-0 bg-transparent ps-1.5 font-semibold text-content outline-none dark:bg-transparent" style={fs(15, 'subtitle')} />
|
||||
</div>
|
||||
</EditorField>
|
||||
<EditorField label={t('costs.currency')}>
|
||||
<CustomSelect value={currency} onChange={v => setCurrency(String(v))} searchable
|
||||
options={currencyChoices}
|
||||
style={{ width: '100%' }} />
|
||||
</EditorField>
|
||||
<EditorField label={t('costs.day')}>
|
||||
<CustomDatePicker value={day} onChange={setDay} style={{ width: '100%' }} />
|
||||
</EditorField>
|
||||
</div>
|
||||
</EditorField>
|
||||
<EditorField label={t('costs.currency')}>
|
||||
<CustomSelect value={currency} onChange={v => setCurrency(String(v))} searchable
|
||||
options={currencyChoices}
|
||||
style={{ width: '100%' }} />
|
||||
</EditorField>
|
||||
<EditorField label={t('costs.day')}>
|
||||
<CustomDatePicker value={day} onChange={setDay} style={{ width: '100%' }} />
|
||||
</EditorField>
|
||||
</div>
|
||||
|
||||
{fx && (
|
||||
<div className="flex flex-wrap items-center gap-1.5 text-content-faint" style={fs(12, 'body')}>
|
||||
{badge(formatMoney(totalNum, currency, locale))}
|
||||
{fx.inTrip != null && <>
|
||||
<span>→</span>
|
||||
{badge(formatMoney(fx.inTrip, tripCur, locale))}
|
||||
</>}
|
||||
{fx.shown != null && <>
|
||||
<span>≈</span>
|
||||
{badge(formatMoney(fx.shown, base, locale))}
|
||||
<span>{t('costs.liveRate')}</span>
|
||||
</>}
|
||||
{fx && (
|
||||
<div className="flex flex-wrap items-center gap-1.5 text-content-faint" style={fs(12, 'body')}>
|
||||
{badge(formatMoney(totalNum, currency, locale))}
|
||||
{fx.inTrip != null && <>
|
||||
<span>→</span>
|
||||
{badge(formatMoney(fx.inTrip, tripCur, locale))}
|
||||
</>}
|
||||
{fx.shown != null && <>
|
||||
<span>≈</span>
|
||||
{badge(formatMoney(fx.shown, base, locale))}
|
||||
<span>{t('costs.liveRate')}</span>
|
||||
</>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
{showSplit && payerSection}
|
||||
{showSplit && splitSection}
|
||||
|
||||
{/* Side by side the two panels share one height. */}
|
||||
<div className={isMobile ? 'flex flex-col gap-5' : 'grid grid-cols-2 gap-3'}>
|
||||
<EditorField label={t('costs.note')} htmlFor="expense-note" className={GROUP}>
|
||||
<textarea id="expense-note" value={note} onChange={e => setNote(e.target.value)} rows={3}
|
||||
<DialogSection icon={NotebookPen} label={<label htmlFor={`${titleId}-note`}>{t('costs.note')}</label>} className={GROUP}>
|
||||
<textarea id={`${titleId}-note`} value={note} onChange={e => setNote(e.target.value)} rows={3}
|
||||
placeholder={t('costs.notePlaceholder')} maxLength={NOTE_MAX} className={`${TEXTAREA} resize-y`} />
|
||||
</EditorField>
|
||||
</DialogSection>
|
||||
<ExpenseReceiptsSection className={GROUP} receipts={receipts} pendingFiles={pendingReceiptFiles} uploading={uploadingReceipt}
|
||||
linkable={linkableFiles} onPick={handleReceiptFileSelect} onLink={handleLinkReceipt}
|
||||
onPreview={index => setModalPreviewReceipts({ receipts, initialIndex: index })}
|
||||
|
||||
@@ -45,7 +45,7 @@ export function ExpenseReceiptsSection({
|
||||
const canLink = linkable.length > 0;
|
||||
|
||||
return (
|
||||
<DialogSection
|
||||
<DialogSection icon={Receipt}
|
||||
label={t('costs.receiptsTitle')}
|
||||
className={className}
|
||||
action={
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useState, useEffect, useId } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { ExternalLink, Download, X, FileText, ChevronLeft, ChevronRight, FileImage } from 'lucide-react'
|
||||
import { useIsPhone } from '../../hooks/useIsPhone'
|
||||
import { DialogHeader, DialogTile, NEUTRAL_TINT, PILL } from '../shared/DialogShell'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { getAuthUrl } from '../../api/authUrl'
|
||||
import { openFile as openFileUrl } from '../../utils/fileDownload'
|
||||
@@ -15,6 +17,8 @@ interface ReceiptPreviewModalProps {
|
||||
|
||||
export function ReceiptPreviewModal({ receipts, initialIndex = 0, onClose }: ReceiptPreviewModalProps) {
|
||||
const { t } = useTranslation()
|
||||
const isPhone = useIsPhone()
|
||||
const labelId = useId()
|
||||
const [index, setIndex] = useState(Math.max(0, Math.min(initialIndex, receipts.length - 1)))
|
||||
const [signedUrl, setSignedUrl] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
@@ -92,13 +96,16 @@ export function ReceiptPreviewModal({ receipts, initialIndex = 0, onClose }: Rec
|
||||
}}
|
||||
>
|
||||
<div
|
||||
role="presentation"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={isPhone ? undefined : labelId}
|
||||
aria-label={isPhone ? current.original_name : undefined}
|
||||
style={{
|
||||
width: '100%',
|
||||
maxWidth: 950,
|
||||
height: '94vh',
|
||||
background: 'var(--bg-card)',
|
||||
borderRadius: 12,
|
||||
borderRadius: isPhone ? 12 : 22,
|
||||
overflow: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
@@ -106,95 +113,115 @@ export function ReceiptPreviewModal({ receipts, initialIndex = 0, onClose }: Rec
|
||||
}}
|
||||
onClick={e => e.stopPropagation()}
|
||||
>
|
||||
{/* Header - identical to PdfPreviewModal */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: '10px 16px',
|
||||
borderBottom: '1px solid var(--border-primary)',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
{isPhone ? (
|
||||
<div
|
||||
style={{
|
||||
fontSize: 'calc(13px * var(--fs-scale-body, 1))',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-primary)',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: '10px 16px',
|
||||
borderBottom: '1px solid var(--border-primary)',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
{current.original_name}
|
||||
</span>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleOpenTab}
|
||||
<span
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
|
||||
color: 'var(--text-muted)',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'none',
|
||||
padding: '4px 8px',
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
fontSize: 'calc(13px * var(--fs-scale-body, 1))',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-primary)',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
flex: 1,
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-muted)')}
|
||||
>
|
||||
<ExternalLink size={13} /> {t('files.openTab')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownload}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
|
||||
color: 'var(--text-muted)',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'none',
|
||||
padding: '4px 8px',
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-muted)')}
|
||||
>
|
||||
<Download size={13} /> {t('files.download') || 'Download'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
style={{
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
color: 'var(--text-faint)',
|
||||
display: 'flex',
|
||||
padding: 4,
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-faint)')}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
{current.original_name}
|
||||
</span>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleOpenTab}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
|
||||
color: 'var(--text-muted)',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'none',
|
||||
padding: '4px 8px',
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-muted)')}
|
||||
>
|
||||
<ExternalLink size={13} /> {t('files.openTab')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDownload}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
fontSize: 'calc(12px * var(--fs-scale-body, 1))',
|
||||
color: 'var(--text-muted)',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'none',
|
||||
padding: '4px 8px',
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-muted)')}
|
||||
>
|
||||
<Download size={13} /> {t('files.download') || 'Download'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label={t('common.close')}
|
||||
style={{
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
color: 'var(--text-faint)',
|
||||
display: 'flex',
|
||||
padding: 4,
|
||||
borderRadius: 6,
|
||||
transition: 'color 0.15s',
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget.style.color = 'var(--text-primary)')}
|
||||
onMouseLeave={e => (e.currentTarget.style.color = 'var(--text-faint)')}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<DialogHeader
|
||||
tile={<DialogTile><FileText size={20} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={onClose}
|
||||
title={current.original_name}
|
||||
pills={(
|
||||
<>
|
||||
<button type="button" onClick={handleOpenTab} className={`${PILL} hover:bg-surface-hover`}>
|
||||
<ExternalLink size={14} /> {t('files.openTab')}
|
||||
</button>
|
||||
<button type="button" onClick={handleDownload} className={`${PILL} hover:bg-surface-hover`}>
|
||||
<Download size={14} /> {t('files.download')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Tab strip if multiple receipts */}
|
||||
{receipts.length > 1 && (
|
||||
@@ -241,6 +268,7 @@ export function ReceiptPreviewModal({ receipts, initialIndex = 0, onClose }: Rec
|
||||
{r.original_name}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
fontSize: 'calc(10px * var(--fs-scale-caption, 1))',
|
||||
opacity: active ? 0.8 : 0.5,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ScanLine, X } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useIsPhone } from '../../mobile/useIsPhone'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { PANEL } from '../shared/dialogParts'
|
||||
import { RECEIPT_PHOTO_ACCEPT, type ReceiptScan } from './useReceiptScan'
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,7 @@ export function ReceiptScanModal({ scan }: { scan: ReceiptScan }) {
|
||||
onClose={scan.close}
|
||||
labelledBy={labelId}
|
||||
width="narrow"
|
||||
front
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><ScanLine size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
|
||||
@@ -49,8 +51,6 @@ export function ReceiptScanModal({ scan }: { scan: ReceiptScan }) {
|
||||
labelId={labelId}
|
||||
onClose={scan.close}
|
||||
title={t('costs.scan.title')}
|
||||
sub={t('costs.scan.accepted')}
|
||||
subWraps
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
@@ -63,19 +63,23 @@ export function ReceiptScanModal({ scan }: { scan: ReceiptScan }) {
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
{picker}
|
||||
<button type="button" onClick={() => inputRef.current?.click()} {...dropHandlers}
|
||||
className={`flex min-h-[132px] w-full flex-col items-center justify-center gap-2 rounded-2xl border-2 border-dashed px-4 py-5 text-center transition-colors ${dragOver ? 'border-content-muted bg-surface-tertiary' : 'border-edge bg-surface-secondary hover:border-content-faint'}`}>
|
||||
<span className="pointer-events-none grid h-10 w-10 place-items-center rounded-full bg-surface-card shadow-sm">
|
||||
<ScanLine size={18} strokeWidth={1.9} className={dragOver ? 'text-content' : 'text-content-muted'} />
|
||||
</span>
|
||||
<span className={`pointer-events-none break-all font-semibold ${scan.photo ? 'text-content' : 'text-content-muted'}`} style={fs(13, 'body')}>
|
||||
{dragOver ? t('costs.scan.dropActive') : scan.photo ? scan.photo.name : t('costs.scan.dropHere')}
|
||||
</span>
|
||||
</button>
|
||||
{scan.error && (
|
||||
<div role="alert" className="rounded-[12px] bg-danger-soft px-3 py-2.5 text-danger" style={fs(12, 'body')}>{scan.error}</div>
|
||||
)}
|
||||
<div className={PANEL}>
|
||||
{picker}
|
||||
<button type="button" onClick={() => inputRef.current?.click()} {...dropHandlers}
|
||||
aria-describedby={`${labelId}-formats`}
|
||||
className={`trek-form-control flex min-h-24 [--form-control-min-height:96px] w-full flex-col items-center justify-center gap-2 rounded-[10px] border border-dashed p-4 text-center transition-colors ${dragOver ? 'border-content-muted bg-surface-tertiary' : 'border-edge bg-surface-input hover:border-content-faint'}`}>
|
||||
<span className="pointer-events-none grid h-10 w-10 place-items-center rounded-full bg-surface-card shadow-sm">
|
||||
<ScanLine size={18} strokeWidth={1.9} className={dragOver ? 'text-content' : 'text-content-muted'} />
|
||||
</span>
|
||||
<span className={`pointer-events-none break-all font-semibold ${scan.photo ? 'text-content' : 'text-content-muted'}`} style={fs(13, 'body')}>
|
||||
{dragOver ? t('costs.scan.dropActive') : scan.photo ? scan.photo.name : t('costs.scan.dropHere')}
|
||||
</span>
|
||||
</button>
|
||||
<p id={`${labelId}-formats`} className="m-0 text-caption text-content-muted">{t('costs.scan.accepted')}</p>
|
||||
{scan.error && (
|
||||
<div role="alert" className="rounded-[12px] bg-danger-soft px-3 py-2.5 text-danger" style={fs(12, 'body')}>{scan.error}</div>
|
||||
)}
|
||||
</div>
|
||||
</DialogShell>
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import { sanitizedMarkdownComponents, sanitizedMarkdownPlugins } from '../shared/markdownSanitize'
|
||||
import { Plus, Pencil, StickyNote, Settings, ExternalLink } from 'lucide-react'
|
||||
import CollabPanelHead, { HEAD_ACTION } from './CollabPanelHead'
|
||||
import { Text, Link, Paperclip, Plus, Pencil, StickyNote, Settings, ExternalLink } from 'lucide-react'
|
||||
import CollabPanelHead, { HEAD_ACTION, HEAD_ICON_ACTION } from './CollabPanelHead'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, PILL, fs } from '../shared/DialogShell'
|
||||
import { collabApi } from '../../api/client'
|
||||
@@ -252,7 +252,7 @@ function CollabNotesHeader({ t, canEdit, setShowSettings, setShowNewModal, notes
|
||||
<>
|
||||
<Tooltip label={t('collab.notes.categorySettings')}>
|
||||
<button type="button" onClick={() => setShowSettings(true)} aria-label={t('collab.notes.categorySettings')}
|
||||
className="grid h-7 w-7 place-items-center rounded-full bg-surface-card text-content-muted shadow-sm hover:text-content">
|
||||
className={HEAD_ICON_ACTION}>
|
||||
<Settings size={13} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
@@ -371,13 +371,13 @@ function ViewNoteModal(S: NotesState) {
|
||||
</DialogFooter>
|
||||
) : undefined}
|
||||
>
|
||||
<DialogSection label={t('collab.notes.content')}>
|
||||
<DialogSection icon={Text} label={t('collab.notes.content')}>
|
||||
<div className="collab-note-md-full text-content" style={{ ...fs(14, 'body'), lineHeight: 1.7 }}>
|
||||
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} rehypePlugins={sanitizedMarkdownPlugins} components={sanitizedMarkdownComponents}>{viewingNote.content || ''}</Markdown>
|
||||
</div>
|
||||
</DialogSection>
|
||||
{websiteHref && (
|
||||
<DialogSection label={t('collab.notes.website')}>
|
||||
<DialogSection icon={Link} label={t('collab.notes.website')}>
|
||||
<a href={websiteHref} target="_blank" rel="noopener noreferrer"
|
||||
className="inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-secondary px-3 py-1.5 font-semibold text-content no-underline hover:opacity-80" style={fs(12, 'body')}>
|
||||
<ExternalLink size={13} className="flex-none text-content-muted" />
|
||||
@@ -386,7 +386,7 @@ function ViewNoteModal(S: NotesState) {
|
||||
</DialogSection>
|
||||
)}
|
||||
{attachments.length > 0 && (
|
||||
<DialogSection label={t('files.title')}>
|
||||
<DialogSection icon={Paperclip} label={t('files.title')}>
|
||||
<div className="flex flex-wrap gap-2.5">
|
||||
{attachments.map(a => {
|
||||
const isImage = a.mime_type?.startsWith('image/')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, useState } from 'react'
|
||||
import { Plus, Tags, Trash2 } from 'lucide-react'
|
||||
import { Shapes, Plus, Tags, Trash2 } from 'lucide-react'
|
||||
import { NOTE_COLORS } from './CollabNotes.constants'
|
||||
import { EditableCatName } from './CollabNotesEditableCatName'
|
||||
import { originalCategoryName } from './CollabNotes.helpers'
|
||||
@@ -96,7 +96,7 @@ export function CategorySettingsModal({ onClose, categories, categoryColors, onS
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<DialogSection label={t('collab.notes.category')}>
|
||||
<DialogSection icon={Shapes} label={t('collab.notes.category')}>
|
||||
{allCats.length === 0 ? (
|
||||
<p className="m-0 rounded-[12px] bg-surface-secondary px-4 py-5 text-center text-content-faint" style={fs(12.5, 'body')}>
|
||||
{t('collab.notes.noCategoriesYet') || 'No categories yet'}
|
||||
|
||||
@@ -3,11 +3,13 @@ import type { LucideIcon } from 'lucide-react'
|
||||
import { NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
|
||||
/** A panel's add action: a soft card pill on the head band. */
|
||||
export const HEAD_ACTION = 'inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-surface-card px-2.5 py-1 font-semibold text-content-muted shadow-sm hover:text-content'
|
||||
const HEAD_CONTROL = 'inline-flex h-7 flex-none items-center justify-center rounded-full bg-surface-card text-content-muted shadow-sm hover:text-content'
|
||||
export const HEAD_ACTION = `${HEAD_CONTROL} gap-1 whitespace-nowrap px-2.5 font-semibold`
|
||||
export const HEAD_ICON_ACTION = `${HEAD_CONTROL} w-7`
|
||||
|
||||
/**
|
||||
* The head band every Collab panel opens with, the same one the cards of the
|
||||
* other trip tabs carry: its icon and name in small capitals, how many there
|
||||
* other trip tabs carry: its icon, name and how many there
|
||||
* are, and its actions on the right.
|
||||
*/
|
||||
export default function CollabPanelHead({ icon: Icon, title, count, actions }: {
|
||||
@@ -18,8 +20,10 @@ export default function CollabPanelHead({ icon: Icon, title, count, actions }: {
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-h-[50px] flex-none items-center gap-2 border-b border-edge-faint px-4 py-2" style={{ background: NEUTRAL_TINT }}>
|
||||
<Icon size={14} strokeWidth={2} className="flex-none text-content-faint" />
|
||||
<h3 className="m-0 font-geist font-bold uppercase tracking-[.08em] text-content-faint" style={fs(11)}>{title}</h3>
|
||||
<span className="grid size-8 flex-none place-items-center rounded-[10px] bg-surface-input text-content-muted">
|
||||
<Icon size={16} strokeWidth={1.9} aria-hidden />
|
||||
</span>
|
||||
<h3 className="m-0 font-semibold text-content" style={fs(14, 'body')}>{title}</h3>
|
||||
{count != null && count > 0 && (
|
||||
<span className="rounded-full bg-surface-card px-2 py-[2px] font-geist font-bold text-content-muted" style={fs(10)}>{count}</span>
|
||||
)}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useId, useRef } from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import { Bookmark, Search, MapPin, MapPinned, Loader2, Trash2, Check, X } from 'lucide-react'
|
||||
import { Text, Link, Bookmark, Search, MapPin, MapPinned, Loader2, Trash2, Check, X } from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { AddRowButton, EditorField, INPUT, Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||
import NoteFormatToolbar from '../shared/NoteFormatToolbar'
|
||||
@@ -176,7 +176,7 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
|
||||
/>
|
||||
</EditorField>
|
||||
|
||||
<DialogSection
|
||||
<DialogSection icon={Text}
|
||||
label={<label htmlFor={`${fieldId}-description`}>{t('collections.description')}</label>}
|
||||
action={<NoteFormatToolbar textareaRef={descRef} onChange={setDescription} compact customTooltips />}
|
||||
>
|
||||
@@ -196,7 +196,7 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
|
||||
)}
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('collections.links')}>
|
||||
<DialogSection icon={Link} label={t('collections.links')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{links.map((l, i) => (
|
||||
<div key={i} className="flex items-center gap-2">
|
||||
|
||||
@@ -228,7 +228,7 @@ export default function CollectionPicker({ bias, onSelect, t }: CollectionPicker
|
||||
// of different widths flanking one form read as a mistake rather than a
|
||||
// hierarchy, and neither of them is the more important one.
|
||||
<aside className={`${SIDE_COLUMN} sm:w-80`}>
|
||||
<ColumnHead icon={<Bookmark size={13} strokeWidth={2.2} />}>{t('collections.picker.title')}</ColumnHead>
|
||||
<ColumnHead icon={<Bookmark size={16} strokeWidth={2} />}>{t('collections.picker.title')}</ColumnHead>
|
||||
<div className="flex flex-none flex-col gap-2 px-3 pb-2.5">
|
||||
<EditorField label={t('common.search')} htmlFor={searchId}>
|
||||
<div className="relative">
|
||||
|
||||
@@ -330,7 +330,7 @@ export default function ImportCollectionModal({
|
||||
disabled={reading}
|
||||
aria-busy={reading}
|
||||
className={`flex min-h-[132px] w-full flex-col items-center justify-center gap-1.5 rounded-[14px] border-2 border-dashed p-4 transition-colors ${
|
||||
dragging ? 'border-accent bg-surface-tertiary' : 'border-edge bg-surface-secondary hover:border-content-faint'
|
||||
dragging ? 'border-accent bg-surface-tertiary' : 'border-edge bg-surface-input hover:border-content-faint'
|
||||
}`}
|
||||
>
|
||||
{reading
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useId, useState } from 'react'
|
||||
import { Plus, Settings2, Trash2, Loader2 } from 'lucide-react'
|
||||
import { Tags, Plus, Settings2, Trash2, Loader2 } from 'lucide-react'
|
||||
import { DialogButton, DialogHeader, DialogSection, DialogShell, DialogTile, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { INPUT, PANEL } from '../shared/dialogParts'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
@@ -135,7 +135,7 @@ export default function LabelManager({ isOpen, labels, onCreate, onUpdate, onDel
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<DialogSection label={t('collections.labels.title')}>
|
||||
<DialogSection icon={Tags} label={t('collections.labels.title')}>
|
||||
{labels.length === 0 ? (
|
||||
<p className="m-0 rounded-[12px] bg-surface-secondary px-4 py-5 text-center text-content-faint" style={fs(12.5, 'body')}>{t('collections.labels.empty')}</p>
|
||||
) : (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { createElement, useId } from 'react'
|
||||
import { ImagePlus, Trash2, Search, Loader2 } from 'lucide-react'
|
||||
import { Image, Link, ImagePlus, Trash2, Search, Loader2 } from 'lucide-react'
|
||||
import { DeleteButton, DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, fs } from '../shared/DialogShell'
|
||||
import { AddRowButton, EditorField, INPUT, TEXTAREA } from '../shared/dialogParts'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
@@ -80,11 +80,11 @@ export default function ListEditorModal({ target, onClose, onCreated, onRequestD
|
||||
return (
|
||||
// Pinned at the top: the photo results grow the body under the search.
|
||||
<DialogShell onClose={onClose} labelledBy={labelId} width="detail" align="top" header={header} footer={footer}>
|
||||
<DialogSection label={t('collections.coverImage')}>
|
||||
<DialogSection icon={Image} label={t('collections.coverImage')}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => fileRef.current?.click()}
|
||||
className="relative flex h-32 w-full items-center justify-center overflow-hidden rounded-[14px] border border-edge-faint bg-surface-secondary transition-colors hover:border-content-faint"
|
||||
className="relative flex h-32 w-full items-center justify-center overflow-hidden rounded-[10px] border border-dashed border-edge bg-surface-input transition-colors hover:border-content-faint"
|
||||
>
|
||||
{coverPreview && <img src={coverPreview} alt="" className="absolute inset-0 h-full w-full object-cover" />}
|
||||
<span className="absolute inset-0" style={{ background: `linear-gradient(135deg, color-mix(in srgb, ${color} 33%, transparent), transparent 70%)` }} />
|
||||
@@ -191,7 +191,7 @@ export default function ListEditorModal({ target, onClose, onCreated, onRequestD
|
||||
/>
|
||||
</EditorField>
|
||||
|
||||
<DialogSection label={t('collections.links')}>
|
||||
<DialogSection icon={Link} label={t('collections.links')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{links.map((l, i) => (
|
||||
<div key={i} className="flex items-center gap-2">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useId } from 'react'
|
||||
import { Bookmark, BookmarkCheck, Check, CheckCircle2, Loader2, Plus } from 'lucide-react'
|
||||
import { Bookmark, BookmarkCheck, Check, CheckCircle2, List, Loader2, Plus } from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, PILL, fs } from '../shared/DialogShell'
|
||||
import { CardHead, PANEL } from '../shared/dialogParts'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import StatusBadge from './StatusBadge'
|
||||
import { VISITED_EVERYWHERE_BUSY, useSaveToCollection } from './useSaveToCollection'
|
||||
@@ -55,51 +56,53 @@ export default function SaveToCollectionModal(): React.ReactElement | null {
|
||||
<Loader2 size={20} className="animate-spin" />
|
||||
</div>
|
||||
) : lists.length === 0 ? (
|
||||
<div className="flex flex-col items-center px-4 py-6 text-center">
|
||||
<div className="mb-3 grid h-11 w-11 place-items-center rounded-2xl bg-surface-secondary text-content-faint">
|
||||
<Bookmark size={20} />
|
||||
<div className={PANEL}>
|
||||
<div className="flex flex-col items-center gap-3 rounded-[10px] bg-surface-input px-4 py-5 text-center">
|
||||
<p className="m-0 text-body text-content-muted">{t('collections.noListsYet')}</p>
|
||||
<DialogButton variant="primary" onClick={openCollections} icon={<Plus size={14} strokeWidth={2.2} />}>{t('collections.newList')}</DialogButton>
|
||||
</div>
|
||||
<p className="m-0 mb-4 text-content-faint" style={fs(13, 'body')}>{t('collections.noListsYet')}</p>
|
||||
<DialogButton variant="primary" onClick={openCollections} icon={<Plus size={14} strokeWidth={2.2} />}>{t('collections.newList')}</DialogButton>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-0.5 rounded-[14px] border border-edge-faint bg-surface-secondary p-1.5">
|
||||
{lists.map(list => {
|
||||
const entry = savedByCollection.get(list.id)
|
||||
const saved = !!entry
|
||||
const busy = busyId === list.id
|
||||
return (
|
||||
<button
|
||||
key={list.id}
|
||||
type="button"
|
||||
aria-pressed={saved}
|
||||
onClick={() => handleToggle(list)}
|
||||
disabled={busyId != null}
|
||||
className={`flex min-h-[46px] items-center gap-3 rounded-[10px] px-3 py-2 text-start disabled:opacity-60 ${saved ? 'bg-surface-card shadow-sm' : 'hover:bg-surface-card'}`}
|
||||
>
|
||||
<span className="h-2.5 w-2.5 flex-none rounded-full" style={{ background: list.color || 'var(--accent)' }} />
|
||||
<span className="min-w-0 flex-1 truncate font-semibold text-content" style={fs(13, 'body')}>{list.name}</span>
|
||||
{list.is_owner === false && (
|
||||
<span className="flex-none rounded-full bg-surface-tertiary px-2 py-[2px] font-semibold text-content-muted" style={fs(10.5)}>{t('collections.shared')}</span>
|
||||
)}
|
||||
{/* Per-list status, so one place can be an idea in one list and
|
||||
visited in another. A role=button span, safe to nest here. */}
|
||||
{entry && (
|
||||
<StatusBadge
|
||||
status={entry.status}
|
||||
showLabel={false}
|
||||
size={12}
|
||||
onChange={entry.can_edit ? next => { void handleStatus(entry, next) } : undefined}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
<span className={`grid h-6 w-6 flex-none place-items-center rounded-[8px] ${saved ? 'bg-accent text-accent-text' : 'border border-edge bg-surface-card text-transparent'}`}>
|
||||
{busy ? <Loader2 size={13} className="animate-spin text-content-faint" /> : saved ? <BookmarkCheck size={13} /> : <Check size={13} />}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<List size={16} />} title={t('collections.pickListPlaceholder')} />
|
||||
<div className="flex flex-col gap-1">
|
||||
{lists.map(list => {
|
||||
const entry = savedByCollection.get(list.id)
|
||||
const saved = !!entry
|
||||
const busy = busyId === list.id
|
||||
return (
|
||||
<button
|
||||
key={list.id}
|
||||
type="button"
|
||||
aria-pressed={saved}
|
||||
onClick={() => handleToggle(list)}
|
||||
disabled={busyId != null}
|
||||
className={`flex min-h-[46px] items-center gap-3 rounded-[10px] px-3 py-2 text-start disabled:opacity-60 bg-surface-input hover:bg-surface-hover ${saved ? 'ring-1 ring-content' : ''}`}
|
||||
>
|
||||
<span className="h-2.5 w-2.5 flex-none rounded-full" style={{ background: list.color || 'var(--accent)' }} />
|
||||
<span className="min-w-0 flex-1 truncate font-semibold text-content" style={fs(13, 'body')}>{list.name}</span>
|
||||
{list.is_owner === false && (
|
||||
<span className="flex-none rounded-full bg-surface-tertiary px-2 py-[2px] font-semibold text-content-muted" style={fs(10.5)}>{t('collections.shared')}</span>
|
||||
)}
|
||||
{/* Per-list status, so one place can be an idea in one list and
|
||||
visited in another. A role=button span, safe to nest here. */}
|
||||
{entry && (
|
||||
<StatusBadge
|
||||
status={entry.status}
|
||||
showLabel={false}
|
||||
size={12}
|
||||
onChange={entry.can_edit ? next => { void handleStatus(entry, next) } : undefined}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
<span className={`grid h-6 w-6 flex-none place-items-center rounded-[8px] ${saved ? 'bg-accent text-accent-text' : 'border border-edge bg-surface-card text-transparent'}`}>
|
||||
{busy ? <Loader2 size={13} className="animate-spin text-content-faint" /> : saved ? <BookmarkCheck size={13} /> : <Check size={13} />}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</DialogShell>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useId, type ReactNode } from 'react'
|
||||
import { avatarSrc } from '../../utils/avatarSrc'
|
||||
import { UserPlus, UserMinus, UserX, Loader2, Clock, Crown, LogOut, Share2 } from 'lucide-react'
|
||||
import { Users, UserPlus, UserMinus, UserX, Loader2, Clock, Crown, LogOut, Share2 } from 'lucide-react'
|
||||
import type { CollectionMember, CollectionRole } from '@trek/shared'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
@@ -103,7 +103,7 @@ export default function ShareCollectionModal({
|
||||
)}
|
||||
>
|
||||
{isOwner && (
|
||||
<DialogSection label={t('collections.share.invite')}>
|
||||
<DialogSection icon={UserPlus} label={t('collections.share.invite')}>
|
||||
<p className="m-0 mb-2.5 leading-normal text-content-faint" style={fs(11.5)}>{t('collections.share.inviteHint')}</p>
|
||||
{availableUsers.length === 0 ? (
|
||||
<p className="m-0 rounded-[12px] border border-dashed border-edge px-3 py-3 text-center text-content-faint" style={fs(12, 'body')}>
|
||||
@@ -137,7 +137,7 @@ export default function ShareCollectionModal({
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
<DialogSection label={(
|
||||
<DialogSection icon={Users} label={(
|
||||
<span className="inline-flex items-center gap-2">
|
||||
{t('collections.share.members')}
|
||||
<span className={COUNT} style={fs(10)}>{sortedMembers.length}</span>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { CalendarCheck } from 'lucide-react';
|
||||
import React, { useMemo } from 'react';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { BOX } from '../Planner/bookings/bookingParts';
|
||||
import { DialogSection } from '../shared/DialogShell';
|
||||
import { visitDate } from './libraryDates';
|
||||
import { tripPlaceEntry, usePlaceVisits } from './usePlaceVisits';
|
||||
|
||||
@@ -26,11 +27,10 @@ export default function TripPlaceVisits({
|
||||
const last = visitDate(v.lastVisit, null, language);
|
||||
if (v.count === 0 || !last) return null;
|
||||
return (
|
||||
<div className={`${BOX} flex flex-none items-center gap-2.5 px-3 py-2`}>
|
||||
<CalendarCheck size={15} className="flex-none text-success" />
|
||||
<span className="min-w-0 flex-1 truncate text-body text-content-secondary">
|
||||
<DialogSection icon={CalendarCheck} label={t('visits.title')}>
|
||||
<p className={`${BOX} m-0 px-3 py-2 text-body text-content-secondary`}>
|
||||
{t('visits.summary', { count: v.count, date: last })}
|
||||
</span>
|
||||
</div>
|
||||
</p>
|
||||
</DialogSection>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ArrowLeft, ArrowRight, Clock, ExternalLink, Images, RotateCcw } from 'lucide-react';
|
||||
import { Compass, Lock, Sparkles, ArrowLeft, ArrowRight, Clock, ExternalLink, Images, RotateCcw } from 'lucide-react';
|
||||
import { lazy, Suspense, useId } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
@@ -80,15 +80,15 @@ function WelcomeBody({ t }: { t: Translate }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogSection label={t('demo.welcome.tryTitle')}>
|
||||
<DialogSection icon={Compass} label={t('demo.welcome.tryTitle')}>
|
||||
<FeatureGrid t={t} />
|
||||
</DialogSection>
|
||||
|
||||
<div className="grid gap-5 md:grid-cols-2">
|
||||
<DialogSection label={t('demo.welcome.limitsTitle')}>
|
||||
<DialogSection icon={Lock} label={t('demo.welcome.limitsTitle')}>
|
||||
<LineList lines={DEMO_LIMITS} tone="muted" t={t} />
|
||||
</DialogSection>
|
||||
<DialogSection label={t('demo.welcome.fullTitle')}>
|
||||
<DialogSection icon={Sparkles} label={t('demo.welcome.fullTitle')}>
|
||||
<LineList lines={DEMO_FULL_VERSION} tone="accent" t={t} />
|
||||
</DialogSection>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Fragment } from 'react'
|
||||
import { Upload, Star } from 'lucide-react'
|
||||
import { Fragment, useId } from 'react'
|
||||
import { LoaderCircle, Upload, Star } from 'lucide-react'
|
||||
import type { FileManagerState } from './useFileManager'
|
||||
import { FileRow } from './FileManagerRow'
|
||||
import { usePluginViewContributions, PluginCardFooter } from '../Plugins/PluginContributions'
|
||||
@@ -11,30 +11,28 @@ export function FilesView(S: FileManagerState) {
|
||||
files, filterType, setFilterType, filteredFiles,
|
||||
} = S
|
||||
const contribFor = usePluginViewContributions('files', S.tripId)
|
||||
const uploadHintId = useId()
|
||||
const formats = (allowedFileTypes || 'jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv')
|
||||
.split(',').map(extension => extension.trim().toUpperCase()).filter(Boolean).join(', ')
|
||||
return (
|
||||
<>
|
||||
{/* Upload zone */}
|
||||
{can('file_upload', trip) && <div
|
||||
{...getRootProps()}
|
||||
className={`mx-7 mt-4 cursor-pointer rounded-2xl border-2 border-dashed px-4 py-5 text-center transition-colors max-md:mx-4 ${isDragActive ? 'border-content-muted bg-surface-tertiary' : 'border-edge bg-surface-secondary hover:border-content-faint'}`}
|
||||
{...getRootProps({ role: 'button', 'aria-label': t('common.upload'), 'aria-describedby': uploadHintId, 'aria-busy': uploading })}
|
||||
className={`mx-7 mt-4 flex cursor-pointer flex-wrap items-center gap-3 rounded-2xl border border-dashed px-4 py-4 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent max-md:mx-4 ${isDragActive ? 'border-content-muted bg-surface-tertiary' : 'border-edge bg-surface-secondary hover:border-content-muted'}`}
|
||||
>
|
||||
<input {...getInputProps()} />
|
||||
<Upload size={24} style={{ margin: '0 auto 8px', color: isDragActive ? 'var(--text-secondary)' : 'var(--text-faint)', display: 'block' }} />
|
||||
{uploading ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6, fontSize: 'calc(13px * var(--fs-scale-body, 1))', color: 'var(--text-secondary)' }}>
|
||||
<div style={{ width: 14, height: 14, border: '2px solid var(--text-secondary)', borderTopColor: 'transparent', borderRadius: '50%', animation: 'spin 0.8s linear infinite' }} />
|
||||
{t('files.uploading')}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<p style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', color: 'var(--text-secondary)', fontWeight: 500, margin: 0 }}>{t('files.dropzone')}</p>
|
||||
<p style={{ fontSize: 'calc(11.5px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)', marginTop: 3 }}>{t('files.dropzoneHint')}</p>
|
||||
<p style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)', marginTop: 6, opacity: 0.7 }}>
|
||||
{(allowedFileTypes || 'jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv').toUpperCase().split(',').join(', ')}
|
||||
</p>
|
||||
<span className="mt-1.5 inline-block rounded-full bg-surface-card px-2 py-[2px] font-geist font-semibold text-content-faint" style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))' }}>{t('files.maxSize', { count: S.maxUploadMb })}</span>
|
||||
</>
|
||||
)}
|
||||
<span className="grid size-10 shrink-0 place-items-center rounded-xl bg-surface-input text-content-muted">
|
||||
{uploading ? <LoaderCircle size={18} className="animate-spin" aria-hidden /> : <Upload size={18} aria-hidden />}
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p aria-live="polite" className="m-0 text-body font-semibold text-content">{t(uploading ? 'files.uploading' : 'files.dropzone')}</p>
|
||||
<p id={uploadHintId} className="mb-0 mt-1 text-caption text-content-muted">{formats}</p>
|
||||
</div>
|
||||
<div className="ms-auto flex shrink-0 flex-wrap items-center gap-2">
|
||||
<span className="rounded-full bg-surface-input px-2 py-0.5 text-[length:calc(11px*var(--fs-scale-caption,1))] font-medium leading-4 text-content-muted">{t('files.maxSize', { count: S.maxUploadMb })}</span>
|
||||
<span className="inline-flex min-h-9 items-center rounded-full bg-accent px-4 text-control font-semibold text-accent-text">{t('common.upload')}</span>
|
||||
</div>
|
||||
</div>}
|
||||
|
||||
{/* Filter tabs */}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useId, useState } from 'react'
|
||||
import { AlertTriangle, Check, Loader2, Plug, ShieldAlert } from 'lucide-react'
|
||||
import { DeleteButton, DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../../shared/DialogShell'
|
||||
import { CardHead, INPUT, PANEL } from '../../shared/dialogParts'
|
||||
import ConfirmDialog from '../../shared/ConfirmDialog'
|
||||
import { Tooltip } from '../../shared/Tooltip'
|
||||
import ToggleSwitch from '../../Settings/ToggleSwitch'
|
||||
@@ -86,8 +87,9 @@ export default function DocSyncConnectModal({
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<p className="text-caption text-content-muted">{t(`docsync.connect.about.${provider.id}`)}</p>
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Plug size={16} />} title={t('docsync.connection.title')} />
|
||||
<p className="m-0 text-caption text-content-muted">{t(`docsync.connect.about.${provider.id}`)}</p>
|
||||
|
||||
{form.fields.map(f => (
|
||||
<Field
|
||||
@@ -101,12 +103,12 @@ export default function DocSyncConnectModal({
|
||||
value={form.valueOf(f.field_key)}
|
||||
placeholder={form.placeholderOf(f)}
|
||||
onChange={e => form.setValue(f.field_key, e.target.value)}
|
||||
className="w-full rounded-lg border border-edge bg-surface-input px-3 py-2.5 text-body text-content ring-accent transition-shadow placeholder:text-content-faint focus:outline-none focus:ring-2"
|
||||
className={INPUT}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
|
||||
<div className="flex items-start justify-between gap-4 rounded-lg border border-edge bg-surface-secondary px-3 py-2.5">
|
||||
<div className="flex items-start justify-between gap-4 rounded-[10px] border border-edge bg-surface-input px-3 py-2.5">
|
||||
<span className="min-w-0">
|
||||
<span className="block text-body text-content">{t('docsync.allowInsecureTls')}</span>
|
||||
<span id={`${labelId}-tls-hint`} className="mt-0.5 block text-caption text-content-muted">
|
||||
@@ -117,7 +119,7 @@ export default function DocSyncConnectModal({
|
||||
<ToggleSwitch on={form.insecureTls} onToggle={() => form.setInsecureTls(!form.insecureTls)} label={t('docsync.allowInsecureTls')} describedBy={`${labelId}-tls-hint`} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<ConfirmDialog
|
||||
isOpen={confirmRemove}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Clock, FilePen, Loader2, RefreshCw, Route, Users } from 'lucide-react';
|
||||
import { Map, Bed, Clock, FilePen, Loader2, RefreshCw, Route, Users } from 'lucide-react';
|
||||
import { useDateFormat } from '../../hooks/useDateFormat';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
@@ -120,7 +120,7 @@ function DayEntries({ state }: { state: JourneyDayImportState }) {
|
||||
const entries = state.review?.entries ?? [];
|
||||
if (entries.length === 0) return null;
|
||||
return (
|
||||
<DialogSection label={t('journey.dayImport.existing')}>
|
||||
<DialogSection icon={Map} label={t('journey.dayImport.existing')}>
|
||||
<ul className="m-0 flex list-none flex-col gap-1 p-0">
|
||||
{entries.map((entry) => (
|
||||
<li
|
||||
@@ -182,7 +182,7 @@ export function JourneyDayImportReview({ state, dayColor, prep }: Props) {
|
||||
return (
|
||||
<>
|
||||
<DayNotices state={state} prep={prep} />
|
||||
<DialogSection label={t('journey.dayImport.map')}>
|
||||
<DialogSection icon={Map} label={t('journey.dayImport.map')}>
|
||||
<div className="flex flex-col gap-2.5">
|
||||
<div className="overflow-hidden rounded-[12px] border border-edge-faint">
|
||||
<JourneyMap
|
||||
@@ -197,7 +197,7 @@ export function JourneyDayImportReview({ state, dayColor, prep }: Props) {
|
||||
<RouteLine state={state} />
|
||||
</div>
|
||||
</DialogSection>
|
||||
<DialogSection
|
||||
<DialogSection icon={Bed}
|
||||
label={t('journey.dayImport.stays')}
|
||||
action={
|
||||
choice && review.stays.length > 1 ? (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useId, useState, useRef, type SyntheticEvent } from 'react'
|
||||
import { Briefcase, X, Plus, Image, Minus, Check, MapPin, Locate, Camera, Play, Loader2, NotebookPen } from 'lucide-react'
|
||||
import { ListChecks, Tags, Briefcase, X, Plus, Image, Minus, Check, MapPin, Locate, Camera, Play, Loader2, NotebookPen } from 'lucide-react'
|
||||
import { isVideoFile } from '../../utils/videoPoster'
|
||||
import { type ResilientResult, type UploadProgress } from '../../utils/uploadQueue'
|
||||
import { useTranslation } from '../../i18n'
|
||||
@@ -417,7 +417,7 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
|
||||
<div className="flex min-w-0 flex-col gap-5">
|
||||
{/* Pros & Cons: gone entirely when the journey does not keep a verdict */}
|
||||
{showVerdict && (
|
||||
<DialogSection label={t('journey.editor.prosCons')}>
|
||||
<DialogSection icon={ListChecks} label={t('journey.editor.prosCons')}>
|
||||
<div className="grid grid-cols-2 gap-3 rounded-[14px] border border-edge-faint bg-surface-secondary p-3">
|
||||
<VerdictColumn
|
||||
list="pros"
|
||||
@@ -448,7 +448,7 @@ export function EntryEditor({ entry, journeyId, tripDates, galleryPhotos, trips,
|
||||
)}
|
||||
|
||||
{/* Tags: the same field the phone sheet has, and what the journal search filters by */}
|
||||
<DialogSection label={t('journey.editor.tags')}>
|
||||
<DialogSection icon={Tags} label={t('journey.editor.tags')}>
|
||||
<div className="flex flex-wrap items-center gap-1.5 rounded-[10px] border border-edge bg-surface-input px-3 py-2">
|
||||
{tags.map(tag => (
|
||||
<span key={tag} className="inline-flex items-center gap-1 rounded-full bg-surface-tertiary px-2.5 py-1 font-semibold text-content" style={fs(12, 'caption')}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, useState, useRef, type ReactNode } from 'react'
|
||||
import { X, ImagePlus, Trash2, Archive, ArchiveRestore, Undo2, Settings, Crown } from 'lucide-react'
|
||||
import { Image, CircleCheck, Route, Radio, SlidersHorizontal, Link, Users, X, ImagePlus, Trash2, Archive, ArchiveRestore, Undo2, Settings, Crown } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
@@ -114,12 +114,12 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
>
|
||||
<div className="grid grid-cols-2 items-start gap-6 max-md:grid-cols-1">
|
||||
<div className="flex flex-col gap-5">
|
||||
<DialogSection label={t('journey.settings.coverImage')}>
|
||||
<DialogSection icon={Image} label={t('journey.settings.coverImage')}>
|
||||
<input ref={coverRef} type="file" accept="image/*" onChange={handleCoverUpload} className="hidden" />
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => coverRef.current?.click()}
|
||||
className="relative flex h-28 w-full items-center justify-center overflow-hidden rounded-[14px] border border-edge-faint bg-surface-secondary transition-colors hover:border-content-faint"
|
||||
className="relative flex h-28 w-full items-center justify-center overflow-hidden rounded-[10px] border border-dashed border-edge bg-surface-input transition-colors hover:border-content-faint"
|
||||
>
|
||||
{journey.cover_image && <img src={`/uploads/${journey.cover_image}`} className="absolute inset-0 h-full w-full object-cover" alt="" />}
|
||||
{/* A chip rather than bare text, so it reads the same on any photo. */}
|
||||
@@ -140,7 +140,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
</EditorField>
|
||||
|
||||
{/* The journey's state, by hand or from the trips (#762) */}
|
||||
<DialogSection label={t('journey.settings.status')}>
|
||||
<DialogSection icon={CircleCheck} label={t('journey.settings.status')}>
|
||||
<div className={savingStatus ? 'opacity-60' : undefined}>
|
||||
<Segmented<'auto' | 'draft' | 'live' | 'completed'>
|
||||
label={t('journey.settings.status')}
|
||||
@@ -161,7 +161,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
</DialogSection>
|
||||
|
||||
{/* Trip GPX tracks on the journey map (#2194) */}
|
||||
<DialogSection label={t('journey.settings.tracks')}>
|
||||
<DialogSection icon={Route} label={t('journey.settings.tracks')}>
|
||||
<div className={ROWS}>
|
||||
<div className={`${ROW}${savingTracks ? ' opacity-60' : ''}`}>
|
||||
<span className="min-w-0 flex-1">
|
||||
@@ -179,7 +179,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
|
||||
{/* Days recorded in Dawarich, prepared for review while a trip runs (JRN-03) */}
|
||||
{recordingPrep && (
|
||||
<DialogSection label={t('journey.settings.recordings')}>
|
||||
<DialogSection icon={Radio} label={t('journey.settings.recordings')}>
|
||||
<div className={ROWS}>
|
||||
<JourneyRecordingPrepRow on={!!journey.auto_prepare_recordings} prep={recordingPrep} rowClass={ROW} />
|
||||
</div>
|
||||
@@ -188,7 +188,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
)}
|
||||
|
||||
{/* Places from photos (#1003): the GPS a picture carries puts its entry on the map */}
|
||||
<DialogSection label={t('journey.settings.photosSection')}>
|
||||
<DialogSection icon={Image} label={t('journey.settings.photosSection')}>
|
||||
<div className={ROWS}>
|
||||
<div className={`${ROW}${savingPhotoLocation ? ' opacity-60' : ''}`}>
|
||||
<span className="min-w-0 flex-1">
|
||||
@@ -205,7 +205,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
</DialogSection>
|
||||
|
||||
{/* The three fields a journey may put away (discussion #2299) */}
|
||||
<DialogSection label={t('journey.settings.entryFields')}>
|
||||
<DialogSection icon={SlidersHorizontal} label={t('journey.settings.entryFields')}>
|
||||
<p className="m-0 mb-2.5 leading-normal text-content-faint" style={fs(11.5)}>{t('journey.settings.entryFieldsHint')}</p>
|
||||
<div className={ROWS}>
|
||||
{([
|
||||
@@ -246,7 +246,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-5">
|
||||
<DialogSection label={t('journey.detail.syncedTrips')}>
|
||||
<DialogSection icon={Link} label={t('journey.detail.syncedTrips')}>
|
||||
{journey.trips.length > 0 ? (
|
||||
<div className={`${ROWS} mb-2.5`}>
|
||||
{journey.trips.map(trip => (
|
||||
@@ -268,7 +268,7 @@ export function JourneySettingsDialog({ journey, onClose, onSaved, onOpenInvite,
|
||||
<AddRowButton onClick={() => setShowAddTrip(true)}>{t('journey.trips.addTrip')}</AddRowButton>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('journey.detail.contributors')}>
|
||||
<DialogSection icon={Users} label={t('journey.detail.contributors')}>
|
||||
<div className={`${ROWS} mb-2.5`}>
|
||||
{journey.contributors.map(c => (
|
||||
<div key={c.user_id} className={ROW}>
|
||||
@@ -352,7 +352,7 @@ function TripAccessSection({ access, roleLabel }: {
|
||||
const { t } = useTranslation()
|
||||
if (!access?.length) return null
|
||||
return (
|
||||
<DialogSection label={t('journey.contributors.viaTrips')}>
|
||||
<DialogSection icon={Users} label={t('journey.contributors.viaTrips')}>
|
||||
<p className="m-0 mb-2.5 leading-normal text-content-faint" style={fs(11.5)}>{t('journey.contributors.viaTripsHint')}</p>
|
||||
<div className={ROWS}>
|
||||
{access.map(a => (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { JourneyRecordedDay, JourneyRecordingPreview } from '@trek/shared';
|
||||
import { AlertTriangle, Clock, Info, Loader2, RefreshCw, Route, Users } from 'lucide-react';
|
||||
import { Globe, ListFilter, AlertTriangle, Clock, Info, Loader2, RefreshCw, Route, Users } from 'lucide-react';
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
@@ -205,7 +205,7 @@ export function JourneyRecordingReview({
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<DialogSection label={t('journey.recording.zone')}>
|
||||
<DialogSection icon={Globe} label={t('journey.recording.zone')}>
|
||||
<CustomSelect
|
||||
ariaLabel={t('journey.recording.zone')}
|
||||
value={day.zone}
|
||||
@@ -217,7 +217,7 @@ export function JourneyRecordingReview({
|
||||
{t('journey.recording.zoneHint')}
|
||||
</p>
|
||||
</DialogSection>
|
||||
<DialogSection label={t('journey.recording.scope')}>
|
||||
<DialogSection icon={ListFilter} label={t('journey.recording.scope')}>
|
||||
<RecordingState day={day} stored={stored ?? day.preview?.stored ?? undefined} />
|
||||
</DialogSection>
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import React, { useEffect, useId, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { Bell, Trash2, CheckCheck } from 'lucide-react'
|
||||
import { Bell, Trash2, CheckCheck, ChevronRight } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useInAppNotificationStore } from '../../store/inAppNotificationStore.ts'
|
||||
import { useAuthStore } from '../../store/authStore'
|
||||
import NotificationDayList from '../Notifications/NotificationDayList'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import EmptyState from '../shared/EmptyState'
|
||||
import { useOverlay } from '../../hooks/overlayStack'
|
||||
|
||||
export default function InAppNotificationBell(): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
@@ -17,6 +19,16 @@ export default function InAppNotificationBell(): React.ReactElement {
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
const [confirmingDeleteAll, setConfirmingDeleteAll] = useState(false)
|
||||
const popupId = useId()
|
||||
const trigger = useRef<HTMLButtonElement>(null)
|
||||
const showAll = useRef<HTMLButtonElement>(null)
|
||||
useOverlay(open && !confirmingDeleteAll, () => {
|
||||
setOpen(false)
|
||||
trigger.current?.focus()
|
||||
}, true)
|
||||
useEffect(() => {
|
||||
if (open) showAll.current?.focus({ preventScroll: true })
|
||||
}, [open])
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated) {
|
||||
@@ -41,9 +53,12 @@ export default function InAppNotificationBell(): React.ReactElement {
|
||||
return (
|
||||
<div className="relative flex-shrink-0">
|
||||
<button type="button"
|
||||
ref={trigger}
|
||||
onClick={handleOpen}
|
||||
title={t('notifications.title')}
|
||||
className="relative p-2 rounded-lg transition-colors text-content-muted hover:bg-surface-hover focus-visible:bg-surface-hover"
|
||||
aria-expanded={open}
|
||||
aria-controls={open ? popupId : undefined}
|
||||
className={`relative rounded-full p-2 text-content-muted transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover ${open ? 'bg-surface-hover' : ''}`}
|
||||
>
|
||||
<Bell className="w-4 h-4" />
|
||||
{unreadCount > 0 && (
|
||||
@@ -65,42 +80,43 @@ export default function InAppNotificationBell(): React.ReactElement {
|
||||
|
||||
{open && createPortal(
|
||||
<>
|
||||
{/* Click-away catcher only — the bell button itself closes the panel again from the keyboard. */}
|
||||
{/* Click-away catcher. */}
|
||||
<div role="presentation" style={{ position: 'fixed', inset: 0, zIndex: 9998 }} onClick={() => setOpen(false)} />
|
||||
<div
|
||||
className="rounded-2xl shadow-xl border overflow-hidden bg-surface-card border-edge"
|
||||
id={popupId}
|
||||
className="trek-desktop-panel trek-menu-enter gap-2 overflow-hidden rounded-[20px] border border-edge bg-surface-card p-2 shadow-xl"
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 'var(--nav-h)',
|
||||
insetInlineEnd: 8,
|
||||
width: 400,
|
||||
maxWidth: 'calc(100vw - 16px)',
|
||||
maxHeight: 'min(560px, calc(100vh - var(--nav-h) - 16px))',
|
||||
top: 'calc(var(--nav-h) + 6px)',
|
||||
insetInlineEnd: 12,
|
||||
width: 360,
|
||||
maxWidth: 'calc(100vw - 24px)',
|
||||
maxHeight: 'min(560px, calc(100dvh - var(--nav-h) - 18px))',
|
||||
zIndex: 9999,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}
|
||||
>
|
||||
{/* Header: the dialogs' head, a tile, the name and how many are unread, the tools at the end. */}
|
||||
<div className="flex items-center gap-3 px-4 pt-4 pb-3 flex-shrink-0">
|
||||
<span className="grid place-items-center w-9 h-9 rounded-xl bg-accent-subtle text-accent flex-shrink-0">
|
||||
<Bell className="w-4 h-4" />
|
||||
<div className="flex shrink-0 items-center gap-2.5 rounded-xl bg-surface-secondary p-2.5">
|
||||
<span className="grid size-8 shrink-0 place-items-center rounded-lg bg-surface-input text-content-muted">
|
||||
<Bell size={16} aria-hidden />
|
||||
</span>
|
||||
<span className="flex-1 min-w-0 flex items-center gap-2 text-subtitle font-semibold text-content">
|
||||
<h2 className="m-0 flex min-w-0 flex-1 items-center gap-2 text-body font-semibold text-content">
|
||||
{t('notifications.title')}
|
||||
{unreadCount > 0 && (
|
||||
<span className="px-2 h-5 inline-flex items-center rounded-full text-caption font-semibold tabular-nums bg-accent text-accent-text">
|
||||
{unreadCount}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</h2>
|
||||
<div className="flex items-center gap-1">
|
||||
{unreadCount > 0 && (
|
||||
<button type="button"
|
||||
onClick={markAllRead}
|
||||
title={t('notifications.markAllRead')}
|
||||
aria-label={t('notifications.markAllRead')}
|
||||
className="grid place-items-center w-8 h-8 rounded-lg transition-colors text-content-muted bg-surface-secondary hover:bg-surface-hover hover:text-content focus-visible:bg-surface-hover"
|
||||
className="grid size-8 place-items-center rounded-full bg-surface-input text-content-muted transition-colors hover:bg-surface-hover hover:text-content focus-visible:bg-surface-hover"
|
||||
>
|
||||
<CheckCheck className="w-4 h-4" />
|
||||
</button>
|
||||
@@ -110,7 +126,7 @@ export default function InAppNotificationBell(): React.ReactElement {
|
||||
onClick={() => setConfirmingDeleteAll(true)}
|
||||
title={t('notifications.deleteAll')}
|
||||
aria-label={t('notifications.deleteAll')}
|
||||
className="grid place-items-center w-8 h-8 rounded-lg transition-colors text-content-muted bg-surface-secondary hover:bg-danger-soft hover:text-danger focus-visible:bg-danger-soft"
|
||||
className="grid size-8 place-items-center rounded-full bg-surface-input text-content-muted transition-colors hover:bg-danger-soft hover:text-danger focus-visible:bg-danger-soft"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
@@ -119,31 +135,28 @@ export default function InAppNotificationBell(): React.ReactElement {
|
||||
</div>
|
||||
|
||||
{/* Notification list */}
|
||||
<div className="overflow-y-auto flex-1 pb-1 border-t border-edge-secondary">
|
||||
<div className="min-h-0 flex-1 overflow-y-auto rounded-xl">
|
||||
{isLoading && notifications.length === 0 ? (
|
||||
<div className="flex items-center justify-center py-10">
|
||||
<div className="w-5 h-5 border-2 rounded-full animate-spin border-edge border-t-content" />
|
||||
</div>
|
||||
) : notifications.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center py-10 px-6 text-center gap-2">
|
||||
<span className="grid place-items-center w-12 h-12 rounded-2xl bg-surface-secondary text-content-faint">
|
||||
<Bell className="w-5 h-5" />
|
||||
</span>
|
||||
<p className="text-body font-semibold text-content">{t('notifications.empty')}</p>
|
||||
<p className="text-caption text-content-muted">{t('notifications.emptyDescription')}</p>
|
||||
</div>
|
||||
<EmptyState scene="notifications" size={62} title={t('notifications.empty')}
|
||||
action={<p className="m-0 text-caption text-content-muted">{t('notifications.emptyDescription')}</p>} />
|
||||
) : (
|
||||
<NotificationDayList notifications={notifications.slice(0, 10)} onClose={() => setOpen(false)} compact />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="p-2 flex-shrink-0 border-t border-edge-secondary">
|
||||
<div className="shrink-0 border-t border-edge-faint pt-2">
|
||||
<button type="button"
|
||||
ref={showAll}
|
||||
onClick={handleShowAll}
|
||||
className="w-full h-9 rounded-xl text-body font-medium transition-colors bg-surface-secondary text-content hover:bg-surface-hover focus-visible:bg-surface-hover"
|
||||
className="flex min-h-9 w-full items-center justify-between gap-2 rounded-xl bg-surface-secondary px-3 text-start text-control font-semibold text-content transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover"
|
||||
>
|
||||
{t('notifications.showAll')}
|
||||
<ChevronRight className="size-4 shrink-0 text-content-muted rtl:rotate-180" aria-hidden />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect, useRef } from 'react'
|
||||
import React, { useId, useState, useEffect, useRef } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { Link, useNavigate, useLocation } from 'react-router'
|
||||
import { useAuthStore } from '../../store/authStore'
|
||||
@@ -14,6 +14,7 @@ import AssistantLauncher from '../Assistant/AssistantLauncher'
|
||||
import { resolvePluginIcon } from '../shared/PluginIcon'
|
||||
import { visibleManagedNavItems } from '../../managed'
|
||||
import { useCollapseOnOverflow } from '../../hooks/useCollapseOnOverflow'
|
||||
import { useOverlay } from '../../hooks/overlayStack'
|
||||
import { openMailInbox } from '../MailIngest/mailInboxOpener'
|
||||
import { useMailInboxShell } from '../MailIngest/useMailInboxShell'
|
||||
import MailInboxDialog from '../MailIngest/MailInboxDialog'
|
||||
@@ -21,6 +22,9 @@ import { addonPath } from './navItems'
|
||||
import UserMenuFooter from './UserMenuFooter'
|
||||
|
||||
const ADDON_ICONS: Record<string, LucideIcon> = { CalendarDays, Briefcase, Globe, Compass, Bookmark }
|
||||
const USER_MENU_ACTION = 'flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 text-start text-sm font-medium transition-colors'
|
||||
const USER_MENU_LINK = `${USER_MENU_ACTION} text-content hover:bg-surface-hover`
|
||||
const USER_MENU_ICON = 'size-4 shrink-0 text-content-muted'
|
||||
|
||||
interface NavbarProps {
|
||||
tripTitle?: string
|
||||
@@ -47,6 +51,16 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const [userMenuOpen, setUserMenuOpen] = useState<boolean>(false)
|
||||
const userMenuId = useId()
|
||||
const userMenuTrigger = useRef<HTMLButtonElement>(null)
|
||||
const firstUserMenuAction = useRef<HTMLAnchorElement>(null)
|
||||
useOverlay(userMenuOpen, () => {
|
||||
setUserMenuOpen(false)
|
||||
userMenuTrigger.current?.focus()
|
||||
}, true)
|
||||
useEffect(() => {
|
||||
if (userMenuOpen) firstUserMenuAction.current?.focus({ preventScroll: true })
|
||||
}, [userMenuOpen])
|
||||
const [scrolled, setScrolled] = useState<boolean>(false)
|
||||
// The booking mail import's inbox: its menu entry shows only where the import is on for this person.
|
||||
const { on: mailImportOn, pending: mailPending } = useMailInboxShell(user?.id)
|
||||
@@ -166,34 +180,33 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
</span>
|
||||
)}
|
||||
|
||||
{/* In a trip the way back lives in the trip's own pill: arrow and name in one. */}
|
||||
{/* The trip title also takes you back when the parent view is available. */}
|
||||
{tripTitle && (showBack ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onBack}
|
||||
aria-label={`${t('common.back')}: ${tripTitle}`}
|
||||
className="trek-back-btn inline-flex min-w-0 max-w-64 items-center gap-1 rounded-full bg-surface-card py-1 ps-1.5 pe-3 text-content shadow-sm ring-1 ring-inset ring-edge-faint transition-colors hover:bg-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
className="trek-back-btn trek-desktop-panel inline-flex h-9 min-w-0 max-w-64 items-center gap-1.5 rounded-xl px-2.5 text-content transition-colors hover:bg-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
>
|
||||
<ChevronLeft className="trek-back-icon h-4 w-4 flex-none text-content-muted" aria-hidden="true" />
|
||||
<span className="truncate text-caption font-semibold">{tripTitle}</span>
|
||||
</button>
|
||||
) : (
|
||||
<span className="hidden sm:inline-flex min-w-0 max-w-56 items-center rounded-full bg-surface-card px-2.5 py-1 shadow-sm ring-1 ring-inset ring-edge-faint">
|
||||
<span className="hidden h-9 min-w-0 max-w-56 items-center px-2.5 sm:inline-flex">
|
||||
<span className="truncate text-caption font-semibold text-content">{tripTitle}</span>
|
||||
</span>
|
||||
))}
|
||||
|
||||
{/* The trip's Settings sit with the trip, beside its pill: they are about this
|
||||
trip, not about the app the right side of the bar belongs to. */}
|
||||
{onSettings && (
|
||||
// The same pill as the trip's own beside it, so the two read as one pair.
|
||||
<button
|
||||
type="button"
|
||||
onClick={onSettings}
|
||||
className="inline-flex flex-none items-center gap-1.5 rounded-full bg-surface-card py-1 ps-2 pe-3 text-content shadow-sm ring-1 ring-inset ring-edge-faint transition-colors hover:bg-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
aria-label={t('trip.settings.title')}
|
||||
title={t('trip.settings.title')}
|
||||
className="trek-desktop-panel inline-flex h-9 flex-none items-center gap-1.5 rounded-xl bg-surface-secondary px-2.5 text-content transition-colors hover:bg-surface-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
>
|
||||
<Settings className="h-4 w-4 flex-none text-content-muted" aria-hidden="true" />
|
||||
<span className="text-caption font-semibold">{t('trip.settings.title')}</span>
|
||||
<span className="hidden text-caption font-medium sm:inline">{t('trip.settings.title')}</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
@@ -292,7 +305,8 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
{/* User menu */}
|
||||
{user && (
|
||||
<div className="relative">
|
||||
<button type="button" onClick={() => setUserMenuOpen(!userMenuOpen)}
|
||||
<button type="button" ref={userMenuTrigger} onClick={() => setUserMenuOpen(!userMenuOpen)}
|
||||
aria-label={user.username} aria-expanded={userMenuOpen} aria-controls={userMenuOpen ? userMenuId : undefined}
|
||||
className="flex items-center gap-2 py-1.5 px-3 rounded-lg transition-colors"
|
||||
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'transparent'}>
|
||||
@@ -313,61 +327,57 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
{userMenuOpen && createPortal(
|
||||
<>
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 9998 }} role="presentation" onClick={() => setUserMenuOpen(false)} />
|
||||
<div className="trek-menu-enter w-60 rounded-xl shadow-xl border overflow-hidden bg-surface-card border-edge" style={{ position: 'fixed', top: 'var(--nav-h)', insetInlineEnd: 8, zIndex: 9999 }}>
|
||||
<div className="px-4 py-3 border-b border-edge-secondary">
|
||||
<p className="text-sm font-medium text-content">{user.username}</p>
|
||||
<p className="text-xs truncate text-content-muted">{user.email}</p>
|
||||
{user.role === 'admin' && (
|
||||
<span className="inline-flex items-center gap-1 text-xs font-medium mt-1 text-content-secondary">
|
||||
<Shield className="w-3 h-3" /> {t('nav.administrator')}
|
||||
</span>
|
||||
)}
|
||||
<div id={userMenuId} className="trek-desktop-panel trek-menu-enter w-[260px] max-w-[calc(100vw_-_24px)] overflow-y-auto rounded-[20px] border border-edge bg-surface-card p-2 shadow-xl" style={{ position: 'fixed', top: 'calc(var(--nav-h) + 6px)', maxHeight: 'calc(100dvh - var(--nav-h) - 18px)', insetInlineEnd: 12, zIndex: 9999 }}>
|
||||
<div className="flex items-center gap-2.5 rounded-xl bg-surface-secondary px-3 py-2.5">
|
||||
{user.avatar_url
|
||||
? <img src={user.avatar_url} alt="" className="size-9 shrink-0 rounded-full object-cover" />
|
||||
: <span aria-hidden="true" className="grid size-9 shrink-0 place-items-center rounded-full bg-accent text-sm font-bold text-accent-text">{user.username?.charAt(0).toUpperCase()}</span>}
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-semibold text-content">{user.username}</p>
|
||||
<p className="truncate text-xs text-content-muted" title={user.email}>{user.email}</p>
|
||||
{user.role === 'admin' && (
|
||||
<span className="mt-1 inline-flex items-center gap-1 text-xs font-medium text-content-muted">
|
||||
<Shield className="size-3" aria-hidden="true" /> {t('nav.administrator')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="py-1">
|
||||
<Link to="/settings" onClick={() => setUserMenuOpen(false)}
|
||||
className="flex items-center gap-2 px-4 py-2 text-sm transition-colors text-content-secondary"
|
||||
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'transparent'}>
|
||||
<Settings className="w-4 h-4" />
|
||||
<div className="grid gap-0.5 py-1.5">
|
||||
<Link ref={firstUserMenuAction} to="/settings" onClick={() => setUserMenuOpen(false)} className={USER_MENU_LINK}>
|
||||
<Settings className={USER_MENU_ICON} aria-hidden="true" />
|
||||
{t('nav.settings')}
|
||||
</Link>
|
||||
|
||||
{/* Bookings from forwarded mails that wait for a decision; only where the import is on. */}
|
||||
{mailImportOn && (
|
||||
<button type="button" onClick={() => { setUserMenuOpen(false); openMailInbox() }}
|
||||
className="flex w-full items-center gap-2 px-4 py-2 text-body transition-colors text-content-secondary hover:bg-surface-hover">
|
||||
<Inbox className="w-4 h-4" />
|
||||
className={USER_MENU_LINK}>
|
||||
<Inbox className={USER_MENU_ICON} aria-hidden="true" />
|
||||
<span className="min-w-0 flex-1 truncate text-start">{t('mailInbox.title')}</span>
|
||||
{mailPending > 0 && <span className="rounded-full bg-accent px-1.5 text-caption font-semibold text-accent-text">{mailPending}</span>}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{!managed && (
|
||||
<Link to="/help" onClick={() => setUserMenuOpen(false)}
|
||||
className="flex items-center gap-2 px-4 py-2 text-sm transition-colors text-content-secondary"
|
||||
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'transparent'}>
|
||||
<BookOpen className="w-4 h-4" />
|
||||
<Link to="/help" onClick={() => setUserMenuOpen(false)} className={USER_MENU_LINK}>
|
||||
<BookOpen className={USER_MENU_ICON} aria-hidden="true" />
|
||||
{t('nav.help')}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{user.role === 'admin' && (
|
||||
<Link to="/admin" onClick={() => setUserMenuOpen(false)}
|
||||
className="flex items-center gap-2 px-4 py-2 text-sm transition-colors text-content-secondary"
|
||||
onMouseEnter={e => e.currentTarget.style.background = 'var(--bg-hover)'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'transparent'}>
|
||||
<Shield className="w-4 h-4" />
|
||||
<Link to="/admin" onClick={() => setUserMenuOpen(false)} className={USER_MENU_LINK}>
|
||||
<Shield className={USER_MENU_ICON} aria-hidden="true" />
|
||||
{t('nav.admin')}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="py-1 border-t border-edge-secondary">
|
||||
<div className="border-t border-edge-faint pt-1.5">
|
||||
<button type="button" onClick={handleLogout}
|
||||
className="flex items-center gap-2 w-full px-4 py-2 text-sm text-red-500 hover:bg-red-500/10 transition-colors">
|
||||
<LogOut className="w-4 h-4" />
|
||||
className={`${USER_MENU_ACTION} text-danger hover:bg-danger/10`}>
|
||||
<LogOut className="size-4 shrink-0" aria-hidden="true" />
|
||||
{t('nav.logout')}
|
||||
</button>
|
||||
{appVersion && <UserMenuFooter appVersion={appVersion} dark={dark} managed={!!managed} />}
|
||||
|
||||
@@ -64,37 +64,39 @@ interface Props {
|
||||
export default function UserMenuFooter({ appVersion, dark, managed }: Props): React.ReactElement {
|
||||
const links = !managed && donationsShown() ? [...SUPPORT, DISCORD] : [DISCORD];
|
||||
return (
|
||||
<div className="mt-1 flex items-center justify-center gap-1.5 border-t border-edge-secondary px-3 pb-2.5 pt-2">
|
||||
<div className="inline-flex items-center gap-[5px] rounded-full bg-surface-tertiary px-2.5 py-1">
|
||||
<div className="mt-1 flex flex-wrap items-center justify-between gap-1.5 border-t border-edge-faint px-1 pt-2">
|
||||
<div className="inline-flex h-6 items-center gap-[5px] rounded-full bg-surface-tertiary px-2.5">
|
||||
<img src={dark ? '/text-light.svg' : '/text-dark.svg'} alt="TREK" className="h-2.5 opacity-50" />
|
||||
<span
|
||||
className="font-semibold text-content-faint"
|
||||
className="font-semibold text-content-muted"
|
||||
style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))' }}
|
||||
>
|
||||
v{appVersion}
|
||||
</span>
|
||||
</div>
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.title}
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={link.title}
|
||||
aria-label={link.title}
|
||||
className="grid h-6 w-6 flex-none place-items-center rounded-full bg-surface-tertiary text-content-faint transition-colors"
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.background = `${link.tint}26`;
|
||||
e.currentTarget.style.color = 'var(--text-primary)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.background = '';
|
||||
e.currentTarget.style.color = '';
|
||||
}}
|
||||
>
|
||||
{link.icon}
|
||||
</a>
|
||||
))}
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.title}
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={link.title}
|
||||
aria-label={link.title}
|
||||
className="grid size-6 flex-none place-items-center rounded-full bg-surface-tertiary text-content-muted transition-colors"
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.background = `${link.tint}26`;
|
||||
e.currentTarget.style.color = 'var(--text-primary)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.background = '';
|
||||
e.currentTarget.style.color = '';
|
||||
}}
|
||||
>
|
||||
{link.icon}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { useId } from 'react'
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus'
|
||||
import { X, Plus } from 'lucide-react'
|
||||
import { Backpack, Package, Plus } from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
import { CardHead, INPUT, PANEL } from '../shared/dialogParts'
|
||||
import type { PackingState } from './usePackingListPanel'
|
||||
import { bagFillPct, bagLoadSummary, packedWeight, perPersonLoads } from './packingListPanel.helpers'
|
||||
import { BagCard } from './PackingListPanelBagCard'
|
||||
import { PackingWeightSummary } from './PackingWeightSummary'
|
||||
|
||||
export function BagModal(S: PackingState) {
|
||||
const labelId = useId()
|
||||
const {
|
||||
setShowBagModal, t, bags, items, tripId, tripMembers, canEdit, currentUserId, handleDeleteBag, handleUpdateBag, handleSetBagMembers,
|
||||
showAddBag, setShowAddBag, newBagName, setNewBagName, handleCreateBag, unassignedWeightGrams, serverWeightsFresh,
|
||||
@@ -16,81 +20,78 @@ export function BagModal(S: PackingState) {
|
||||
// whether or not you may see the items, so it comes from the server (#2191).
|
||||
const { myItems, bagItemsOf, bagWeightOf, heaviestBagWeight, unassigned, unassignedWeight, totalWeight } =
|
||||
bagLoadSummary(bags, items, currentUserId, unassignedWeightGrams, serverWeightsFresh)
|
||||
const close = () => setShowBagModal(false)
|
||||
const resetNewBag = () => { setShowAddBag(false); setNewBagName('') }
|
||||
|
||||
return (
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 100, background: 'rgba(0,0,0,0.3)', display: 'flex', alignItems: 'flex-start', justifyContent: 'center', padding: 20, paddingTop: 140, paddingBottom: 'calc(20px + var(--bottom-nav-h))', overflowY: 'auto' }}
|
||||
role="button" tabIndex={0} aria-label={t('common.close')}
|
||||
onClick={() => setShowBagModal(false)}
|
||||
onKeyDown={e => {
|
||||
if (e.target !== e.currentTarget) return
|
||||
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setShowBagModal(false) }
|
||||
}}>
|
||||
<div role="presentation" style={{ background: 'var(--bg-card)', borderRadius: 16, width: '100%', maxWidth: 360, maxHeight: 'calc(100vh - 80px)', overflow: 'auto', padding: 20, boxShadow: '0 16px 48px rgba(0,0,0,0.15)', flexShrink: 0 }}
|
||||
onClick={e => e.stopPropagation()}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||
<h3 style={{ margin: 0, fontSize: 'calc(16px * var(--fs-scale-subtitle, 1))', fontWeight: 700, color: 'var(--text-primary)' }}>{t('packing.bags')}</h3>
|
||||
<button type="button" onClick={() => setShowBagModal(false)} style={{ background: 'none', border: 'none', cursor: 'pointer', color: 'var(--text-faint)', display: 'flex' }}><X size={18} /></button>
|
||||
</div>
|
||||
<DialogShell
|
||||
onClose={close}
|
||||
labelledBy={labelId}
|
||||
width="narrow"
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><Backpack size={20} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={close}
|
||||
title={t('packing.bags')}
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
<DialogFooter>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={close}>{t('common.close')}</DialogButton>
|
||||
{canEdit && (
|
||||
showAddBag
|
||||
? <DialogButton variant="primary" onClick={handleCreateBag} disabled={!newBagName.trim()}>{t('packing.addBag')}</DialogButton>
|
||||
: <DialogButton variant="primary" onClick={() => setShowAddBag(true)} icon={<Plus size={16} />}>{t('packing.addBag')}</DialogButton>
|
||||
)}
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
{bags.map(bag => {
|
||||
const bagItems = bagItemsOf(bag)
|
||||
const bagWeight = bagWeightOf(bag)
|
||||
const pct = bagFillPct(bagWeight, bag.weight_limit_grams, heaviestBagWeight)
|
||||
return (
|
||||
<BagCard key={bag.id} bag={bag} bagItems={bagItems} totalWeight={bagWeight} pct={pct} tripId={tripId} tripMembers={tripMembers} canEdit={canEdit} onDelete={() => handleDeleteBag(bag.id)} onUpdate={handleUpdateBag} onSetMembers={handleSetBagMembers} t={t} />
|
||||
)
|
||||
})}
|
||||
|
||||
{bags.map(bag => {
|
||||
const bagItems = bagItemsOf(bag)
|
||||
const bagWeight = bagWeightOf(bag)
|
||||
const pct = bagFillPct(bagWeight, bag.weight_limit_grams, heaviestBagWeight)
|
||||
return (
|
||||
<BagCard key={bag.id} bag={bag} bagItems={bagItems} totalWeight={bagWeight} pct={pct} tripId={tripId} tripMembers={tripMembers} canEdit={canEdit} onDelete={() => handleDeleteBag(bag.id)} onUpdate={handleUpdateBag} onSetMembers={handleSetBagMembers} t={t} />
|
||||
)
|
||||
})}
|
||||
|
||||
{/* Unassigned */}
|
||||
{(() => {
|
||||
// Shown whenever there is weight to account for, even with no visible
|
||||
// items: the grand total counts it, and a total nothing adds up to is
|
||||
// the confusion this issue was about (#2191).
|
||||
if (unassigned.length === 0 && unassignedWeight === 0) return null
|
||||
return (
|
||||
<div style={{ marginBottom: 16, opacity: 0.6 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 6 }}>
|
||||
<span style={{ width: 12, height: 12, borderRadius: '50%', border: '2px dashed var(--border-primary)', flexShrink: 0 }} />
|
||||
<span style={{ flex: 1, fontSize: 'calc(14px * var(--fs-scale-body, 1))', fontWeight: 600, color: 'var(--text-faint)' }}>{t('packing.noBag')}</span>
|
||||
<span style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', color: 'var(--text-faint)' }}>
|
||||
{unassignedWeight >= 1000 ? `${(unassignedWeight / 1000).toFixed(1)} kg` : `${unassignedWeight} g`}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 'calc(11px * var(--fs-scale-caption, 1))', color: 'var(--text-faint)' }}>{unassigned.length} {t('admin.packingTemplates.items', { count: unassigned.length })}</div>
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
|
||||
{/* Total, packed share and who carries what (#1131) */}
|
||||
<div style={{ marginTop: 8, border: '1px solid var(--border-secondary)', borderRadius: 16, overflow: 'hidden' }}>
|
||||
<PackingWeightSummary t={t} topRule={false}
|
||||
// Same rule as the rows above it: a grand total mixing true bag
|
||||
// weights with a per-viewer remainder would be worse than either.
|
||||
total={totalWeight}
|
||||
packed={packedWeight(myItems)}
|
||||
people={perPersonLoads(bags, bagWeightOf)} />
|
||||
</div>
|
||||
|
||||
{/* Add bag */}
|
||||
{canEdit && (showAddBag ? (
|
||||
<div style={{ display: 'flex', gap: 6, marginTop: 14 }}>
|
||||
<input ref={focusRevealedEditor} value={newBagName} onChange={e => setNewBagName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleCreateBag(); if (e.key === 'Escape') { setShowAddBag(false); setNewBagName('') } }}
|
||||
placeholder={t('packing.bagName')}
|
||||
style={{ flex: 1, padding: '8px 12px', borderRadius: 10, border: '1px solid var(--border-primary)', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontFamily: 'inherit', outline: 'none' }} />
|
||||
<button type="button" onClick={handleCreateBag} disabled={!newBagName.trim()}
|
||||
style={{ padding: '8px 12px', borderRadius: 10, border: 'none', background: newBagName.trim() ? 'var(--text-primary)' : 'var(--border-primary)', color: 'var(--bg-primary)', cursor: newBagName.trim() ? 'pointer' : 'default', display: 'flex', alignItems: 'center' }}>
|
||||
<Plus size={14} />
|
||||
</button>
|
||||
{(unassigned.length > 0 || unassignedWeight > 0) && (
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Package size={16} />} title={t('packing.noBag')} />
|
||||
<div className="flex items-center justify-between gap-2 rounded-[10px] bg-surface-input px-3 py-2 text-body tabular-nums text-content-muted">
|
||||
<span>{unassigned.length} {t('admin.packingTemplates.items', { count: unassigned.length })}</span>
|
||||
<span>{unassignedWeight >= 1000 ? `${(unassignedWeight / 1000).toFixed(1)} kg` : `${unassignedWeight} g`}</span>
|
||||
</div>
|
||||
) : (
|
||||
<button type="button" onClick={() => setShowAddBag(true)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 14, padding: '9px 14px', borderRadius: 10, border: '1px dashed var(--border-primary)', background: 'none', cursor: 'pointer', fontSize: 'calc(13px * var(--fs-scale-body, 1))', color: 'var(--text-faint)', fontFamily: 'inherit', width: '100%', transition: 'all 0.15s' }}
|
||||
onMouseEnter={e => { e.currentTarget.style.borderColor = 'var(--text-muted)'; e.currentTarget.style.color = 'var(--text-secondary)' }}
|
||||
onMouseLeave={e => { e.currentTarget.style.borderColor = 'var(--border-primary)'; e.currentTarget.style.color = 'var(--text-faint)' }}>
|
||||
<Plus size={14} /> {t('packing.addBag')}
|
||||
</button>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Total, packed share and who carries what (#1131) */}
|
||||
<div className="overflow-hidden rounded-[14px] border border-edge-faint bg-surface-input">
|
||||
<PackingWeightSummary t={t} topRule={false}
|
||||
// Same rule as the rows above it: a grand total mixing true bag
|
||||
// weights with a per-viewer remainder would be worse than either.
|
||||
total={totalWeight}
|
||||
packed={packedWeight(myItems)}
|
||||
people={perPersonLoads(bags, bagWeightOf)} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{canEdit && showAddBag && (
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<Plus size={16} />} title={t('packing.addBag')} />
|
||||
<input aria-label={t('packing.bagName')} ref={focusRevealedEditor} value={newBagName}
|
||||
onChange={e => setNewBagName(e.target.value)}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter' && newBagName.trim()) void handleCreateBag()
|
||||
if (e.key === 'Escape') { e.preventDefault(); resetNewBag() }
|
||||
}}
|
||||
placeholder={t('packing.bagName')}
|
||||
className={INPUT}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</DialogShell>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useRef } from 'react'
|
||||
import { useId, useRef } from 'react'
|
||||
import { Printer } from 'lucide-react'
|
||||
import Modal from '../shared/Modal'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
import { useTranslation } from '../../i18n'
|
||||
|
||||
interface PackingPrintPreviewProps {
|
||||
@@ -19,27 +19,35 @@ interface PackingPrintPreviewProps {
|
||||
*/
|
||||
export default function PackingPrintPreview({ html, title, onClose }: PackingPrintPreviewProps) {
|
||||
const { t } = useTranslation()
|
||||
const labelId = useId()
|
||||
const frameRef = useRef<HTMLIFrameElement>(null)
|
||||
return (
|
||||
<Modal
|
||||
isOpen={html != null}
|
||||
<DialogShell
|
||||
open={html != null}
|
||||
onClose={onClose}
|
||||
title={title}
|
||||
size="3xl"
|
||||
labelledBy={labelId}
|
||||
width="wide"
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><Printer size={20} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={onClose}
|
||||
title={title}
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
<div className="flex justify-end gap-2">
|
||||
<button type="button" onClick={onClose} className="rounded-lg border border-edge px-4 py-2 text-body text-content-muted hover:bg-surface-hover">
|
||||
{t('common.close')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
<DialogFooter>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={onClose}>{t('common.close')}</DialogButton>
|
||||
<DialogButton
|
||||
variant="primary"
|
||||
onClick={() => frameRef.current?.contentWindow?.print()}
|
||||
className="inline-flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-body font-medium text-accent-text hover:bg-accent-hover"
|
||||
icon={<Printer size={15} strokeWidth={2.2} />}
|
||||
>
|
||||
<Printer size={15} strokeWidth={2.2} />
|
||||
{t('packing.exportPrint')}
|
||||
</button>
|
||||
</div>
|
||||
</DialogButton>
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
{html != null && (
|
||||
@@ -51,6 +59,6 @@ export default function PackingPrintPreview({ html, title, onClose }: PackingPri
|
||||
className="block h-[62vh] w-full rounded-lg border border-edge"
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
</DialogShell>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Plus } from 'lucide-react'
|
||||
|
||||
export function AddRouteStop({ onClick, label, mobile = false }: { onClick: () => void; label: string; mobile?: boolean }) {
|
||||
const button = mobile
|
||||
? 'border-m-rowbr bg-m-sheetop text-control text-m-ink active:bg-m-ic'
|
||||
: 'border-edge bg-surface-input text-body text-content hover:bg-surface-hover'
|
||||
const tile = mobile ? 'bg-m-ic text-m-muted' : 'bg-surface-secondary text-content-muted'
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={`flex min-h-11 w-full items-center gap-2 rounded-xl border px-3 py-1.5 text-start font-medium ${button}`}
|
||||
>
|
||||
<span className={`grid size-7 shrink-0 place-items-center rounded-lg ${tile}`}>
|
||||
<Plus size={16} strokeWidth={2} aria-hidden />
|
||||
</span>
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
@@ -326,7 +326,7 @@ describe('AirTrailImportModal', () => {
|
||||
const onClose = vi.fn();
|
||||
render(<AirTrailImportModal {...defaultProps} onClose={onClose} />);
|
||||
await screen.findByText('Import from AirTrail');
|
||||
const backdrop = document.querySelector('[style*="z-index: 99999"]') as HTMLElement;
|
||||
const backdrop = screen.getByRole('dialog', { name: 'Import from AirTrail' }).parentElement!;
|
||||
|
||||
fireEvent.mouseDown(screen.getByText('Import from AirTrail'));
|
||||
fireEvent.click(backdrop);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useState, useRef, useEffect, useMemo } from 'react'
|
||||
import { Plane, X, Check } from 'lucide-react'
|
||||
import { useState, useRef, useEffect, useId, useMemo } from 'react'
|
||||
import { CalendarDays, Plane, X, Check } from 'lucide-react'
|
||||
import type { AirtrailFlight, AirtrailImportResult } from '@trek/shared'
|
||||
import { useIsPhone } from '../../hooks/useIsPhone'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
import { CardHead, PANEL } from '../shared/dialogParts'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useToast } from '../shared/Toast'
|
||||
import { airtrailApi } from '../../api/client'
|
||||
@@ -75,6 +78,8 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
const reservations = useTripStore(s => s.reservations)
|
||||
const loadReservations = useTripStore(s => s.loadReservations)
|
||||
const deleteReservation = useTripStore(s => s.deleteReservation)
|
||||
const isPhone = useIsPhone()
|
||||
const labelId = useId()
|
||||
const mouseDownTarget = useRef<EventTarget | null>(null)
|
||||
|
||||
const [loading, setLoading] = useState(false)
|
||||
@@ -251,7 +256,8 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
key={f.id}
|
||||
onClick={() => !already && toggle(f.id)}
|
||||
disabled={already}
|
||||
className={already ? 'bg-surface-tertiary' : isSelected ? 'bg-surface-secondary' : 'bg-transparent'}
|
||||
aria-pressed={isSelected || already}
|
||||
className={already ? 'bg-surface-tertiary' : isSelected ? 'bg-surface-hover' : 'bg-surface-input'}
|
||||
style={{
|
||||
width: '100%', textAlign: 'start', borderRadius: 10, padding: '10px 12px', marginBottom: 8,
|
||||
border: `1px solid ${isSelected && !already ? 'var(--accent)' : 'var(--border-primary)'}`,
|
||||
@@ -268,7 +274,7 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
}}>
|
||||
{(isSelected || already) && <Check size={12} color="var(--accent-text)" strokeWidth={3} />}
|
||||
</span>
|
||||
<Plane size={15} color="#3b82f6" style={{ flexShrink: 0 }} />
|
||||
<Plane size={15} className="shrink-0 text-content-muted" aria-hidden="true" />
|
||||
<span style={{ flex: 1, minWidth: 0 }}>
|
||||
<span style={{ display: 'block', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 600, color: 'var(--text-primary)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{label}</span>
|
||||
<span style={{ display: 'block', fontSize: 'calc(11px * var(--fs-scale-caption, 1))', color: 'var(--text-muted)' }}>
|
||||
@@ -318,6 +324,56 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
const renderItem = (item: { chain?: AirtrailFlight[]; flight?: AirtrailFlight }) =>
|
||||
item.chain ? renderChain(item.chain) : renderFlight(item.flight!)
|
||||
|
||||
const flightList = (
|
||||
<>
|
||||
{loading && <p className="m-0 py-6 text-center text-body text-content-muted">{t('common.loading')}</p>}
|
||||
{!loading && flights.length === 0 && !error && (
|
||||
<p className="m-0 py-6 text-center text-body text-content-muted">{t('reservations.airtrail.empty')}</p>
|
||||
)}
|
||||
{!loading && sectionItems.during.length > 0 && (
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<CalendarDays size={16} />} title={t('reservations.airtrail.duringTrip')} />
|
||||
<div>{sectionItems.during.map(renderItem)}</div>
|
||||
</section>
|
||||
)}
|
||||
{!loading && sectionItems.others.length > 0 && (
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Plane size={16} />} title={t('reservations.airtrail.otherFlights')} />
|
||||
<div>{sectionItems.others.map(renderItem)}</div>
|
||||
</section>
|
||||
)}
|
||||
{error && <p role="alert" className="m-0 whitespace-pre-wrap rounded-xl bg-danger-soft px-3 py-2.5 text-body text-danger">{error}</p>}
|
||||
</>
|
||||
)
|
||||
const importLabel = importing ? t('common.loading') : t('reservations.airtrail.importCta', { count: selectableCount })
|
||||
const importDisabled = selectableCount === 0 || importing
|
||||
|
||||
if (!isPhone) return (
|
||||
<DialogShell
|
||||
onClose={handleClose}
|
||||
labelledBy={labelId}
|
||||
front
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><Plane size={20} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={handleClose}
|
||||
title={t('reservations.airtrail.title')}
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
<DialogFooter>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={handleClose}>{t('common.cancel')}</DialogButton>
|
||||
<DialogButton variant="primary" onClick={handleImport} disabled={importDisabled}>{importLabel}</DialogButton>
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
{flightList}
|
||||
</DialogShell>
|
||||
)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
className="bg-[rgba(0,0,0,0.4)]"
|
||||
@@ -345,43 +401,7 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={{ flex: 1, overflowY: 'auto', minHeight: 0 }}>
|
||||
{loading && (
|
||||
<div className="text-content-faint" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', textAlign: 'center', padding: '24px 0' }}>
|
||||
{t('common.loading')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && flights.length === 0 && !error && (
|
||||
<div className="text-content-faint" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', textAlign: 'center', padding: '24px 0' }}>
|
||||
{t('reservations.airtrail.empty')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!loading && sectionItems.during.length > 0 && (
|
||||
<>
|
||||
<div style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 700, color: 'var(--text-primary)', margin: '2px 0 8px' }}>
|
||||
{t('reservations.airtrail.duringTrip')}
|
||||
</div>
|
||||
{sectionItems.during.map(renderItem)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{!loading && sectionItems.others.length > 0 && (
|
||||
<>
|
||||
<div style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', fontWeight: 700, color: 'var(--text-faint)', margin: `${sectionItems.during.length > 0 ? 14 : 2}px 0 8px` }}>
|
||||
{t('reservations.airtrail.otherFlights')}
|
||||
</div>
|
||||
{sectionItems.others.map(renderItem)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="bg-[rgba(239,68,68,0.08)] text-[#b91c1c]" style={{ border: '1px solid rgba(239,68,68,0.35)', borderRadius: 10, padding: '8px 10px', fontSize: 'calc(12px * var(--fs-scale-body, 1))', whiteSpace: 'pre-wrap', marginTop: 8 }}>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto">{flightList}</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 14, paddingTop: 14, borderTop: '1px solid var(--border-faint)' }}>
|
||||
<button type="button"
|
||||
@@ -392,11 +412,11 @@ export default function AirTrailImportModal({ isOpen, onClose, tripId, pushUndo
|
||||
</button>
|
||||
<button type="button"
|
||||
onClick={handleImport}
|
||||
disabled={selectableCount === 0 || importing}
|
||||
disabled={importDisabled}
|
||||
className={selectableCount > 0 && !importing ? 'bg-accent text-accent-text' : 'bg-surface-tertiary text-content-faint'}
|
||||
style={{ padding: '8px 16px', borderRadius: 10, border: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: selectableCount > 0 && !importing ? 'pointer' : 'default', fontFamily: 'inherit' }}
|
||||
>
|
||||
{importing ? t('common.loading') : t('reservations.airtrail.importCta', { count: selectableCount })}
|
||||
{importLabel}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Plus, Pencil, Trash2, Link2Off } from 'lucide-react'
|
||||
import { Plus, Pencil, Receipt, Trash2, Link2Off } from 'lucide-react'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import CustomSelect from '../shared/CustomSelect'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
import { CardHead } from '../shared/dialogParts'
|
||||
import { formatMoney } from '../../utils/formatters'
|
||||
import { catMeta } from '../Budget/costsCategories'
|
||||
import { useExpenseLinks } from './useRecordLinks'
|
||||
@@ -25,7 +26,7 @@ import type { BudgetItem } from '../../types'
|
||||
* Exactly one of reservationId / placeId is set — they are the two sides of the
|
||||
* same link, and the block behaves identically on both.
|
||||
*/
|
||||
export function BookingCostsSection({ reservationId, placeId = null, hintKey = 'reservations.createExpenseHint', pendingExpense, onCreate, onEdit, onRemove, labelClassName, customTooltips = false, whiteButtons = false }: {
|
||||
export function BookingCostsSection({ reservationId, placeId = null, hintKey = 'reservations.createExpenseHint', pendingExpense, onCreate, onEdit, onRemove, customTooltips = false, whiteButtons = false }: {
|
||||
reservationId: number | null
|
||||
/** Set instead of reservationId when the block sits in the place form (#1298). */
|
||||
placeId?: number | null
|
||||
@@ -36,8 +37,6 @@ export function BookingCostsSection({ reservationId, placeId = null, hintKey = '
|
||||
onCreate: () => void
|
||||
onEdit: (item: BudgetItem) => void
|
||||
onRemove: (item: BudgetItem) => void
|
||||
/** Replaces the block's own label style, so a host form can match its other fields. */
|
||||
labelClassName?: string
|
||||
/** Shows the row buttons' hints in the shared Tooltip instead of the native title. */
|
||||
customTooltips?: boolean
|
||||
/**
|
||||
@@ -56,7 +55,6 @@ export function BookingCostsSection({ reservationId, placeId = null, hintKey = '
|
||||
const ownCurrency = (currency: string | null | undefined) => currency || tripCurrency || base
|
||||
const { targetId, linked, unlinked, link, unlink } = useExpenseLinks(reservationId, placeId)
|
||||
|
||||
const labelCls = labelClassName ?? 'block text-[11px] font-semibold uppercase tracking-[0.08em] text-content-faint mb-[6px]'
|
||||
const rowCls = whiteButtons ? 'bg-surface-card border border-edge-faint' : 'bg-surface-secondary border border-edge'
|
||||
const rowStyle = { display: 'flex', alignItems: 'center', gap: 10, padding: '10px 12px', borderRadius: 10 } as const
|
||||
// White, the row's buttons trade the border for the hairline ring and shadow of
|
||||
@@ -82,8 +80,8 @@ export function BookingCostsSection({ reservationId, placeId = null, hintKey = '
|
||||
const meta = catMeta(pendingExpense.category)
|
||||
const Icon = meta.Icon
|
||||
return (
|
||||
<div>
|
||||
<label className={labelCls}>{t('reservations.linkedExpense')}</label>
|
||||
<div className="space-y-3">
|
||||
<CardHead icon={<Receipt size={16} strokeWidth={2} />} title={t('reservations.linkedExpense')} />
|
||||
<div className={rowCls} style={rowStyle}>
|
||||
<span style={{ width: 26, height: 26, borderRadius: 7, display: 'grid', placeItems: 'center', background: meta.color + '22', color: meta.color, flexShrink: 0 }}><Icon size={14} /></span>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
@@ -97,8 +95,8 @@ export function BookingCostsSection({ reservationId, placeId = null, hintKey = '
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<label className={labelCls}>{linked.length > 0 ? t('reservations.linkedExpenses') : t('reservations.costsLabel')}</label>
|
||||
<div className="space-y-3">
|
||||
<CardHead icon={<Receipt size={16} strokeWidth={2} />} title={t(linked.length > 0 ? 'reservations.linkedExpenses' : 'reservations.costsLabel')} />
|
||||
|
||||
{linked.length > 0 && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 8 }}>
|
||||
|
||||
@@ -33,10 +33,10 @@ export function BookingFileButtons({ canAttach, uploading, onAttach, linkable, o
|
||||
const canLink = linkable.length > 0
|
||||
if (!canAttach && !canLink) return null
|
||||
|
||||
const buttonClass = 'bg-surface-secondary border border-edge text-content transition-colors hover:bg-surface-tertiary disabled:cursor-default disabled:opacity-60'
|
||||
const buttonClass = 'trek-form-control border border-edge bg-surface-input text-content transition-colors hover:bg-surface-hover disabled:cursor-default disabled:opacity-50'
|
||||
const buttonStyle = {
|
||||
width: '100%', minWidth: 0, display: 'flex', whiteSpace: 'nowrap', alignItems: 'center', justifyContent: 'center', gap: 8, padding: '8px 13px',
|
||||
borderRadius: 10, fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 600, cursor: 'pointer', fontFamily: 'inherit',
|
||||
borderRadius: 10, fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: 'pointer', fontFamily: 'inherit',
|
||||
} as const
|
||||
|
||||
return (
|
||||
|
||||
@@ -211,8 +211,8 @@ describe('BookingImportModal', () => {
|
||||
it('FE-PLANNER-BOOKIMP-015: a backdrop press-and-release closes, a press inside does not', () => {
|
||||
const onClose = vi.fn();
|
||||
render(<BookingImportModal {...defaultProps} onClose={onClose} />);
|
||||
const backdrop = document.querySelector('[style*="z-index: 99999"]') as HTMLElement;
|
||||
const card = screen.getByText('Import booking confirmations').closest('div')!.parentElement!;
|
||||
const card = screen.getByRole('dialog', { name: 'Import booking confirmations' });
|
||||
const backdrop = card.parentElement!;
|
||||
|
||||
// A drag that starts inside the dialog and ends on the backdrop must not close it.
|
||||
fireEvent.mouseDown(card);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createPortal } from 'react-dom'
|
||||
import { useSharedImportStore } from '../../native/sharedFiles'
|
||||
import { useState, useRef, useEffect, type ReactNode, type DragEventHandler } from 'react'
|
||||
import { Upload, X } from 'lucide-react'
|
||||
import { useState, useRef, useEffect, useId, type ReactNode, type DragEventHandler } from 'react'
|
||||
import { FileUp, Upload } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { reservationsApi, healthApi } from '../../api/client'
|
||||
import { llmRepo } from '../../repo/llmRepo'
|
||||
@@ -10,6 +9,8 @@ import { useBackgroundTasksStore } from '../../store/backgroundTasksStore'
|
||||
import { saveImportFiles } from '../../db/offlineDb'
|
||||
import { isEffectivelyOffline } from '../../sync/networkMode'
|
||||
import TripMailForward from '../MailIngest/TripMailForward'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT } from '../shared/DialogShell'
|
||||
import { PANEL } from '../shared/dialogParts'
|
||||
|
||||
export interface BookingImportModalProps {
|
||||
isOpen: boolean
|
||||
@@ -55,7 +56,7 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind, rend
|
||||
const { t } = useTranslation()
|
||||
const addTask = useBackgroundTasksStore((s) => s.addTask)
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
const mouseDownTarget = useRef<EventTarget | null>(null)
|
||||
const labelId = useId()
|
||||
|
||||
const [files, setFiles] = useState<File[]>([])
|
||||
useEffect(() => {
|
||||
@@ -194,97 +195,55 @@ export default function BookingImportModal({ isOpen, onClose, tripId, kind, rend
|
||||
})
|
||||
}
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
role="presentation"
|
||||
className="bg-[rgba(0,0,0,0.4)]"
|
||||
style={{ position: 'fixed', inset: 0, zIndex: 99999, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16 }}
|
||||
onMouseDown={(e) => { mouseDownTarget.current = e.target }}
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget && mouseDownTarget.current === e.currentTarget) handleClose()
|
||||
mouseDownTarget.current = null
|
||||
}}
|
||||
>
|
||||
<div
|
||||
role="presentation"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="bg-surface-card"
|
||||
style={{ borderRadius: 16, width: '100%', maxWidth: 540, padding: 24, boxShadow: '0 8px 32px rgba(0,0,0,0.2)', fontFamily: 'var(--font-system)', maxHeight: '90vh', display: 'flex', flexDirection: 'column' }}
|
||||
>
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 14 }}>
|
||||
<div style={{ flex: 1, fontSize: 'calc(15px * var(--fs-scale-subtitle, 1))', fontWeight: 700, color: 'var(--text-primary)' }}>
|
||||
{t('reservations.import.title')}
|
||||
</div>
|
||||
<button type="button" onClick={handleClose} className="bg-transparent text-content-faint" style={{ border: 'none', cursor: 'pointer', padding: 4, borderRadius: 6, display: 'flex', alignItems: 'center' }}>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={{ flex: 1, overflowY: 'auto', minHeight: 0 }}>
|
||||
<div style={{ fontSize: 'calc(12px * var(--fs-scale-body, 1))', color: 'var(--text-faint)', marginBottom: 14, lineHeight: 1.45 }}>
|
||||
{t('reservations.import.acceptedFormats')}
|
||||
{readsPhotos && <> {t('reservations.import.acceptedPhotos')}</>}
|
||||
</div>
|
||||
|
||||
{fileInput}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onDragOver={handleDragOver}
|
||||
onDragEnter={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
className={isDragOver ? 'bg-surface-tertiary' : 'bg-transparent'}
|
||||
style={{
|
||||
width: '100%', minHeight: 100, borderRadius: 12,
|
||||
border: `2px dashed ${isDragOver ? 'var(--accent)' : 'var(--border-primary)'}`,
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
|
||||
gap: 6, fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: 'pointer',
|
||||
marginBottom: 12, padding: 16, boxSizing: 'border-box',
|
||||
transition: 'border-color 0.15s, background 0.15s',
|
||||
}}
|
||||
>
|
||||
<Upload size={18} strokeWidth={1.8} color={isDragOver ? 'var(--accent)' : 'var(--text-faint)'} style={{ pointerEvents: 'none' }} />
|
||||
{isDragOver ? (
|
||||
<span className="text-accent" style={{ pointerEvents: 'none' }}>{t('reservations.import.dropActive')}</span>
|
||||
) : files.length > 0 ? (
|
||||
<span style={{ color: 'var(--text-primary)', textAlign: 'center', wordBreak: 'break-all', pointerEvents: 'none' }}>{files.map((f) => f.name).join(', ')}</span>
|
||||
) : (
|
||||
<span style={{ color: 'var(--text-faint)', textAlign: 'center', pointerEvents: 'none' }}>{t('reservations.import.dropHere')}</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{error && (
|
||||
<div className="bg-[rgba(239,68,68,0.08)] text-[#b91c1c]" style={{ border: '1px solid rgba(239,68,68,0.35)', borderRadius: 10, padding: '8px 10px', fontSize: 'calc(12px * var(--fs-scale-body, 1))', whiteSpace: 'pre-wrap', marginTop: 8 }}>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* The other way in: forward the booking mail to the trip's own address. */}
|
||||
<TripMailForward tripId={tripId} />
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 14, paddingTop: 14, borderTop: '1px solid var(--border-faint)' }}>
|
||||
<button type="button"
|
||||
onClick={handleClose}
|
||||
style={{ padding: '8px 16px', borderRadius: 10, border: '1px solid var(--border-primary)', background: 'none', color: 'var(--text-primary)', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: 'pointer', fontFamily: 'inherit' }}
|
||||
>
|
||||
{t('common.cancel')}
|
||||
</button>
|
||||
<button type="button"
|
||||
onClick={() => void handleParse()}
|
||||
disabled={files.length === 0 || loading}
|
||||
className={files.length > 0 && !loading ? 'bg-accent text-accent-text' : 'bg-surface-tertiary text-content-faint'}
|
||||
style={{ padding: '8px 16px', borderRadius: 10, border: 'none', fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, cursor: files.length > 0 && !loading ? 'pointer' : 'default', fontFamily: 'inherit' }}
|
||||
>
|
||||
return (
|
||||
<DialogShell
|
||||
onClose={handleClose}
|
||||
labelledBy={labelId}
|
||||
width="narrow"
|
||||
front
|
||||
header={(
|
||||
<DialogHeader
|
||||
tile={<DialogTile><FileUp size={20} strokeWidth={1.9} className="text-content-muted" /></DialogTile>}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={labelId}
|
||||
onClose={handleClose}
|
||||
title={t('reservations.import.title')}
|
||||
/>
|
||||
)}
|
||||
footer={(
|
||||
<DialogFooter>
|
||||
<FooterSpacer />
|
||||
<DialogButton onClick={handleClose}>{t('common.cancel')}</DialogButton>
|
||||
<DialogButton variant="primary" onClick={() => void handleParse()} disabled={files.length === 0 || loading}>
|
||||
{loading ? t('reservations.import.parsing') : t('common.import')}
|
||||
</button>
|
||||
</div>
|
||||
</DialogButton>
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<div className={PANEL}>
|
||||
{fileInput}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
onDragOver={handleDragOver}
|
||||
onDragEnter={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
aria-describedby={`${labelId}-formats`}
|
||||
className={`trek-form-control flex min-h-24 [--form-control-min-height:96px] w-full flex-col items-center justify-center gap-2 rounded-[10px] border border-dashed p-4 text-center font-medium ${isDragOver ? 'border-accent bg-surface-tertiary text-content' : 'border-edge bg-surface-input text-content-muted hover:border-content-faint'}`}
|
||||
>
|
||||
<Upload size={18} strokeWidth={1.8} className="pointer-events-none" aria-hidden />
|
||||
<span className="pointer-events-none break-all">
|
||||
{isDragOver ? t('reservations.import.dropActive') : files.length > 0 ? files.map(file => file.name).join(', ') : t('reservations.import.dropHere')}
|
||||
</span>
|
||||
</button>
|
||||
<p id={`${labelId}-formats`} className="m-0 text-caption leading-snug text-content-muted">
|
||||
{t('reservations.import.acceptedFormats')}
|
||||
{readsPhotos && <> {t('reservations.import.acceptedPhotos')}</>}
|
||||
</p>
|
||||
{error && <div role="alert" className="whitespace-pre-wrap rounded-xl bg-danger-soft px-3 py-2.5 text-body text-danger">{error}</div>}
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
<TripMailForward tripId={tripId} />
|
||||
</DialogShell>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { RefObject } from 'react';
|
||||
import { useId, type RefObject } from 'react';
|
||||
import { NotebookPen, Paperclip } from 'lucide-react';
|
||||
|
||||
import { useTranslation } from '../../i18n';
|
||||
import type { TripFile } from '../../types';
|
||||
import { EditorField, INPUT, LABEL, TEXTAREA } from '../shared/dialogParts';
|
||||
import { DialogSection } from '../shared/DialogShell';
|
||||
import { INPUT, LABEL, PANEL, TEXTAREA } from '../shared/dialogParts';
|
||||
import { BookingCostsSection } from './BookingCostsSection';
|
||||
import { BookingLinkAndFiles } from './BookingLinkAndFiles';
|
||||
import type { useBookingExpenseIntent } from './useBookingExpenseIntent';
|
||||
@@ -42,47 +44,53 @@ export function BookingNotesFilesCosts({
|
||||
expense: ReturnType<typeof useBookingExpenseIntent>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const notesId = useId();
|
||||
return (
|
||||
<>
|
||||
<EditorField label={t('reservations.notes')}>
|
||||
<DialogSection icon={NotebookPen} label={<label htmlFor={notesId}>{t('reservations.notes')}</label>}>
|
||||
<textarea
|
||||
id={notesId}
|
||||
value={form.notes}
|
||||
onChange={(e) => set('notes', e.target.value)}
|
||||
rows={2}
|
||||
placeholder={t('reservations.notesPlaceholder')}
|
||||
className={TEXTAREA}
|
||||
/>
|
||||
</EditorField>
|
||||
</DialogSection>
|
||||
|
||||
<BookingLinkAndFiles
|
||||
url={form.url}
|
||||
onUrlChange={(url) => set('url', url)}
|
||||
labelClass={LABEL}
|
||||
inputClass={INPUT}
|
||||
reservationId={reservationId}
|
||||
tripFiles={tripFiles}
|
||||
attachedFiles={attach.attachedFiles}
|
||||
pendingFiles={pendingFiles}
|
||||
onRemovePending={attach.removePending}
|
||||
fileInputRef={fileInputRef}
|
||||
onFileChange={attach.handleFileChange}
|
||||
canAttach={canAttach}
|
||||
uploading={saving}
|
||||
onLinked={attach.linkFile}
|
||||
onDetached={attach.detachFile}
|
||||
/>
|
||||
<DialogSection icon={Paperclip} label={t('places.formContactSection')}>
|
||||
<BookingLinkAndFiles
|
||||
url={form.url}
|
||||
onUrlChange={(url) => set('url', url)}
|
||||
labelClass={LABEL}
|
||||
inputClass={INPUT}
|
||||
reservationId={reservationId}
|
||||
tripFiles={tripFiles}
|
||||
attachedFiles={attach.attachedFiles}
|
||||
pendingFiles={pendingFiles}
|
||||
onRemovePending={attach.removePending}
|
||||
fileInputRef={fileInputRef}
|
||||
onFileChange={attach.handleFileChange}
|
||||
canAttach={canAttach}
|
||||
uploading={saving}
|
||||
onLinked={attach.linkFile}
|
||||
onDetached={attach.detachFile}
|
||||
/>
|
||||
</DialogSection>
|
||||
|
||||
{/* Costs: create or view the expenses linked to this booking */}
|
||||
{showCosts && (
|
||||
<BookingCostsSection
|
||||
reservationId={reservationId ?? null}
|
||||
pendingExpense={pendingExpense}
|
||||
onCreate={expense.create}
|
||||
onEdit={expense.edit}
|
||||
onRemove={expense.remove}
|
||||
labelClassName={LABEL}
|
||||
customTooltips
|
||||
/>
|
||||
<section className={PANEL}>
|
||||
<BookingCostsSection
|
||||
reservationId={reservationId ?? null}
|
||||
pendingExpense={pendingExpense}
|
||||
onCreate={expense.create}
|
||||
onEdit={expense.edit}
|
||||
onRemove={expense.remove}
|
||||
customTooltips
|
||||
whiteButtons
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useId, type ReactNode, type Ref } from 'react'
|
||||
import { X, CloudRain, Wind, Droplets, Sunrise, Sunset, Hotel, Calendar, MapPin, LogIn, LogOut, Pencil, ChevronsDown, ChevronsUp, ArrowRight, Check, Moon, type LucideIcon } from 'lucide-react'
|
||||
import { Bed, Ticket, X, CloudRain, Wind, Droplets, Sunrise, Sunset, Hotel, Calendar, MapPin, LogIn, LogOut, Pencil, ChevronsDown, ChevronsUp, ArrowRight, Check, Moon, type LucideIcon } from 'lucide-react'
|
||||
import type { WeatherResult } from '@trek/shared'
|
||||
import { usePluginViewContributions, PluginCardFooter } from '../Plugins/PluginContributions'
|
||||
import { usePluginStore } from '../../store/pluginStore'
|
||||
@@ -251,7 +251,7 @@ export default function DayDetailPanel({ day, days, places, categories = [], tri
|
||||
|
||||
<DayReservations day={day} days={days} assignments={assignments} reservations={reservations} is12h={is12h} onOpen={onOpenBooking} />
|
||||
|
||||
<DialogSection label={t('day.accommodation')}>
|
||||
<DialogSection icon={Bed} label={t('day.accommodation')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{dayAccommodations.map(acc => (
|
||||
<AccommodationCard key={acc.id} acc={acc} day={day}
|
||||
@@ -399,7 +399,7 @@ function DayReservations({ day, days, assignments, reservations, is12h, onOpen }
|
||||
const dayReservations = dayBookings(day.id, dayAssignments, reservations, pinnedAwayIn(assignments, days))
|
||||
if (dayReservations.length === 0) return null
|
||||
return (
|
||||
<DialogSection label={t('day.reservations')}>
|
||||
<DialogSection icon={Ticket} label={t('day.reservations')}>
|
||||
<ul className="m-0 flex list-none flex-col gap-1.5 p-0">
|
||||
{dayReservations.map(r => {
|
||||
const linkedAssignment = dayAssignments.find(a => a.id === r.assignment_id)
|
||||
@@ -615,7 +615,7 @@ function HotelPickerModal({ mode, onClose, onSave, days, categories, places, hot
|
||||
</DialogFooter>
|
||||
)}
|
||||
>
|
||||
<DialogSection label={t('day.hotelDayRange')}>
|
||||
<DialogSection icon={Bed} label={t('day.hotelDayRange')}>
|
||||
<div className={PANEL}>
|
||||
<div className="grid grid-cols-[1fr_auto_1fr_auto] items-end gap-2 max-sm:grid-cols-1">
|
||||
<EditorField label={t('reservations.start')} htmlFor={startId}>
|
||||
@@ -660,7 +660,7 @@ function HotelPickerModal({ mode, onClose, onSave, days, categories, places, hot
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('reservations.meta.pickHotel')}
|
||||
<DialogSection icon={Bed} label={t('reservations.meta.pickHotel')}
|
||||
action={categories.length > 0 ? (
|
||||
<PillSelect<string>
|
||||
value={hotelCategoryFilter ? String(hotelCategoryFilter) : ''}
|
||||
|
||||
@@ -1175,7 +1175,7 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) {
|
||||
* worse than the icon that means the same thing. The icon keeps the accessible
|
||||
* name, so nothing is lost but the letters.
|
||||
*/
|
||||
const NARROW_PLAN_PX = 320
|
||||
const DAY_DATE_BADGE = 'inline-flex items-center rounded-full bg-surface-card px-2 py-0.5 font-medium text-content-muted'
|
||||
|
||||
const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarProps) {
|
||||
const S = useDayPlanSidebar(props)
|
||||
@@ -1250,22 +1250,6 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
// Deleting a note asks for confirmation first — the edit/delete icons sit close together and are
|
||||
// easy to mis-tap on touch devices, where an accidental delete was previously unrecoverable.
|
||||
const [pendingDeleteNote, setPendingDeleteNote] = useState<{ dayId: number; noteId: number } | null>(null)
|
||||
// The plan sidebar is resizable. Below this the route button's own word is the
|
||||
// first thing that stops fitting beside the two export buttons — the icon says
|
||||
// the same thing, and the accessible name still spells it out.
|
||||
//
|
||||
// A callback ref rather than `useRef`, so the measurement happens when the
|
||||
// element exists rather than on a mount that may render nothing yet.
|
||||
const [panel, setPanel] = useState<HTMLElement | null>(null)
|
||||
const [narrowPanel, setNarrowPanel] = useState(false)
|
||||
useEffect(() => {
|
||||
if (!panel || typeof ResizeObserver === 'undefined') return
|
||||
const measure = (): void => setNarrowPanel(panel.clientWidth < NARROW_PLAN_PX)
|
||||
measure()
|
||||
const ro = new ResizeObserver(measure)
|
||||
ro.observe(panel)
|
||||
return () => ro.disconnect()
|
||||
}, [panel])
|
||||
// A stable key for the current selection. A multi-day place renders one row per
|
||||
// day (same place_id, different assignment ids); selecting it by place_id alone
|
||||
// (e.g. clicking an accommodation) marks every one of those rows selected, so a
|
||||
@@ -1440,7 +1424,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
// trip switch above this, and at height 100% alone the list ran the switch's height
|
||||
// past the panel's clipped edge, so the last day could never be scrolled into view.
|
||||
// Where nothing sits above it (the mobile shell), the height still fills the panel.
|
||||
<div ref={setPanel} data-touch-drag={dragDisabled ? undefined : ''} style={{ display: 'flex', flexDirection: 'column', flex: '1 1 0%', minHeight: 0, height: '100%', position: 'relative', fontFamily: "var(--font-system)" }}>
|
||||
<div data-touch-drag={dragDisabled ? undefined : ''} style={{ display: 'flex', flexDirection: 'column', flex: '1 1 0%', minHeight: 0, height: '100%', position: 'relative', fontFamily: "var(--font-system)" }}>
|
||||
{/* Toolbar */}
|
||||
{toursEnabled && selectedDayId != null && projectDayItinerary(assignments[String(selectedDayId)] || [], true, places).some(item => item.kind === 'tour' && !item.valid) && (
|
||||
<div role="status" style={{ color: 'var(--warning)', padding: '8px 12px' }}>
|
||||
@@ -1663,12 +1647,12 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
</div>
|
||||
|
||||
<div className={hasDayPills ? 'min-w-0 pt-[5px]' : 'min-w-0'}>
|
||||
<div className="flex min-w-0 items-baseline gap-2">
|
||||
<span className={`${headingFit(heading).primary} font-bold text-content`} style={fs(13.5, 'body')}>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className={`${headingFit(heading).primary} ${heading.nameFirst ? 'font-bold text-content' : DAY_DATE_BADGE}`} style={heading.nameFirst ? fs(13.5, 'body') : fs(11)}>
|
||||
{heading.primary}
|
||||
</span>
|
||||
{heading.secondary && (
|
||||
<span className={`${headingFit(heading).secondary} text-content-faint`} style={fs(11)}>
|
||||
<span className={`${headingFit(heading).secondary} ${heading.nameFirst ? DAY_DATE_BADGE : 'text-content-muted'}`} style={fs(11)}>
|
||||
{heading.secondary}
|
||||
</span>
|
||||
)}
|
||||
@@ -2519,8 +2503,8 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
|
||||
{/* Routen-Werkzeuge (ausgewählter Tag, 2+ Orte — oder 1 Ort mit Hotel-Bookend #1330 — oder Hotel-zu-Hotel-Transfertag ohne Orte #1297) */}
|
||||
{showRouteTools && (
|
||||
<div data-dp="route-tools" className="mt-1 flex flex-col gap-2 border-t border-edge-faint px-1 pb-0.5 pt-2">
|
||||
<div className="flex items-center gap-1">
|
||||
<div data-dp="route-tools" className="mt-1 flex flex-col gap-2 border-t border-edge-faint px-1 pb-0.5 pt-2 [container-type:inline-size]">
|
||||
<div className="trek-desktop-panel flex flex-wrap items-center gap-2">
|
||||
<button type="button"
|
||||
onClick={() => {
|
||||
if (showRouteToolsWhenExpanded) {
|
||||
@@ -2540,14 +2524,15 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
}}
|
||||
aria-label={t('dayplan.route')}
|
||||
aria-pressed={routeActive}
|
||||
className={`inline-flex h-8 flex-none items-center gap-1.5 rounded-[10px] px-3 font-semibold transition-colors ${routeActive ? 'bg-accent text-accent-text' : `${ROUTE_TOOL} text-content-secondary hover:text-content`}`}
|
||||
className={`inline-flex h-8 flex-none items-center justify-center gap-1.5 rounded-[10px] px-3 font-semibold transition-colors [@container(max-width:340px)]:w-8 [@container(max-width:340px)]:px-0 ${routeActive ? 'bg-accent text-accent-text' : `${ROUTE_TOOL} text-content-secondary hover:text-content`}`}
|
||||
style={fs(12, 'body')}
|
||||
>
|
||||
<RouteIcon size={13} strokeWidth={2.2} />
|
||||
{!narrowPanel && t('dayplan.route')}
|
||||
<RouteIcon size={14} strokeWidth={2} />
|
||||
<span className="whitespace-nowrap [@container(max-width:340px)]:hidden">{t('dayplan.route')}</span>
|
||||
</button>
|
||||
{/* The day's travel mode as one segmented control. */}
|
||||
<div className={`inline-flex h-8 flex-none items-center gap-0.5 rounded-[10px] p-[3px] ${ROUTE_TOOL}`}>
|
||||
<div role="group" aria-label={t('dayplan.transportMode.change')}
|
||||
className={`inline-flex h-8 flex-none items-center gap-1 rounded-[10px] px-1 ${ROUTE_TOOL}`}>
|
||||
{routeProfileOptions.map(p => {
|
||||
const ModeIcon = routeModeIcon(p.key)
|
||||
const active = (day.default_transport_mode ?? routeProfile) === p.key
|
||||
@@ -2557,15 +2542,14 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
onClick={() => setDayDefaultMode(day.id, p.key)}
|
||||
aria-label={p.label}
|
||||
aria-pressed={active}
|
||||
className={`grid h-[26px] w-8 place-items-center rounded-[7px] transition-colors ${active ? 'bg-surface-tertiary text-content' : 'text-content-muted hover:text-content'}`}
|
||||
className={`grid h-6 w-8 place-items-center rounded-md transition-colors ${active ? 'bg-surface-selected text-content' : 'text-content-muted hover:bg-surface-hover hover:text-content'}`}
|
||||
>
|
||||
<ModeIcon size={13} strokeWidth={2} />
|
||||
<ModeIcon size={14} strokeWidth={2} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<span className="flex-1" />
|
||||
{/* Icon-only (#1981): the label stays as the accessible name and the tooltip. */}
|
||||
<BarButton label={t('dayplan.optimize')} onClick={() => handleOptimize(day.id)} placement="top" className={ROUTE_TOOL}>
|
||||
<RotateCcw size={14} strokeWidth={2} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useId, useRef } from 'react'
|
||||
import { Palette, Text } from 'lucide-react'
|
||||
import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
@@ -9,8 +10,7 @@ import { noteSurface } from './noteSurface'
|
||||
import { markdownLinkComponents } from '../shared/markdownLink'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { DeleteButton, DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { EditorField, TEXTAREA } from '../shared/dialogParts'
|
||||
import { EYEBROW } from './bookings/bookingParts'
|
||||
import { CardHead, EditorField, PANEL, TEXTAREA } from '../shared/dialogParts'
|
||||
import { tintOf } from './planParts'
|
||||
|
||||
interface NoteModalUi {
|
||||
@@ -115,10 +115,11 @@ function OpenNoteDialog({ dayId, ui, setNoteUi, cancelNote, saveNote, onRequestD
|
||||
)
|
||||
|
||||
return (
|
||||
<DialogShell onClose={() => cancelNote(day)} labelledBy={labelId} width="editor" header={header} footer={footer}>
|
||||
<div className="grid grid-cols-1 items-start gap-5 sm:grid-cols-[210px_minmax(0,1fr)]">
|
||||
<DialogShell onClose={() => cancelNote(day)} labelledBy={labelId} width="wide" header={header} footer={footer}>
|
||||
<div className="grid grid-cols-1 items-start gap-5 sm:grid-cols-[minmax(215px,1fr)_minmax(0,2fr)]">
|
||||
{/* Left: how it looks. */}
|
||||
<div className="flex min-w-0 flex-col gap-4">
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Palette size={16} />} title={t('notes.appearance')} />
|
||||
<EditorField label={t('dayplan.noteIcon')}>
|
||||
<div role="group" aria-label={t('dayplan.noteIcon')} className="flex flex-wrap gap-[5px]">
|
||||
{NOTE_ICONS.map(({ id, Icon }) => {
|
||||
@@ -127,7 +128,7 @@ function OpenNoteDialog({ dayId, ui, setNoteUi, cancelNote, saveNote, onRequestD
|
||||
return (
|
||||
<Tooltip key={id} label={id}>
|
||||
<button type="button" onClick={() => patch({ icon: id })} aria-pressed={on} aria-label={id}
|
||||
className={`grid h-[38px] w-[38px] place-items-center rounded-[10px] border-2 ${on ? 'border-content bg-surface-hover' : 'border-edge-faint hover:bg-surface-hover'}`}>
|
||||
className={`grid h-[38px] w-[38px] place-items-center rounded-[10px] border-2 ${on ? 'border-content bg-surface-hover' : 'border-edge-faint bg-surface-input hover:bg-surface-hover'}`}>
|
||||
<Icon size={16} strokeWidth={1.8} color={on ? (color ?? 'var(--text-primary)') : 'var(--text-muted)'} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
@@ -151,17 +152,18 @@ function OpenNoteDialog({ dayId, ui, setNoteUi, cancelNote, saveNote, onRequestD
|
||||
</span>
|
||||
</div>
|
||||
</EditorField>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Right: what it says. */}
|
||||
<div className="flex min-w-0 flex-col gap-3">
|
||||
<section className={PANEL}>
|
||||
<div className="min-w-0">
|
||||
<div className="mb-[5px] flex flex-wrap items-center justify-between gap-2">
|
||||
<label htmlFor={bodyId} className={EYEBROW} style={fs(9.5)}>{t('dayplan.noteSubtitle')}</label>
|
||||
<CardHead icon={<Text size={16} />} title={t('dayplan.noteSubtitle')} />
|
||||
<NoteFormatToolbar textareaRef={bodyRef} onChange={v => patch({ time: v })} compact />
|
||||
</div>
|
||||
<textarea
|
||||
id={bodyId}
|
||||
aria-label={t('dayplan.noteSubtitle')}
|
||||
ref={bodyRef}
|
||||
value={ui.time}
|
||||
maxLength={DAY_NOTE_DETAIL_MAX}
|
||||
@@ -182,7 +184,7 @@ function OpenNoteDialog({ dayId, ui, setNoteUi, cancelNote, saveNote, onRequestD
|
||||
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownLinkComponents}>{ui.time}</Markdown>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</DialogShell>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, type ReactNode } from 'react'
|
||||
import { CalendarDays, Clock, ExternalLink, FileText, Pencil } from 'lucide-react'
|
||||
import { Route, NotebookPen, Paperclip, CalendarDays, Clock, ExternalLink, FileText, Pencil } from 'lucide-react'
|
||||
import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
@@ -133,13 +133,13 @@ function TransportDetailDialog({ res, setTransportDetail, onNavigateToFiles, onE
|
||||
|
||||
{/* Public-transit itinerary (#1065): the legs the transit search stored. */}
|
||||
{transit && transit.legs.length > 0 && (
|
||||
<DialogSection label={t('transit.itinerary')}>
|
||||
<DialogSection icon={Route} label={t('transit.itinerary')}>
|
||||
<TransitLegs legs={transit.legs} />
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
{res.notes && (
|
||||
<DialogSection label={t('reservations.notes')}>
|
||||
<DialogSection icon={NotebookPen} label={t('reservations.notes')}>
|
||||
<div className={`${BOX} collab-note-md px-3.5 py-3 text-content-secondary`} style={{ ...fs(13, 'body'), wordBreak: 'break-word', overflowWrap: 'anywhere' }}>
|
||||
<Markdown remarkPlugins={[remarkGfm, remarkBreaks]} components={markdownLinkComponents}>{res.notes}</Markdown>
|
||||
</div>
|
||||
@@ -147,7 +147,7 @@ function TransportDetailDialog({ res, setTransportDetail, onNavigateToFiles, onE
|
||||
)}
|
||||
|
||||
{files.length > 0 && (
|
||||
<DialogSection label={t('files.title')}>
|
||||
<DialogSection icon={Paperclip} label={t('files.title')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{files.map(f => (
|
||||
<button key={f.id} type="button" onClick={() => { close(); onNavigateToFiles?.() }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { useRef, useId } from 'react'
|
||||
import { Check, FileDown, Loader2, Upload } from 'lucide-react'
|
||||
import { FileUp, Check, FileDown, Loader2, Upload } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useToast } from '../shared/Toast'
|
||||
import { useTripStore } from '../../store/tripStore'
|
||||
@@ -106,7 +106,7 @@ export default function FileImportModal({ isOpen, onClose, tripId, pushUndo, ini
|
||||
onDragEnter={handleDragOver}
|
||||
onDragLeave={handleDragLeave}
|
||||
onDrop={handleDrop}
|
||||
className={`flex min-h-[96px] w-full flex-col items-center justify-center gap-1.5 rounded-[14px] border-2 border-dashed p-4 font-medium transition-colors ${isDragOver ? 'border-accent bg-surface-tertiary' : 'border-edge bg-surface-secondary hover:border-content-faint'}`}
|
||||
className={`trek-form-control flex min-h-24 w-full flex-col items-center justify-center gap-2 rounded-[10px] border border-dashed p-4 font-medium transition-colors ${isDragOver ? 'border-accent bg-surface-tertiary' : 'border-edge bg-surface-input hover:border-content-faint'}`}
|
||||
style={fs(13, 'body')}
|
||||
>
|
||||
<Upload size={18} strokeWidth={1.8} className={`pointer-events-none ${isDragOver ? 'text-accent' : 'text-content-faint'}`} />
|
||||
@@ -115,7 +115,7 @@ export default function FileImportModal({ isOpen, onClose, tripId, pushUndo, ini
|
||||
</EditorField>
|
||||
|
||||
{isGpx && (
|
||||
<DialogSection label={t('places.gpxImportTypes')}>
|
||||
<DialogSection icon={FileUp} label={t('places.gpxImportTypes')}>
|
||||
<div className={TYPE_BOX}>
|
||||
{(['waypoints', 'routes', 'tracks'] as const).map(key => (
|
||||
<TypeCheck
|
||||
@@ -131,7 +131,7 @@ export default function FileImportModal({ isOpen, onClose, tripId, pushUndo, ini
|
||||
)}
|
||||
|
||||
{isKml && (
|
||||
<DialogSection label={t('places.kmlImportTypes')}>
|
||||
<DialogSection icon={FileUp} label={t('places.kmlImportTypes')}>
|
||||
<div className={TYPE_BOX}>
|
||||
{(['points', 'paths'] as const).map(key => (
|
||||
<TypeCheck
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId } from 'react'
|
||||
import { Copy, DoorClosed, Mail, Phone, RotateCcw, X } from 'lucide-react'
|
||||
import { Clock, Copy, DoorClosed, Mail, Phone, RotateCcw, X } from 'lucide-react'
|
||||
import type { PlaceClientOrigin, PlaceOpeningHours } from '@trek/shared'
|
||||
import CustomTimePicker from '../shared/CustomTimePicker'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
@@ -68,7 +68,7 @@ export function PlaceContactFields({ id: anchorId, phone, email, openingHours, o
|
||||
</EditorField>
|
||||
</div>
|
||||
|
||||
<DialogSection
|
||||
<DialogSection icon={Clock}
|
||||
label={t('inspector.openingHours')}
|
||||
action={editing ? (
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
@@ -248,14 +248,10 @@ export default function PlaceDetailsColumn({
|
||||
if (mobile && !selection) return pictures
|
||||
|
||||
return (
|
||||
// 320px, not 288: the picture grid was doing (288 - 24 - 12) / 3 = 84px
|
||||
// tiles, which is too small to tell a facade from a foyer. The column is
|
||||
// stretched to the form's height by the row it sits in, so the extra room
|
||||
// costs nothing that was being used.
|
||||
<aside className={dialog ? `${SIDE_COLUMN} ${fluid ? '' : 'sm:w-80'}` : `w-full ${fluid ? '' : 'sm:w-80'} shrink-0 flex flex-col self-stretch`}>
|
||||
{mobile && pictures}
|
||||
{dialog ? (
|
||||
<ColumnHead icon={<Landmark size={13} strokeWidth={2.2} />}>{t('places.details.title')}</ColumnHead>
|
||||
<ColumnHead icon={<Landmark size={16} strokeWidth={2} />}>{t('places.details.title')}</ColumnHead>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -16,6 +16,8 @@ interface PlaceFormLocationProps {
|
||||
onChange: (field: LocationField, value: string) => void;
|
||||
/** Off where the form explains a missing position in its own words (a service stop). */
|
||||
warnWithoutCoordinates: boolean;
|
||||
/** Search and location already share a panel in the place editor. */
|
||||
grouped?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +25,13 @@ interface PlaceFormLocationProps {
|
||||
* An address typed without coordinates says under the field that the place will not be
|
||||
* on the map, and how to put it there (#2837).
|
||||
*/
|
||||
export function PlaceFormLocation({ fieldId, form, onChange, warnWithoutCoordinates }: PlaceFormLocationProps) {
|
||||
export function PlaceFormLocation({
|
||||
fieldId,
|
||||
form,
|
||||
onChange,
|
||||
warnWithoutCoordinates,
|
||||
grouped = false,
|
||||
}: PlaceFormLocationProps) {
|
||||
const { t } = useTranslation();
|
||||
// "48.85, 2.35" pasted into either coordinate fills both halves.
|
||||
const pastePair = (e: React.ClipboardEvent<HTMLInputElement>) => {
|
||||
@@ -41,7 +49,7 @@ export function PlaceFormLocation({ fieldId, form, onChange, warnWithoutCoordina
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<div className={grouped ? 'contents' : PANEL}>
|
||||
<EditorField label={t('places.formAddress')} htmlFor={`${fieldId}-address`} hint={hint}>
|
||||
<input
|
||||
id={`${fieldId}-address`}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Paperclip, X } from 'lucide-react';
|
||||
import { ImagePlus, Paperclip, X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import type { TranslationFn } from '../../types';
|
||||
import { fs } from '../shared/DialogShell';
|
||||
import { Tooltip } from '../shared/Tooltip';
|
||||
import { LABEL } from '../shared/dialogParts';
|
||||
import { CardHead, LABEL } from '../shared/dialogParts';
|
||||
import PlaceImagePicker, { type PlaceImageOwn } from './PlaceImagePicker';
|
||||
import { COLUMN_CARD, WHITE_BUTTON } from './placeDialogParts';
|
||||
import { offersPictures, type ChosenImage } from './placeImageChoice';
|
||||
@@ -84,8 +84,8 @@ export function PlaceImageSection({
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="min-w-0">
|
||||
<div className={LABEL}>{t('places.details.pickImage')}</div>
|
||||
<div className="min-w-0 space-y-3">
|
||||
<CardHead icon={<ImagePlus size={16} strokeWidth={2} />} title={t('places.details.pickImage')} />
|
||||
<div className={`${COLUMN_CARD} p-2`}>
|
||||
<PlaceImagePicker photos={[]} chosen={image.chosen} onPickUrl={onPickUrl} own={image.own} dialog t={t} />
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LocateFixed, PencilLine, RotateCcw, Search } from 'lucide-react';
|
||||
import { Clock3, LocateFixed, Paperclip, PencilLine, RotateCcw, Search, Signpost } from 'lucide-react';
|
||||
import { useId, type ReactNode } from 'react';
|
||||
import { offersGoogleRetry } from '../../utils/placeSource';
|
||||
import { safeHexColor } from '../../utils/safeColor';
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { Tooltip } from '../shared/Tooltip';
|
||||
import { getCategoryIcon } from '../shared/categoryIcons';
|
||||
import { focusRevealedEditor } from '../shared/dialogFocus';
|
||||
import { EditorField, GRID_2, INPUT, LABEL, PANEL, TEXTAREA } from '../shared/dialogParts';
|
||||
import { CardHead, EditorField, GRID_2, INPUT, PANEL, TEXTAREA } from '../shared/dialogParts';
|
||||
import { BookingCostsSection } from './BookingCostsSection';
|
||||
import { PlaceContactFields } from './PlaceContactFields';
|
||||
import PlaceDetailsColumn from './PlaceDetailsColumn';
|
||||
@@ -41,14 +41,13 @@ function SourceBadge({ label }: { label: string | null }) {
|
||||
return <SoftPill>{label}</SoftPill>;
|
||||
}
|
||||
|
||||
const ROW = 'flex items-stretch gap-5';
|
||||
const ROW = 'flex items-start gap-5';
|
||||
const STACK = 'flex flex-col gap-5';
|
||||
const FORM_COLUMN = 'flex min-w-0 flex-1 flex-col gap-4';
|
||||
/** A row of the typed-ahead list or of the search results. */
|
||||
const PICK_ROW = 'flex w-full items-center gap-2 rounded-[8px] px-2.5 py-2 text-start';
|
||||
/** The small accent square beside a field that runs its action, sized by the row it sits in. */
|
||||
const SIDE_BUTTON =
|
||||
'grid w-[38px] flex-none place-items-center rounded-[10px] transition-colors disabled:cursor-default disabled:opacity-60';
|
||||
'trek-form-control trek-form-square grid size-10 flex-none place-items-center rounded-[10px] border border-edge bg-surface-input text-content transition-colors hover:bg-surface-hover disabled:cursor-default disabled:opacity-50';
|
||||
/**
|
||||
* ServiceStopSection draws its labels in the old form's look and takes no class
|
||||
* for them; this gives them the eyebrow every other field here has.
|
||||
@@ -113,8 +112,6 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
|
||||
let headerSub: ReactNode;
|
||||
if (serviceStopDuplicate) {
|
||||
headerSub = <span className="text-warning">{t('roadtrip.stop.duplicate', { name: serviceStopDuplicate })}</span>;
|
||||
} else if (!form.name.trim()) {
|
||||
headerSub = `${t('places.formName')} *`;
|
||||
}
|
||||
|
||||
const header = (
|
||||
@@ -211,6 +208,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
|
||||
|
||||
const schedule = (proposal || (place && S.assignmentId)) && (
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<Clock3 size={16} strokeWidth={2} />} title={t('places.formTime')} />
|
||||
<TimeSection
|
||||
form={form}
|
||||
handleChange={handleChange}
|
||||
@@ -318,14 +316,17 @@ function PlaceFormColumns({
|
||||
/>
|
||||
)}
|
||||
<form onSubmit={handleSubmit} className={FORM_COLUMN}>
|
||||
<PlaceSearchFields state={S} fieldId={fieldId} />
|
||||
|
||||
<PlaceFormLocation
|
||||
fieldId={fieldId}
|
||||
form={form}
|
||||
onChange={handleChange}
|
||||
warnWithoutCoordinates={!serviceStop}
|
||||
/>
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<Search size={16} strokeWidth={2} />} title={t('common.search')} />
|
||||
<PlaceSearchFields state={S} fieldId={fieldId} />
|
||||
<PlaceFormLocation
|
||||
fieldId={fieldId}
|
||||
form={form}
|
||||
onChange={handleChange}
|
||||
warnWithoutCoordinates={!serviceStop}
|
||||
grouped
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* For a stop on a drive: the kind of stop, how long, and where it belongs.
|
||||
The category it replaces is gone from the head band too: refuelling is
|
||||
@@ -333,6 +334,7 @@ function PlaceFormColumns({
|
||||
`places.stop_type` and not in the trip's own editable category list. */}
|
||||
{serviceStop && (
|
||||
<div className={`${PANEL} ${SERVICE_STOP_LABELS}`}>
|
||||
<CardHead icon={<Signpost size={16} strokeWidth={2} />} title={t('roadtrip.title')} />
|
||||
<ServiceStopSection
|
||||
mode={serviceStop}
|
||||
stopType={form.stop_type ?? null}
|
||||
@@ -393,7 +395,6 @@ function PlaceFormColumns({
|
||||
onCreate={S.handleCreateExpense}
|
||||
onEdit={S.handleEditExpense}
|
||||
onRemove={S.handleRemoveExpense}
|
||||
labelClassName={LABEL}
|
||||
customTooltips
|
||||
whiteButtons
|
||||
/>
|
||||
@@ -435,92 +436,90 @@ function PlaceSearchFields({ state: S, fieldId }: { state: PlaceFormState; field
|
||||
handleSearchKeyDown,
|
||||
} = S;
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<EditorField label={t('common.search')} htmlFor={`${fieldId}-search`}>
|
||||
<div className="relative">
|
||||
<div className="flex items-stretch gap-2">
|
||||
<input
|
||||
id={`${fieldId}-search`}
|
||||
type="text"
|
||||
// A new place starts at the search; an edit or a place brought
|
||||
// in from the map already has what the search would give.
|
||||
ref={!place && !prefillCoords ? focusRevealedEditor : undefined}
|
||||
value={mapsSearch}
|
||||
onChange={(e) => {
|
||||
setMapsSearch(e.target.value);
|
||||
S.setEmptySearch(null);
|
||||
<div className="contents">
|
||||
<div className="relative">
|
||||
<div className="flex items-stretch gap-2">
|
||||
<input
|
||||
id={`${fieldId}-search`}
|
||||
type="text"
|
||||
aria-label={t('common.search')}
|
||||
// A new place starts at the search; an edit or a place brought
|
||||
// in from the map already has what the search would give.
|
||||
ref={!place && !prefillCoords ? focusRevealedEditor : undefined}
|
||||
value={mapsSearch}
|
||||
onChange={(e) => {
|
||||
setMapsSearch(e.target.value);
|
||||
S.setEmptySearch(null);
|
||||
}}
|
||||
onKeyDown={handleSearchKeyDown}
|
||||
onBlur={() => setTimeout(() => setAcSuggestions([]), 150)}
|
||||
onFocus={() => {
|
||||
if (mapsSearch.trim().length >= 2 && acSuggestions.length === 0 && mapsResults.length === 0) {
|
||||
fetchSuggestions(mapsSearch.trim());
|
||||
}
|
||||
}}
|
||||
placeholder={t('places.mapsSearchPlaceholder')}
|
||||
className={`${INPUT} flex-1`}
|
||||
/>
|
||||
<Tooltip label={t('common.search')}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setAcSuggestions([]);
|
||||
void handleMapsSearch();
|
||||
}}
|
||||
onKeyDown={handleSearchKeyDown}
|
||||
onBlur={() => setTimeout(() => setAcSuggestions([]), 150)}
|
||||
onFocus={() => {
|
||||
if (mapsSearch.trim().length >= 2 && acSuggestions.length === 0 && mapsResults.length === 0) {
|
||||
fetchSuggestions(mapsSearch.trim());
|
||||
}
|
||||
}}
|
||||
placeholder={t('places.mapsSearchPlaceholder')}
|
||||
className={`${INPUT} flex-1`}
|
||||
/>
|
||||
<Tooltip label={t('common.search')}>
|
||||
disabled={isSearchingMaps}
|
||||
aria-label={t('common.search')}
|
||||
className={SIDE_BUTTON}
|
||||
>
|
||||
{isSearchingMaps ? '...' : <Search size={15} strokeWidth={2.2} aria-hidden="true" />}
|
||||
</button>
|
||||
</Tooltip>
|
||||
{pin && (
|
||||
<Tooltip label={t('places.nearby')}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setAcSuggestions([]);
|
||||
void handleMapsSearch();
|
||||
}}
|
||||
onClick={handleNearby}
|
||||
disabled={isSearchingMaps}
|
||||
aria-label={t('common.search')}
|
||||
className={`${SIDE_BUTTON} bg-accent text-accent-text hover:opacity-90`}
|
||||
style={fs(13, 'body')}
|
||||
aria-label={t('places.nearby')}
|
||||
className={SIDE_BUTTON}
|
||||
>
|
||||
{isSearchingMaps ? '...' : <Search size={15} strokeWidth={2.2} aria-hidden="true" />}
|
||||
<LocateFixed size={15} strokeWidth={2.2} aria-hidden="true" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
{pin && (
|
||||
<Tooltip label={t('places.nearby')}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleNearby}
|
||||
disabled={isSearchingMaps}
|
||||
aria-label={t('places.nearby')}
|
||||
className={`${SIDE_BUTTON} border border-edge bg-surface-card text-content-secondary hover:bg-surface-hover`}
|
||||
>
|
||||
<LocateFixed size={15} strokeWidth={2.2} aria-hidden="true" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Autocomplete dropdown. Capped and scrolling, because plugin rows can
|
||||
follow the core ones (#2221) and the list must stay inside the dialog;
|
||||
the row the arrow keys land on is scrolled into view. */}
|
||||
{acSuggestions.length > 0 && (
|
||||
<div className="absolute inset-x-0 z-20 mt-1 max-h-96 overflow-y-auto rounded-[12px] border border-edge-faint bg-surface-card p-1 shadow-dropdown">
|
||||
{acSuggestions.map((s, idx) => (
|
||||
<button
|
||||
key={s.placeId}
|
||||
ref={idx === acHighlight ? (el) => el?.scrollIntoView?.({ block: 'nearest' }) : undefined}
|
||||
type="button"
|
||||
onMouseDown={() => handleSelectSuggestion(s)}
|
||||
onMouseEnter={() => setAcHighlight(idx)}
|
||||
className={`${PICK_ROW} ${idx === acHighlight ? 'bg-surface-tertiary' : 'hover:bg-surface-hover'}`}
|
||||
>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-medium text-content" style={fs(13, 'body')}>
|
||||
{s.mainText}
|
||||
</span>
|
||||
{s.secondaryText && (
|
||||
<span className="block truncate text-content-muted" style={fs(11.5)}>
|
||||
{s.secondaryText}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<SourceBadge label={sourceLabel(s, acSource)} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</EditorField>
|
||||
|
||||
{/* Autocomplete dropdown. Capped and scrolling, because plugin rows can
|
||||
follow the core ones (#2221) and the list must stay inside the dialog;
|
||||
the row the arrow keys land on is scrolled into view. */}
|
||||
{acSuggestions.length > 0 && (
|
||||
<div className="absolute inset-x-0 z-20 mt-1 max-h-96 overflow-y-auto rounded-[12px] border border-edge-faint bg-surface-card p-1 shadow-dropdown">
|
||||
{acSuggestions.map((s, idx) => (
|
||||
<button
|
||||
key={s.placeId}
|
||||
ref={idx === acHighlight ? (el) => el?.scrollIntoView?.({ block: 'nearest' }) : undefined}
|
||||
type="button"
|
||||
onMouseDown={() => handleSelectSuggestion(s)}
|
||||
onMouseEnter={() => setAcHighlight(idx)}
|
||||
className={`${PICK_ROW} ${idx === acHighlight ? 'bg-surface-tertiary' : 'hover:bg-surface-hover'}`}
|
||||
>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-medium text-content" style={fs(13, 'body')}>
|
||||
{s.mainText}
|
||||
</span>
|
||||
{s.secondaryText && (
|
||||
<span className="block truncate text-content-muted" style={fs(11.5)}>
|
||||
{s.secondaryText}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<SourceBadge label={sourceLabel(s, acSource)} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Nothing found (#2472): say so, and offer the hand-made way in, taking
|
||||
the query as the name when there is none yet. */}
|
||||
@@ -605,6 +604,7 @@ function PlaceContactAndFiles({ state: S, fieldId }: { state: PlaceFormState; fi
|
||||
const { canUploadFiles, form, handleChange, t } = S;
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<Paperclip size={16} strokeWidth={2} />} title={t('places.formContactSection')} />
|
||||
{/* The link and the files side by side, as on a booking. */}
|
||||
<div className={canUploadFiles ? GRID_2 : ''}>
|
||||
<EditorField label={t('places.formWebsite')} htmlFor={`${fieldId}-website`}>
|
||||
|
||||
@@ -84,15 +84,15 @@ describe('PlaceFormTags', () => {
|
||||
expect(screen.queryByRole('button', { name: '#10b981' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("FE-PLANNER-PLFORMTAGS-006: the new tag's colour is picked the same way and tints the field once a name is typed", () => {
|
||||
it("FE-PLANNER-PLFORMTAGS-006: the new tag's colour is shown on its swatch and uses the same palette", () => {
|
||||
const tags = field({ name: 'Food' });
|
||||
render(<PlaceFormTags tags={tags} t={t} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: 'places.newTagColor' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '#f97316' }));
|
||||
expect(tags.setNewColor).toHaveBeenCalledWith('#f97316');
|
||||
expect(tags.recolor).not.toHaveBeenCalled();
|
||||
const pill = screen.getByRole('textbox', { name: 'places.newTag' }).parentElement as HTMLElement;
|
||||
expect(pill.style.background).toContain('#ec4899');
|
||||
const swatch = screen.getByRole('button', { name: 'places.newTagColor' }).querySelector('span');
|
||||
expect(swatch).toHaveStyle({ background: '#ec4899' });
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLFORMTAGS-007: Escape and a click outside close the palette without a pick', () => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { TRIP_TAG_NAME_MAX } from '@trek/shared';
|
||||
import { Check, Plus } from 'lucide-react';
|
||||
import { Check, Plus, Tag } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { DialogSection, fs } from '../shared/DialogShell';
|
||||
import { PANEL } from '../shared/dialogParts';
|
||||
import { fs } from '../shared/DialogShell';
|
||||
import { CardHead, PANEL } from '../shared/dialogParts';
|
||||
import { TagColorPopover } from './TagColorPopover';
|
||||
import type { PlaceTagsField } from './usePlaceTags';
|
||||
|
||||
@@ -12,36 +12,32 @@ type Translate = (key: string, params?: Record<string, string | number>) => stri
|
||||
const ROW = 'flex flex-wrap items-center gap-2';
|
||||
/** One tag: the colour dot and the name, two buttons in one pill. */
|
||||
const PILL =
|
||||
'relative inline-flex h-8 min-w-0 max-w-full items-center rounded-full border shadow-sm transition-[background-color,border-color,box-shadow] duration-150';
|
||||
'trek-form-chip relative inline-flex min-h-[34px] min-w-0 max-w-full items-center rounded-full border transition-colors';
|
||||
const PILL_OFF = 'border-edge bg-surface-input hover:border-content-faint';
|
||||
const DOT_BUTTON =
|
||||
'ms-1 grid h-6 w-6 flex-none place-items-center rounded-full transition-transform duration-150 hover:scale-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--text-primary)]';
|
||||
const DOT = 'h-3.5 w-3.5 rounded-full ring-1 ring-inset ring-edge';
|
||||
const NAME_BUTTON = 'inline-flex h-full min-w-0 items-center gap-1.5 rounded-e-full ps-1.5 font-medium';
|
||||
/** The tick of a picked tag, in a round white badge. */
|
||||
const TICK = 'me-1 grid h-5 w-5 flex-none place-items-center rounded-full bg-surface-card shadow-sm';
|
||||
const TICK = 'me-2 grid h-5 w-5 flex-none place-items-center rounded-full';
|
||||
const NEW_TAG =
|
||||
'relative inline-flex h-8 min-w-0 items-center rounded-full border pe-1 transition-[background-color,border-color,box-shadow] duration-150 focus-within:shadow-sm';
|
||||
const NEW_TAG_INPUT = 'w-32 min-w-0 bg-transparent ps-1.5 text-content outline-none placeholder:text-content-faint';
|
||||
'trek-form-control relative inline-flex min-w-0 flex-1 items-center rounded-[10px] border border-edge bg-surface-input px-1.5 focus-within:ring-2 focus-within:ring-accent';
|
||||
const NEW_TAG_INPUT = 'w-full min-w-0 bg-transparent px-1.5 text-content outline-none placeholder:text-content-faint';
|
||||
const ADD_BUTTON =
|
||||
'grid h-6 w-6 flex-none place-items-center rounded-full shadow-sm transition-[background-color,color,transform] duration-150 enabled:hover:scale-110 disabled:cursor-default disabled:bg-surface-tertiary disabled:text-content-faint disabled:shadow-none';
|
||||
'trek-form-control trek-form-square grid size-10 flex-none place-items-center rounded-[10px] border bg-accent text-accent-text transition-colors enabled:border-transparent enabled:hover:bg-accent-hover disabled:cursor-default disabled:border-edge disabled:bg-transparent disabled:text-content-muted disabled:opacity-50';
|
||||
|
||||
const FALLBACK_COLOR = 'var(--text-muted)';
|
||||
const tint = (color: string, percent: number) => `color-mix(in srgb, ${color} ${percent}%, var(--bg-input))`;
|
||||
|
||||
/**
|
||||
* The tags of the place form on the desktop, as a card like the search and the
|
||||
* address. Every tag on offer is a pill in its own colour: the name ticks it for
|
||||
* the place, the dot opens a palette that recolours it for the whole trip. The
|
||||
* field after them adds a new tag, in a colour picked the same way and shown on
|
||||
* the field as it is typed. The state is usePlaceTags'; this is its markup.
|
||||
* the place, the dot opens a palette that recolours it for the whole trip.
|
||||
*/
|
||||
export function PlaceFormTags({ tags, t, manage = true }: { tags: PlaceTagsField; t: Translate; manage?: boolean }) {
|
||||
// Which palette is open: a tag's id, 'new' for the new tag's colour, or none.
|
||||
const [palette, setPalette] = useState<number | 'new' | null>(null);
|
||||
// The colour a tag shows while its custom colour is being dragged, before it is kept.
|
||||
const [preview, setPreview] = useState<{ id: number; color: string } | null>(null);
|
||||
const typing = !!tags.name.trim();
|
||||
const closePalette = () => {
|
||||
setPalette(null);
|
||||
setPreview(null);
|
||||
@@ -50,65 +46,62 @@ export function PlaceFormTags({ tags, t, manage = true }: { tags: PlaceTagsField
|
||||
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<DialogSection label={t('places.tags')}>
|
||||
<div role="group" aria-label={t('places.tags')} className={ROW}>
|
||||
{tags.options.map((tag) => {
|
||||
const color = (preview?.id === tag.id ? preview.color : tag.color) ?? FALLBACK_COLOR;
|
||||
return (
|
||||
<span
|
||||
key={tag.id}
|
||||
className={`${PILL} ${tag.on ? '' : PILL_OFF}`}
|
||||
style={tag.on ? { background: tint(color, 18), borderColor: tint(color, 55) } : undefined}
|
||||
>
|
||||
{manage ? (
|
||||
<CardHead icon={<Tag size={16} strokeWidth={2} />} title={t('places.tags')} />
|
||||
<div role="group" aria-label={t('places.tags')} className="space-y-2">
|
||||
{tags.options.length > 0 && (
|
||||
<div className={ROW}>
|
||||
{tags.options.map((tag) => {
|
||||
const color = (preview?.id === tag.id ? preview.color : tag.color) ?? FALLBACK_COLOR;
|
||||
return (
|
||||
<span
|
||||
key={tag.id}
|
||||
className={`${PILL} ${tag.on ? 'border-transparent bg-inverse text-inverse-text' : PILL_OFF}`}
|
||||
>
|
||||
{manage ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('places.tagColor', { name: tag.name })}
|
||||
aria-expanded={palette === tag.id}
|
||||
onClick={() => (palette === tag.id ? closePalette() : setPalette(tag.id))}
|
||||
className={DOT_BUTTON}
|
||||
>
|
||||
<span aria-hidden="true" className={DOT} style={{ background: color }} />
|
||||
</button>
|
||||
) : (
|
||||
<span aria-hidden="true" className={`${DOT} ms-2`} style={{ background: color }} />
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('places.tagColor', { name: tag.name })}
|
||||
aria-expanded={palette === tag.id}
|
||||
onClick={() => (palette === tag.id ? closePalette() : setPalette(tag.id))}
|
||||
className={DOT_BUTTON}
|
||||
aria-pressed={tag.on}
|
||||
onClick={() => tags.toggle(tag.id)}
|
||||
className={`${NAME_BUTTON} ${tag.on ? 'pe-0' : 'pe-3 text-content-secondary hover:text-content'}`}
|
||||
style={fs(12, 'body')}
|
||||
>
|
||||
<span aria-hidden="true" className={DOT} style={{ background: color }} />
|
||||
<span className="truncate">{tag.name}</span>
|
||||
{tag.on && (
|
||||
<span aria-hidden="true" className={TICK}>
|
||||
<Check size={13} strokeWidth={2.2} />
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
) : (
|
||||
<span aria-hidden="true" className={`${DOT} ms-2`} style={{ background: color }} />
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={tag.on}
|
||||
onClick={() => tags.toggle(tag.id)}
|
||||
className={`${NAME_BUTTON} ${tag.on ? 'pe-0 text-content' : 'pe-3 text-content-secondary hover:text-content'}`}
|
||||
style={fs(12, 'body')}
|
||||
>
|
||||
<span className="truncate">{tag.name}</span>
|
||||
{tag.on && (
|
||||
<span aria-hidden="true" className={TICK}>
|
||||
<Check size={11} strokeWidth={3.2} style={{ color }} />
|
||||
</span>
|
||||
{palette === tag.id && (
|
||||
<TagColorPopover
|
||||
label={t('places.tagColor', { name: tag.name })}
|
||||
value={tag.color ?? null}
|
||||
onPick={(next) => void tags.recolor(tag.id, next)}
|
||||
onPreview={(next) => setPreview({ id: tag.id, color: next })}
|
||||
onClose={closePalette}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
{palette === tag.id && (
|
||||
<TagColorPopover
|
||||
label={t('places.tagColor', { name: tag.name })}
|
||||
value={tag.color ?? null}
|
||||
onPick={(next) => void tags.recolor(tag.id, next)}
|
||||
onPreview={(next) => setPreview({ id: tag.id, color: next })}
|
||||
onClose={closePalette}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
{manage && (
|
||||
<span
|
||||
className={NEW_TAG}
|
||||
style={{
|
||||
background: tint(tags.newColor, typing ? 14 : 6),
|
||||
borderColor: tint(tags.newColor, typing ? 60 : 35),
|
||||
borderStyle: typing ? 'solid' : 'dashed',
|
||||
}}
|
||||
>
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{manage && (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className={NEW_TAG}>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('places.newTagColor')}
|
||||
@@ -127,18 +120,8 @@ export function PlaceFormTags({ tags, t, manage = true }: { tags: PlaceTagsField
|
||||
aria-label={t('places.newTag')}
|
||||
placeholder={t('places.newTag')}
|
||||
className={NEW_TAG_INPUT}
|
||||
style={fs(12, 'body')}
|
||||
style={fs(13, 'body')}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void tags.addNew()}
|
||||
disabled={!tags.canAdd}
|
||||
aria-label={t('places.addTag')}
|
||||
className={ADD_BUTTON}
|
||||
style={tags.canAdd ? { background: tags.newColor, color: 'var(--bg-card)' } : undefined}
|
||||
>
|
||||
<Plus size={13} strokeWidth={2.8} />
|
||||
</button>
|
||||
{palette === 'new' && (
|
||||
<TagColorPopover
|
||||
label={t('places.newTagColor')}
|
||||
@@ -149,10 +132,19 @@ export function PlaceFormTags({ tags, t, manage = true }: { tags: PlaceTagsField
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void tags.addNew()}
|
||||
disabled={!tags.canAdd}
|
||||
aria-label={t('places.addTag')}
|
||||
className={ADD_BUTTON}
|
||||
>
|
||||
<Plus size={19} aria-hidden />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useRef, type ReactNode } from 'react';
|
||||
|
||||
import { fs } from '../shared/DialogShell';
|
||||
import NoteFormatToolbar from '../shared/NoteFormatToolbar';
|
||||
import { PANEL, Segmented } from '../shared/dialogParts';
|
||||
import { CardHead, PANEL, Segmented } from '../shared/dialogParts';
|
||||
import { usePlaceTextTabs, type PlaceTextField } from './usePlaceTextTabs';
|
||||
|
||||
type Translate = (key: string, params?: Record<string, string | number>) => string;
|
||||
@@ -60,6 +60,7 @@ export function PlaceFormTexts({
|
||||
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<StickyNote size={16} strokeWidth={2} />} title={t('places.formTextSection')} />
|
||||
<Segmented<PlaceTextField>
|
||||
fill
|
||||
value={shown.field}
|
||||
@@ -82,17 +83,6 @@ export function PlaceFormTexts({
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
{tabs.map((tab) => (
|
||||
<p
|
||||
key={tab.field}
|
||||
id={`${fieldId}-${tab.field}-hint`}
|
||||
hidden={tab.field !== shown.field}
|
||||
className="m-0 -mb-1 leading-snug text-content-muted"
|
||||
style={fs(11)}
|
||||
>
|
||||
{tab.hint}
|
||||
</p>
|
||||
))}
|
||||
{/* The box hides, not the field: the field's own `block` class would win over `hidden`. */}
|
||||
{tabs.map((tab) => (
|
||||
<div key={tab.field} hidden={tab.field !== shown.field} className={FIELD_BOX}>
|
||||
@@ -119,6 +109,17 @@ export function PlaceFormTexts({
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{tabs.map((tab) => (
|
||||
<p
|
||||
key={tab.field}
|
||||
id={`${fieldId}-${tab.field}-hint`}
|
||||
hidden={tab.field !== shown.field}
|
||||
className={tab.field === 'description' ? 'sr-only' : 'm-0 leading-snug text-content-muted'}
|
||||
style={fs(12)}
|
||||
>
|
||||
{tab.hint}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ function UploadTile({
|
||||
disabled={reading}
|
||||
aria-pressed={selected}
|
||||
aria-label={t('places.uploadImage')}
|
||||
className={`${TILE} ${ring(selected, dialog)} ${preview ? '' : dialog ? 'border border-edge-faint bg-surface-secondary hover:bg-surface-tertiary' : 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'}`}
|
||||
className={`${TILE} ${ring(selected, dialog)} ${preview ? '' : dialog ? 'border border-dashed border-edge bg-surface-input hover:bg-surface-hover' : 'border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]'}`}
|
||||
onMouseEnter={() => onHover(!!preview)}
|
||||
onMouseLeave={() => onHover(false)}
|
||||
>
|
||||
|
||||
@@ -6,7 +6,7 @@ import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import { markdownLinkComponents } from '../shared/markdownLink'
|
||||
import { Clock, MapPin, ExternalLink, Pencil, Plus, Minus, ChevronDown, ChevronUp, FileText, Upload, File, FileImage, Navigation, Mountain, Bookmark, BookmarkCheck, Copy, Trash2 } from 'lucide-react'
|
||||
import { Star, Text, NotebookPen, Ticket, Users, Palette, ChartBar, Paperclip, Clock, MapPin, ExternalLink, Pencil, Plus, Minus, ChevronDown, ChevronUp, FileText, Upload, File, FileImage, Navigation, Mountain, Bookmark, BookmarkCheck, Copy, Trash2 } from 'lucide-react'
|
||||
import { hoursLines, periodsFromWeek } from './placeHours'
|
||||
import PlaceRating from '../shared/StarRating'
|
||||
import TrackColorPicker from '../shared/TrackColorPicker'
|
||||
@@ -48,6 +48,7 @@ import LinkedBookingCard from './PlaceLinkedBookingCard'
|
||||
import { usePlaceLanguage } from '../../hooks/usePlaceLanguage'
|
||||
import { participantsWith, participantsWithout, splitParticipants, usePlaceFileUpload } from './usePlaceActions'
|
||||
|
||||
const DETAIL_GRID = 'grid min-w-0 flex-none grid-cols-[repeat(auto-fit,minmax(min(100%,208px),1fr))] gap-3'
|
||||
const detailsCache = new Map()
|
||||
|
||||
function getSessionCache(key) {
|
||||
@@ -363,6 +364,10 @@ export default function PlaceInspector({
|
||||
const phone = place.phone || googleDetails?.phone
|
||||
const description = place.description || googleDetails?.summary
|
||||
const showRating = (mode === 'trip' && !!onRate) || !!shortReview
|
||||
const showParticipants = mode === 'trip' && !!selectedAssignmentId && tripMembers.length > 1
|
||||
const participantIds = assignmentInDay?.id === selectedAssignmentId
|
||||
? assignmentInDay?.participants?.map(participant => participant.user_id) ?? []
|
||||
: []
|
||||
const mapCard = centredMapCard(leftWidth, rightWidth, { clearPill: clearMapPill })
|
||||
|
||||
return (
|
||||
@@ -389,55 +394,60 @@ export default function PlaceInspector({
|
||||
onClose={onClose} />
|
||||
|
||||
{/* The body scrolls inside the capped card; each block keeps its natural height (#1195). */}
|
||||
<div data-testid="inspector-scroll" className={`${collapsed ? 'hidden' : 'flex'} min-h-0 flex-1 flex-col gap-3.5 overflow-y-auto overscroll-contain px-4 py-3.5 empty:hidden`}>
|
||||
|
||||
{/* Collaborative rating (#1435): every member's own vote, shown as the
|
||||
average, and the first review worth quoting. */}
|
||||
{showRating && (
|
||||
// The review alone is a desktop extra, as it always was; without the vote row the block goes with it below md.
|
||||
<DialogSection className={mode === 'trip' && onRate ? 'flex-none' : 'hidden flex-none md:block'} label={t('places.details.fact.rating')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{mode === 'trip' && onRate && (
|
||||
<div className={`${BOX} px-3 py-2`}>
|
||||
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
|
||||
<div data-testid="inspector-scroll" className={`trek-desktop-panel trek-place-inspector-body ${collapsed ? 'hidden' : 'flex'} min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain bg-surface-card px-4 py-3 empty:hidden`}>
|
||||
{(showRating || showParticipants) && (
|
||||
<div className={DETAIL_GRID}>
|
||||
{showRating && (
|
||||
<DialogSection icon={Star} className={mode === 'trip' && onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{mode === 'trip' && onRate && (
|
||||
<div className={`${BOX} px-3 py-2`}>
|
||||
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
|
||||
</div>
|
||||
)}
|
||||
{shortReview && (
|
||||
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{shortReview.text}"</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{shortReview && (
|
||||
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{shortReview.text}"</p>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
</DialogSection>
|
||||
)}
|
||||
{showParticipants && (
|
||||
<ParticipantsBox tripMembers={tripMembers} participantIds={participantIds} allJoined={participantIds.length === 0}
|
||||
onSetParticipants={onSetParticipants} selectedAssignmentId={selectedAssignmentId} selectedDayId={selectedDayId} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(roadtripEndDay || roadtripStay) && (
|
||||
<div className={`${DETAIL_GRID} items-start`}>
|
||||
<VisitControls endDay={roadtripEndDay} stay={roadtripStay} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{roadtripActive && place.stop_type === 'charging' && <ChargingInfo placeId={place.id} />}
|
||||
{(roadtripEndDay || roadtripStay) && <VisitControls endDay={roadtripEndDay} stay={roadtripStay} />}
|
||||
|
||||
{description && (
|
||||
<DialogSection className="flex-none" label={t('places.formDescription')}>
|
||||
<DialogSection icon={Text} className="flex-none" label={t('places.formDescription')}>
|
||||
<MarkdownBox>{description}</MarkdownBox>
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
{place.notes && (
|
||||
<DialogSection className="flex-none" label={t('places.formNotes')}>
|
||||
<MarkdownBox>{place.notes}</MarkdownBox>
|
||||
</DialogSection>
|
||||
{(place.notes || assignmentInDay?.notes) && (
|
||||
<div className={`${DETAIL_GRID} items-start`}>
|
||||
{place.notes && (
|
||||
<DialogSection icon={NotebookPen} label={t('places.formNotes')}>
|
||||
<MarkdownBox>{place.notes}</MarkdownBox>
|
||||
</DialogSection>
|
||||
)}
|
||||
{assignmentInDay?.notes && (
|
||||
<DialogSection icon={NotebookPen} label={t('places.assignmentNotes')}>
|
||||
<MarkdownBox>{assignmentInDay.notes}</MarkdownBox>
|
||||
</DialogSection>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Day-specific assignment note (#2163) — written via MCP/API or the
|
||||
edit form; distinct from the pool-wide place.notes above, so its
|
||||
label says which day-scope it belongs to. */}
|
||||
{assignmentInDay?.notes && (
|
||||
<DialogSection className="flex-none" label={t('places.assignmentNotes')}>
|
||||
<MarkdownBox>{assignmentInDay.notes}</MarkdownBox>
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
{/* Bookings + participants — trip-only (collections have no days) */}
|
||||
{mode === 'trip' && (
|
||||
<PlaceBookingsAndPeople selectedAssignmentId={selectedAssignmentId} placeId={place.id} reservations={reservations}
|
||||
assignments={assignments} selectedDayId={selectedDayId} tripMembers={tripMembers}
|
||||
timeFormat={timeFormat} onSetParticipants={onSetParticipants}
|
||||
<PlaceBookings selectedAssignmentId={selectedAssignmentId} placeId={place.id} reservations={reservations}
|
||||
timeFormat={timeFormat}
|
||||
onEditTransport={onEditTransport} onEditReservation={onEditReservation} onOpenBooking={onOpenBooking} />
|
||||
)}
|
||||
|
||||
@@ -445,8 +455,8 @@ export default function PlaceInspector({
|
||||
setHoursExpanded={setHoursExpanded} timeFormat={timeFormat} place={place} placeFiles={placeFiles}
|
||||
onFileUpload={onFileUpload} filesExpanded={filesExpanded} setFilesExpanded={setFilesExpanded}
|
||||
fileInputRef={fileInputRef} handleFileUpload={handleFileUpload} isUploading={isUploading}
|
||||
distanceUnit={distanceUnit} onUpdatePlace={onUpdatePlace} />
|
||||
{mode === 'trip' && trip && <TripPlaceVisits trip={trip} place={place} language={locale} t={t} />}
|
||||
distanceUnit={distanceUnit} onUpdatePlace={onUpdatePlace}
|
||||
visits={mode === 'trip' && trip ? <TripPlaceVisits trip={trip} place={place} language={locale} t={t} /> : null} />
|
||||
|
||||
{/* Extra native rows from placeDetailProvider plugins (#1429). */}
|
||||
{mode === 'trip' && providerDetails.length > 0 && (
|
||||
@@ -479,7 +489,7 @@ export default function PlaceInspector({
|
||||
|
||||
{/* Footer: the day action and the ways out on the left, the "…" and edit on the right. */}
|
||||
{/* A container: squeezed between the sidebars, the buttons drop their words before wrapping. */}
|
||||
<footer className={`${collapsed ? 'hidden' : 'flex'} flex-none flex-wrap items-center gap-2 border-t border-edge-faint px-4 py-2.5 [container-type:inline-size]`}>
|
||||
<footer className={`trek-desktop-panel trek-dialog-footer ${collapsed ? 'hidden' : 'flex'} flex-none flex-wrap items-center gap-2 border-t border-edge-faint bg-surface-card px-4 py-2.5 [container-type:inline-size]`}>
|
||||
{/* Collection mode — copy to trip + per-place status */}
|
||||
{mode === 'collection' && onCopyToTrip && (
|
||||
<DialogButton variant="primary" onClick={onCopyToTrip} icon={<Copy size={14} strokeWidth={2} />} aria-label={t('collections.copyToTrip')}>
|
||||
@@ -539,8 +549,8 @@ export default function PlaceInspector({
|
||||
? (onRemoveFromList && <DeleteButton onClick={onRemoveFromList} label={t('collections.removeFromList')} />)
|
||||
: (
|
||||
// The rare and the destructive behind one "…", so the row holds what is used.
|
||||
<MoreButton label={t('files.menu')} size={36} alwaysVisible
|
||||
className="!rounded-[10px] bg-surface-card !text-content shadow-sm ring-1 ring-edge-faint hover:!bg-surface-secondary"
|
||||
<MoreButton label={t('files.menu')} size={40} alwaysVisible
|
||||
className="bg-surface-card !text-content ring-1 ring-edge-faint hover:!bg-surface-secondary"
|
||||
items={[
|
||||
mode === 'trip' && !!selectedDayId && !bookedNight && assignmentInDay && {
|
||||
label: t('inspector.removeFromDay'), icon: Minus,
|
||||
@@ -570,64 +580,32 @@ function MarkdownBox({ children }: { children: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
interface PlaceBookingsAndPeopleProps {
|
||||
interface PlaceBookingsProps {
|
||||
selectedAssignmentId: number | null
|
||||
placeId: number
|
||||
reservations: Reservation[]
|
||||
assignments: AssignmentsMap
|
||||
selectedDayId: number | null
|
||||
tripMembers: TripMember[]
|
||||
timeFormat: string
|
||||
onSetParticipants?: (assignmentId: number, dayId: number, participantIds: number[]) => void
|
||||
onEditTransport?: (reservation: Reservation) => void
|
||||
onEditReservation?: (reservation: Reservation) => void
|
||||
onOpenBooking?: (reservation: Reservation) => void
|
||||
}
|
||||
|
||||
/** The bookings pinned to this stop and who joins it, side by side from sm up. */
|
||||
function PlaceBookingsAndPeople({ selectedAssignmentId, placeId, reservations, assignments, selectedDayId,
|
||||
tripMembers, timeFormat, onSetParticipants, onEditTransport, onEditReservation, onOpenBooking }: PlaceBookingsAndPeopleProps) {
|
||||
/** The bookings pinned to this stop. */
|
||||
function PlaceBookings({ selectedAssignmentId, placeId, reservations, timeFormat,
|
||||
onEditTransport, onEditReservation, onOpenBooking }: PlaceBookingsProps) {
|
||||
const { t } = useTranslation()
|
||||
const linked = getPlaceBookings<Reservation>(reservations, selectedAssignmentId, placeId)
|
||||
const assignment = selectedAssignmentId ? (assignments[String(selectedDayId)] || []).find(a => a.id === selectedAssignmentId) : null
|
||||
const currentParticipants = assignment?.participants || []
|
||||
const participantIds = currentParticipants.map(p => p.user_id)
|
||||
const allJoined = currentParticipants.length === 0
|
||||
const showParticipants = !!selectedAssignmentId && tripMembers.length > 1
|
||||
if (linked.length === 0 && !showParticipants) return null
|
||||
if (linked.length === 0) return null
|
||||
return (
|
||||
<div className={`grid flex-none items-start gap-3 ${linked.length > 0 && showParticipants ? 'grid-cols-1 sm:grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{/* Bookings pinned to this stop; several can share one (#2201) */}
|
||||
{linked.length > 0 && (
|
||||
<DialogSection label={t('reservations.title')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{linked.map(res => {
|
||||
// The strip summarised the booking but went nowhere, so its
|
||||
// attachments and fields had no route from the map (#2012).
|
||||
// A transport has its own form; picking by type is what the day
|
||||
// sidebar does, and an absent handler means this user may not
|
||||
// open this one, so the strip stays inert rather than lying.
|
||||
// With a detail to show, the card is the booking itself and opens it;
|
||||
// the editor is one Edit further, under the same rights as before.
|
||||
if (onOpenBooking) return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={() => onOpenBooking(res)} opens="detail" />
|
||||
const editor = TRANSPORT_TYPES.has(res.type) ? onEditTransport : onEditReservation
|
||||
return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={editor ? () => editor(res) : undefined} />
|
||||
})}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
{showParticipants && (
|
||||
<ParticipantsBox
|
||||
tripMembers={tripMembers}
|
||||
participantIds={participantIds}
|
||||
allJoined={allJoined}
|
||||
onSetParticipants={onSetParticipants}
|
||||
selectedAssignmentId={selectedAssignmentId}
|
||||
selectedDayId={selectedDayId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<DialogSection icon={Ticket} className="flex-none" label={t('reservations.title')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{linked.map(res => {
|
||||
if (onOpenBooking) return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={() => onOpenBooking(res)} opens="detail" />
|
||||
const editor = TRANSPORT_TYPES.has(res.type) ? onEditTransport : onEditReservation
|
||||
return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={editor ? () => editor(res) : undefined} />
|
||||
})}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -687,7 +665,7 @@ function ParticipantsBox({ tripMembers, participantIds, allJoined, onSetParticip
|
||||
}
|
||||
|
||||
return (
|
||||
<DialogSection label={t('inspector.participants')}>
|
||||
<DialogSection icon={Users} label={t('inspector.participants')}>
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{activeMembers.map(member => (
|
||||
<button type="button" key={member.id} disabled={!canRemove}
|
||||
@@ -736,7 +714,7 @@ function TrackColorRow({ place, trackColor, onUpdatePlace }: { place: Place; tra
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<DialogSection className="flex-none" label={t('inspector.trackColor')}>
|
||||
<DialogSection icon={Palette} className="flex-none" label={t('inspector.trackColor')}>
|
||||
<div className={BOX}>
|
||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open}
|
||||
className="flex w-full items-center gap-2 rounded-[10px] px-3 py-2 text-start transition-colors hover:bg-surface-hover">
|
||||
@@ -829,7 +807,7 @@ function TrackStatsSection({ place, trackColor, distanceUnit }: { place: Place;
|
||||
const stats = computeTrackStats(place.route_geometry)
|
||||
if (!stats) return null
|
||||
return (
|
||||
<DialogSection className="flex-none" label={t('inspector.trackStats')}>
|
||||
<DialogSection icon={ChartBar} className="flex-none" label={t('inspector.trackStats')}>
|
||||
<div className={`${BOX} flex flex-col gap-2 px-3 py-2.5`}>
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
<SoftPill icon={<MapPin size={11} strokeWidth={2} className="flex-none" style={{ color: trackColor }} />}>
|
||||
@@ -877,22 +855,22 @@ interface PlaceExtrasProps {
|
||||
isUploading: boolean
|
||||
distanceUnit: DistanceUnit
|
||||
onUpdatePlace?: (placeId: number, data: Partial<Place>) => void
|
||||
visits: React.ReactNode
|
||||
}
|
||||
|
||||
/** Opening hours, the track of a GPX place and the files, side by side from sm up when there are hours. */
|
||||
/** Opening hours, track details, attached files and visit history. */
|
||||
function PlaceExtras({ openingHours, weekdayIndex, hoursExpanded, setHoursExpanded, timeFormat, place,
|
||||
placeFiles, onFileUpload, filesExpanded, setFilesExpanded, fileInputRef, handleFileUpload, isUploading, distanceUnit,
|
||||
onUpdatePlace }: PlaceExtrasProps) {
|
||||
onUpdatePlace, visits }: PlaceExtrasProps) {
|
||||
const { t } = useTranslation()
|
||||
const openFile = useOpenFile()
|
||||
const hasHours = !!openingHours && openingHours.length > 0
|
||||
const showFiles = placeFiles.length > 0 || !!onFileUpload
|
||||
if (!hasHours && !place.route_geometry && !showFiles) return null
|
||||
const trackColor = resolveTrackColor(place)
|
||||
return (
|
||||
<div className={`grid flex-none grid-cols-1 items-start gap-3 ${hasHours ? 'sm:grid-cols-2' : ''}`}>
|
||||
<div className={place.route_geometry ? 'grid flex-none gap-3' : `${DETAIL_GRID} items-start empty:hidden`}>
|
||||
{hasHours && (
|
||||
<DialogSection label={t('inspector.openingHours')}>
|
||||
<DialogSection icon={Clock} label={t('inspector.openingHours')}>
|
||||
<div className={`${BOX} relative`}>
|
||||
{hoursExpanded ? (
|
||||
<>
|
||||
@@ -928,12 +906,13 @@ function PlaceExtras({ openingHours, weekdayIndex, hoursExpanded, setHoursExpand
|
||||
{place.route_geometry && <TrackStatsSection place={place} trackColor={trackColor} distanceUnit={distanceUnit} />}
|
||||
|
||||
{showFiles && (
|
||||
<DialogSection
|
||||
<DialogSection icon={Paperclip}
|
||||
label={t('inspector.files')}
|
||||
action={onFileUpload && (
|
||||
<label className="inline-flex cursor-pointer items-center gap-1 rounded-full bg-surface-card px-2 py-[2px] font-geist font-semibold text-content-muted shadow-sm transition-colors focus-within:ring-2 focus-within:ring-accent hover:text-content" style={fs(10.5)}>
|
||||
<label className="inline-flex min-h-8 cursor-pointer items-center gap-1.5 rounded-full bg-accent px-3 font-semibold text-accent-text transition-colors focus-within:ring-2 focus-within:ring-accent focus-within:ring-offset-2 hover:bg-accent-hover" style={fs(12, 'body')}>
|
||||
<input ref={fileInputRef} type="file" multiple className="sr-only" onChange={handleFileUpload} />
|
||||
{isUploading ? <span aria-live="polite">…</span> : <><Upload size={11} strokeWidth={2} />{t('common.upload')}</>}
|
||||
<Upload size={14} strokeWidth={2} aria-hidden />
|
||||
<span aria-live="polite">{t(isUploading ? 'files.uploading' : 'common.upload')}</span>
|
||||
</label>
|
||||
)}
|
||||
>
|
||||
@@ -942,7 +921,7 @@ function PlaceExtras({ openingHours, weekdayIndex, hoursExpanded, setHoursExpand
|
||||
disabled={!placeFiles.length} className="group flex w-full items-center gap-2 rounded-[10px] px-3 py-2 text-start transition-colors enabled:hover:bg-surface-hover">
|
||||
<FileText size={13} strokeWidth={2} className="flex-none text-content-faint" />
|
||||
<span className="min-w-0 flex-1 truncate font-medium text-content-secondary" style={fs(12, 'body')}>
|
||||
{placeFiles.length > 0 ? t('inspector.filesCount', { count: placeFiles.length }) : t('inspector.files')}
|
||||
{placeFiles.length > 0 ? t('inspector.filesCount', { count: placeFiles.length }) : t('files.empty')}
|
||||
</span>
|
||||
{filesExpanded ? <ChevronUp size={13} className="flex-none text-content-faint group-disabled:hidden" /> : <ChevronDown size={13} className="flex-none text-content-faint group-disabled:hidden" />}
|
||||
</button>
|
||||
@@ -963,6 +942,7 @@ function PlaceExtras({ openingHours, weekdayIndex, hoursExpanded, setHoursExpand
|
||||
</div>
|
||||
</DialogSection>
|
||||
)}
|
||||
{visits}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import CustomSelect from '../shared/CustomSelect'
|
||||
import { BookingCodeInput } from '../shared/BookingCode'
|
||||
import { buildAssignmentOptions } from './assignmentOptions'
|
||||
import AddressInput from './AddressInput'
|
||||
import { Link2 } from 'lucide-react'
|
||||
import { Bed, CalendarClock, Link2, MapPin, Ticket } from 'lucide-react'
|
||||
import { useToast } from '../shared/Toast'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { CustomDatePicker } from '../shared/CustomDateTimePicker'
|
||||
@@ -21,7 +21,7 @@ import type { BookingReviewDraft } from './parsedItemToDraft'
|
||||
import { stayPlaces } from '../../utils/stayPlaces'
|
||||
import { BookingDialogHeader, StatusPill } from './bookings/BookingDialogShell'
|
||||
import { DialogShell, DialogFooter, FooterSpacer, DialogButton } from '../shared/DialogShell'
|
||||
import { INPUT, GRID_2, GRID_3, EditorField, PillSelect } from '../shared/dialogParts'
|
||||
import { INPUT, GRID_2, GRID_3, CardHead, EditorField, PANEL, PillSelect } from '../shared/dialogParts'
|
||||
import { typeInfo } from './bookings/bookingsModel'
|
||||
import type { StatusTone } from './bookings/bookingParts'
|
||||
import { RESERVATION_TYPE_OPTIONS as TYPE_OPTIONS, reservationFieldsFrom, reservationFieldsFromPrefill, selectedDayDate } from './reservationFormModel'
|
||||
@@ -239,7 +239,8 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
||||
>
|
||||
{/* When: the plan stop it belongs to, then start and end (hidden for hotels) */}
|
||||
{form.type !== 'hotel' && (
|
||||
<div className="flex flex-col gap-3">
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<CalendarClock size={16} />} title={t('reservations.datetime')} />
|
||||
{assignmentOptions.length > 0 && (
|
||||
<EditorField label={<><Link2 size={10} className="me-[3px] inline align-[-1px]" />{t('reservations.linkAssignment')}</>}>
|
||||
<CustomSelect
|
||||
@@ -289,36 +290,40 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
||||
<CustomTimePicker value={form.reservation_end_time} onChange={v => set('reservation_end_time', v)} />
|
||||
</EditorField>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Where: a trip place/activity (#1353) and the address. Hotels pick their
|
||||
place through the accommodation below. */}
|
||||
{form.type !== 'hotel' && (
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('reservations.meta.linkPlace')}>
|
||||
<CustomSelect
|
||||
value={form.place_id}
|
||||
onChange={pickPlace}
|
||||
placeholder={t('reservations.meta.pickPlace')}
|
||||
options={[
|
||||
{ value: '', label: '—' },
|
||||
...places.map(p => ({ value: p.id, label: p.name })),
|
||||
]}
|
||||
searchable
|
||||
size="sm"
|
||||
/>
|
||||
</EditorField>
|
||||
<EditorField label={t('reservations.locationAddress')}>
|
||||
<AddressInput value={form.location} onChange={v => set('location', v)}
|
||||
placeholder={t('reservations.locationPlaceholder')} className={INPUT} />
|
||||
</EditorField>
|
||||
</div>
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<MapPin size={16} />} title={t('reservations.place')} />
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('reservations.meta.linkPlace')}>
|
||||
<CustomSelect
|
||||
value={form.place_id}
|
||||
onChange={pickPlace}
|
||||
placeholder={t('reservations.meta.pickPlace')}
|
||||
options={[
|
||||
{ value: '', label: '—' },
|
||||
...places.map(p => ({ value: p.id, label: p.name })),
|
||||
]}
|
||||
searchable
|
||||
size="sm"
|
||||
/>
|
||||
</EditorField>
|
||||
<EditorField label={t('reservations.locationAddress')}>
|
||||
<AddressInput value={form.location} onChange={v => set('location', v)}
|
||||
placeholder={t('reservations.locationPlaceholder')} className={INPUT} />
|
||||
</EditorField>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* The stay: place and nights, then the check-in window */}
|
||||
{form.type === 'hotel' && (
|
||||
<>
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Bed size={16} />} title={t('reservations.type.hotel')} />
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className={GRID_3}>
|
||||
<EditorField label={t('reservations.meta.hotelPlace')}>
|
||||
@@ -375,19 +380,22 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
|
||||
hidden={!!form.hotel_place_id}
|
||||
onRetry={() => stayPin.lookUp(form.title, form.hotel_address)}
|
||||
/>
|
||||
</>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* The booking code, and the trip members and guests on this booking (#1517) */}
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('reservations.confirmationCode')}>
|
||||
<BookingCodeInput value={form.confirmation_number} onChange={e => set('confirmation_number', e.target.value)}
|
||||
placeholder={t('reservations.confirmationPlaceholder')} className={INPUT} />
|
||||
</EditorField>
|
||||
<EditorField label={t('reservations.travelers.label')}>
|
||||
<TravelerPicker tripMembers={tripMembers} selectedIds={travelerIds} onToggle={toggleTraveler} />
|
||||
</EditorField>
|
||||
</div>
|
||||
<section className={PANEL}>
|
||||
<CardHead icon={<Ticket size={16} />} title={t('reservations.title')} />
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('reservations.confirmationCode')}>
|
||||
<BookingCodeInput value={form.confirmation_number} onChange={e => set('confirmation_number', e.target.value)}
|
||||
placeholder={t('reservations.confirmationPlaceholder')} className={INPUT} />
|
||||
</EditorField>
|
||||
<EditorField label={t('reservations.travelers.label')}>
|
||||
<TravelerPicker tripMembers={tripMembers} selectedIds={travelerIds} onToggle={toggleTraveler} />
|
||||
</EditorField>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<BookingNotesFilesCosts
|
||||
form={form}
|
||||
|
||||
@@ -146,7 +146,7 @@ export default function ReservationsPanel({
|
||||
closeDetail()
|
||||
onEdit(r)
|
||||
}
|
||||
const { toggleStatus, requestDelete } = actions
|
||||
const { requestDelete } = actions
|
||||
|
||||
const importAction = onImport && bookingImportAvailable ? onImport : undefined
|
||||
const airTrailAction = onAirTrailImport && airTrailAvailable ? onAirTrailImport : undefined
|
||||
@@ -231,7 +231,6 @@ export default function ReservationsPanel({
|
||||
onSelect={select}
|
||||
onEdit={edit}
|
||||
onDelete={requestDelete}
|
||||
onToggleStatus={toggleStatus}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -241,7 +240,7 @@ export default function ReservationsPanel({
|
||||
const open = !v.collapsed(g.id)
|
||||
return (
|
||||
<div key={g.id}>
|
||||
{g.label && <SectionHead label={g.label} sub={g.sub} count={g.items.length} open={open} onToggle={() => v.toggleGroup(g.id)} />}
|
||||
{g.label && <SectionHead group={g} open={open} onToggle={() => v.toggleGroup(g.id)} />}
|
||||
{open && (
|
||||
<div className={CARD_GRID}>
|
||||
{g.items.map(r => (
|
||||
@@ -257,7 +256,6 @@ export default function ReservationsPanel({
|
||||
onSelect={() => select(r)}
|
||||
onEdit={() => edit(r)}
|
||||
onDelete={() => requestDelete(r)}
|
||||
onToggleStatus={() => toggleStatus(r)}
|
||||
contributions={contribFor(r.id)}
|
||||
detailPlugins={detailPlugins}
|
||||
showFrames={v.selectedId !== r.id}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import { CalendarDays, Clock, Pencil, RefreshCw } from 'lucide-react'
|
||||
import { Route, NotebookPen, CalendarDays, Clock, Pencil, RefreshCw } from 'lucide-react'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import { DialogShell, DialogSection, DialogFooter, FooterSpacer, DialogButton, DeleteButton, PILL, fs } from '../shared/DialogShell'
|
||||
import { Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||
@@ -135,11 +135,11 @@ export default function TransitJourneyModal({ reservation, onClose, onSave, onDe
|
||||
</div>
|
||||
)}
|
||||
{legs.length > 0 && (
|
||||
<DialogSection label={t('transit.itinerary')}>
|
||||
<DialogSection icon={Route} label={t('transit.itinerary')}>
|
||||
<TransitLegs legs={legs} />
|
||||
</DialogSection>
|
||||
)}
|
||||
<DialogSection label={t('reservations.notes')} action={noteTools}>
|
||||
<DialogSection icon={NotebookPen} label={t('reservations.notes')} action={noteTools}>
|
||||
{canEdit && notesTab === 'write' ? (
|
||||
<textarea
|
||||
ref={notesRef}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useRef, useMemo, type ReactNode } from 'react'
|
||||
import { useParams } from 'react-router'
|
||||
import { X, Trash2, ChevronUp, ChevronDown, CalendarDays } from 'lucide-react'
|
||||
import { Route, Users, X, Trash2, ChevronUp, ChevronDown, CalendarDays, Ticket } from 'lucide-react'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import CustomSelect from '../shared/CustomSelect'
|
||||
import { BookingCodeInput } from '../shared/BookingCode'
|
||||
@@ -15,6 +15,7 @@ import { useTripStore } from '../../store/tripStore'
|
||||
import { useTripAddonEnabled } from '../../store/tripAddonsStore'
|
||||
import type { Day, Place, Accommodation, Reservation, TripFile, AssignmentsMap } from '../../types'
|
||||
import { BookingNotesFilesCosts } from './BookingNotesFilesCosts'
|
||||
import { AddRouteStop } from './AddRouteStop'
|
||||
import { TravelerPicker } from './TravelerPicker'
|
||||
import type { TripMember } from '../Budget/BudgetPanelMemberChips'
|
||||
import type { BookingExpenseRequest } from './BookingCostsSection.types'
|
||||
@@ -24,7 +25,7 @@ import { getTransitDayPlaces } from './transitDayPlaces'
|
||||
import type { TransitPrefill } from './transitLeg'
|
||||
import { BookingDialogHeader, StatusPill } from './bookings/BookingDialogShell'
|
||||
import { DialogShell, DialogSection, DialogFooter, FooterSpacer, DialogButton, DeleteButton } from '../shared/DialogShell'
|
||||
import { INPUT, READONLY_BOX, GRID_2, GRID_3, PANEL, SEARCH_ON_PANEL, EditorField, Segmented, PillSelect, AddRowButton } from '../shared/dialogParts'
|
||||
import { INPUT, READONLY_BOX, GRID_2, GRID_3, PANEL, SEARCH_ON_PANEL, EditorField, Segmented, PillSelect } from '../shared/dialogParts'
|
||||
import { fs, Eyebrow, type StatusTone } from './bookings/bookingParts'
|
||||
import { deleteBodyKey, typeInfo } from './bookings/bookingsModel'
|
||||
import {
|
||||
@@ -313,7 +314,7 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
|
||||
// Flight route: ordered airports (origin, stops, destination) on one rail.
|
||||
const flightRoute = () => (
|
||||
<DialogSection key="flight" label={t('reservations.layover.route')}>
|
||||
<DialogSection icon={Route} key="flight" label={t('reservations.layover.route')}>
|
||||
<ol>
|
||||
{waypoints.map((wp, i) => {
|
||||
const isFirst = i === 0
|
||||
@@ -363,9 +364,10 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
</div>
|
||||
{!isLast && (
|
||||
<div className="py-2.5">
|
||||
<AddRowButton onClick={() => setWaypoints(prev => [...prev.slice(0, i + 1), emptyWaypoint(prev[i]?.depDayId || ''), ...prev.slice(i + 1)])}>
|
||||
{t('reservations.layover.addStop')}
|
||||
</AddRowButton>
|
||||
<AddRouteStop
|
||||
label={t('reservations.layover.addStop')}
|
||||
onClick={() => setWaypoints(prev => [...prev.slice(0, i + 1), emptyWaypoint(prev[i]?.depDayId || ''), ...prev.slice(i + 1)])}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</RailStop>
|
||||
@@ -377,7 +379,7 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
|
||||
// Train route: ordered stations on the same rail, per-leg train fields.
|
||||
const trainRoute = () => (
|
||||
<DialogSection key="train" label={t('reservations.layover.route')}>
|
||||
<DialogSection icon={Route} key="train" label={t('reservations.layover.route')}>
|
||||
<ol>
|
||||
{trainWaypoints.map((wp, i) => {
|
||||
const isFirst = i === 0
|
||||
@@ -426,9 +428,10 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
</div>
|
||||
{!isLast && (
|
||||
<div className="py-2.5">
|
||||
<AddRowButton onClick={() => setTrainWaypoints(prev => [...prev.slice(0, i + 1), emptyStationWaypoint(prev[i]?.depDayId || ''), ...prev.slice(i + 1)])}>
|
||||
{t(form.type === 'cruise' ? 'reservations.cruise.addPort' : 'reservations.layover.addStop')}
|
||||
</AddRowButton>
|
||||
<AddRouteStop
|
||||
label={t(form.type === 'cruise' ? 'reservations.cruise.addPort' : 'reservations.layover.addStop')}
|
||||
onClick={() => setTrainWaypoints(prev => [...prev.slice(0, i + 1), emptyStationWaypoint(prev[i]?.depDayId || ''), ...prev.slice(i + 1)])}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</RailStop>
|
||||
@@ -440,7 +443,7 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
|
||||
// Every other type: one From and one To, the day and time rows under them.
|
||||
const plainRoute = () => (
|
||||
<DialogSection key="plain" label={t('reservations.layover.route')}>
|
||||
<DialogSection icon={Route} key="plain" label={t('reservations.layover.route')}>
|
||||
<div className={PANEL}>
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('reservations.meta.from')}>
|
||||
@@ -493,7 +496,10 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
</IconAction>
|
||||
</div>
|
||||
))}
|
||||
<AddRowButton onClick={() => setCarStops(prev => [...prev, emptyCarStop()])}>{t('reservations.layover.addStop')}</AddRowButton>
|
||||
<AddRouteStop
|
||||
label={t('reservations.layover.addStop')}
|
||||
onClick={() => setCarStops(prev => [...prev, emptyCarStop()])}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@@ -530,16 +536,17 @@ export function TransportModal({ isOpen, onClose, onSave, reservation, days, sel
|
||||
) : (
|
||||
<>
|
||||
{/* Travelers: trip members and guests on this booking (#1517) */}
|
||||
<DialogSection label={t('reservations.travelers.label')}>
|
||||
<DialogSection icon={Users} label={t('reservations.travelers.label')}>
|
||||
<TravelerPicker tripMembers={tripMembers} selectedIds={travelerIds} onToggle={toggleTraveler} />
|
||||
</DialogSection>
|
||||
|
||||
{form.type === 'flight' ? flightRoute() : stationRoute ? trainRoute() : plainRoute()}
|
||||
|
||||
<EditorField label={t('reservations.confirmationCode')}>
|
||||
<BookingCodeInput value={form.confirmation_number} onChange={e => set('confirmation_number', e.target.value)}
|
||||
<DialogSection icon={Ticket} label={<label htmlFor={`${titleId}-booking-code`}>{t('reservations.confirmationCode')}</label>}>
|
||||
<BookingCodeInput id={`${titleId}-booking-code`} value={form.confirmation_number}
|
||||
onChange={e => set('confirmation_number', e.target.value)}
|
||||
placeholder={t('reservations.confirmationPlaceholder')} className={INPUT} />
|
||||
</EditorField>
|
||||
</DialogSection>
|
||||
|
||||
<BookingNotesFilesCosts
|
||||
form={form}
|
||||
|
||||
@@ -86,7 +86,6 @@ describe('TripExportModal', () => {
|
||||
it('FE-PLANNER-EXPORTMODAL-002: open, every export sits in its own section', () => {
|
||||
render(<TripExportModal {...makeProps()} />)
|
||||
expect(screen.getByRole('dialog', { name: 'dayplan.export' })).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportIntro')).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportDocument')).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportCalendar')).toBeInTheDocument()
|
||||
// The format stands beside the plain-language heading as a pill, not behind a "·".
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, useState } from 'react'
|
||||
import { CalendarDays, CalendarPlus, ChevronRight, Download, FileText, Loader2, MapPin, MapPinned, Route as RouteIcon, UserRound } from 'lucide-react'
|
||||
import { Map, CalendarDays, CalendarPlus, ChevronRight, Download, FileText, Loader2, MapPin, MapPinned, Route as RouteIcon, UserRound } from 'lucide-react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import { DialogHeader, DialogSection, DialogShell, DialogTile, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { IcsSubscribeModal } from './IcsSubscribeModal'
|
||||
@@ -87,8 +87,6 @@ export function TripExportModal({
|
||||
labelId={titleId}
|
||||
onClose={onClose}
|
||||
title={t('dayplan.export')}
|
||||
sub={t('dayplan.exportIntro')}
|
||||
subWraps
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -97,7 +95,7 @@ export function TripExportModal({
|
||||
{/* While the subscription dialog sits on top, Escape and the backdrop are
|
||||
its own: one key press closes only the dialog in front. */}
|
||||
<DialogShell open={isOpen} onClose={onClose} labelledBy={titleId} width="narrow" blocked={subscribeOpen} header={header}>
|
||||
<DialogSection label={t('dayplan.exportDocument')}>
|
||||
<DialogSection icon={FileText} label={t('dayplan.exportDocument')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<ExportRow
|
||||
icon={FileText}
|
||||
@@ -130,7 +128,7 @@ export function TripExportModal({
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={t('dayplan.exportCalendar')}>
|
||||
<DialogSection icon={CalendarDays} label={t('dayplan.exportCalendar')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<ExportRow
|
||||
icon={CalendarDays}
|
||||
@@ -155,7 +153,7 @@ export function TripExportModal({
|
||||
{/* GPX: the counterpart to the GPX import in the places sidebar. The
|
||||
format name carries more than a translated heading would, so it
|
||||
stands beside the plain-language one as a pill of its own. */}
|
||||
<DialogSection label={<span className="inline-flex items-center gap-1.5">{t('dayplan.exportMaps')}<SoftPill caps>GPX</SoftPill></span>}>
|
||||
<DialogSection icon={Map} label={<span className="inline-flex items-center gap-1.5">{t('dayplan.exportMaps')}<SoftPill caps>GPX</SoftPill></span>}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{GPX_SCOPES.map(scope => (
|
||||
<ExportRow
|
||||
@@ -172,7 +170,7 @@ export function TripExportModal({
|
||||
|
||||
{/* Google Maps keeps no list from outside, but My Maps takes the places
|
||||
as a KML layer (#1866); the format pill as for GPX above. */}
|
||||
<DialogSection label={<span className="inline-flex items-center gap-1.5">{t('dayplan.exportGoogleMaps')}<SoftPill caps>KML</SoftPill></span>}>
|
||||
<DialogSection icon={Map} label={<span className="inline-flex items-center gap-1.5">{t('dayplan.exportGoogleMaps')}<SoftPill caps>KML</SoftPill></span>}>
|
||||
<ExportRow
|
||||
icon={MapPinned}
|
||||
title={t('dayplan.kmlPlaces')}
|
||||
@@ -211,7 +209,7 @@ function ExportRow({ icon: Icon, title, sub, busy = false, disabled = false, onC
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
className="group flex w-full items-center gap-3 rounded-[14px] border border-edge-faint bg-surface-card px-3 py-2.5 text-start transition-colors enabled:hover:bg-surface-hover disabled:cursor-default disabled:opacity-50"
|
||||
className="group flex w-full items-center gap-3 rounded-[14px] border border-edge-faint bg-surface-input px-3 py-2.5 text-start transition-colors enabled:hover:bg-surface-hover disabled:cursor-default disabled:opacity-50"
|
||||
>
|
||||
<span className="grid h-9 w-9 flex-none place-items-center rounded-[10px] bg-surface-tertiary text-content-secondary transition-colors group-enabled:group-hover:bg-surface-card group-enabled:group-hover:text-content">
|
||||
{busy ? <Loader2 size={16} strokeWidth={2} className="animate-spin" /> : <Icon size={16} strokeWidth={1.9} />}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { formatMoney } from '../../../utils/formatters'
|
||||
import { parseMeta, displayTitle, type CostTotal } from './bookingsModel'
|
||||
import type { BookingFacts } from './bookingFacts'
|
||||
import {
|
||||
AirTrailPill, BOX, Block, Field, FileRows, ReviewPill, RoundAction, RouteBox, StatusDot, TravelerChips, TypeChip, WhenFields,
|
||||
AirTrailPill, BOX, Block, BookingTypeMarker, Field, FileRows, ReviewPill, RoundAction, RouteBox, TravelerChips, WhenFields,
|
||||
fs, toneOf, toneTint,
|
||||
} from './bookingParts'
|
||||
import { TransitLegs, transitSummary } from './transitParts'
|
||||
@@ -32,7 +32,6 @@ export interface BookingCardProps {
|
||||
onSelect: () => void
|
||||
onEdit: () => void
|
||||
onDelete: () => void
|
||||
onToggleStatus: () => void
|
||||
contributions: ViewContribution[]
|
||||
detailPlugins: ActivePlugin[]
|
||||
/** False while the detail pane shows this booking, so its plugin frames are not mounted twice. */
|
||||
@@ -41,7 +40,7 @@ export interface BookingCardProps {
|
||||
|
||||
/**
|
||||
* One booking or transport as the phone draws it: a head band tinted by its
|
||||
* status with the status switch, the type and the title, then framed fields.
|
||||
* status with a category icon and title, then framed fields.
|
||||
* The desktop keeps every value the old card had, so nothing is behind a tap.
|
||||
*/
|
||||
export default function BookingCard(p: BookingCardProps) {
|
||||
@@ -58,8 +57,7 @@ export default function BookingCard(p: BookingCardProps) {
|
||||
>
|
||||
<div role="presentation" onClick={p.onSelect} className="flex flex-1 flex-col">
|
||||
<div className="flex items-center gap-2 border-b border-edge-faint px-3 py-2.5" style={{ background: toneTint(tone) }}>
|
||||
<StatusDot r={r} canToggle={p.canEdit} onToggle={p.onToggleStatus} />
|
||||
<TypeChip type={r.type} />
|
||||
<BookingTypeMarker booking={r} inHeader />
|
||||
<button type="button" aria-label={title} className="flex min-w-0 flex-1 items-center gap-1.5 rounded text-start focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--text-primary)]">
|
||||
<span className="min-w-0 truncate font-bold text-content" style={fs(13.5, 'body')}>{title}</span>
|
||||
{!!r.needs_review && <ReviewPill />}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { bookingSeats } from '../../../utils/flightLegs'
|
||||
import { TransitLegChips } from '../transitDisplay'
|
||||
import { displayTitle, parseMeta, type BookingGroup, type CostTotal } from './bookingsModel'
|
||||
import type { BookingFacts } from './bookingFacts'
|
||||
import { AirTrailPill, CountPill, EYEBROW, ReviewPill, RoundAction, StatusDot, TravelerStack, TypeTile, fs } from './bookingParts'
|
||||
import { AirTrailPill, BookingGroupHeading, BookingTypeMarker, ReviewPill, RoundAction, TravelerStack, fs } from './bookingParts'
|
||||
|
||||
export interface BookingsListProps {
|
||||
groups: BookingGroup[]
|
||||
@@ -22,7 +22,6 @@ export interface BookingsListProps {
|
||||
onSelect: (r: Reservation) => void
|
||||
onEdit: (r: Reservation) => void
|
||||
onDelete: (r: Reservation) => void
|
||||
onToggleStatus: (r: Reservation) => void
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,9 +52,7 @@ export default function BookingsList(p: BookingsListProps) {
|
||||
{g.label && (
|
||||
<button type="button" onClick={() => p.onToggleGroup(g.id)} onKeyDown={onNavigate} aria-expanded={open}
|
||||
className="flex w-full items-center gap-2 bg-surface-secondary px-3.5 py-2.5 text-start">
|
||||
<span className={EYEBROW} style={fs(10.5)}>{g.label}</span>
|
||||
{g.sub && <span className="truncate font-geist font-medium text-content-muted" style={fs(11.5)}>{g.sub}</span>}
|
||||
<CountPill>{g.items.length}</CountPill>
|
||||
<BookingGroupHeading group={g} open={open} />
|
||||
</button>
|
||||
)}
|
||||
{open && g.items.map(r => (
|
||||
@@ -98,10 +95,9 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
|
||||
if (e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); p.onSelect(r) }
|
||||
else onNavigate(e)
|
||||
}}
|
||||
className={`group relative grid cursor-pointer grid-cols-[22px_32px_minmax(0,1fr)_minmax(118px,auto)_auto] items-center gap-3 border-t border-edge-faint px-3.5 py-2.5 first:border-t-0 hover:bg-surface-hover focus-visible:outline-none focus-visible:bg-surface-hover ${selected ? 'bg-surface-hover shadow-[inset_3px_0_0_0_var(--text-primary)]' : ''}`}
|
||||
className={`group relative grid cursor-pointer grid-cols-[32px_minmax(0,1fr)_minmax(118px,auto)_auto] items-center gap-3 border-t border-edge-faint px-3.5 py-2.5 first:border-t-0 hover:bg-surface-hover focus-visible:outline-none focus-visible:bg-surface-hover ${selected ? 'bg-surface-hover shadow-[inset_3px_0_0_0_var(--text-primary)]' : ''}`}
|
||||
>
|
||||
<StatusDot r={r} canToggle={p.canEdit} onToggle={() => p.onToggleStatus(r)} />
|
||||
<TypeTile type={r.type} />
|
||||
<BookingTypeMarker booking={r} />
|
||||
<div className="min-w-0">
|
||||
<div className="flex min-w-0 items-center gap-1.5">
|
||||
<span className="truncate font-semibold text-content" style={fs(13.5, 'body')}>{displayTitle(r)}</span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { AlertCircle, ChevronDown, ChevronUp, Download, FileText, Mail, Plane } from 'lucide-react'
|
||||
import { AlertCircle, ArrowLeftRight, Check, ChevronDown, ChevronUp, Clock, Download, FileText, Mail, Plane } from 'lucide-react'
|
||||
import type { Reservation, TripFile } from '../../../types'
|
||||
import type { ReservationTraveler } from '@trek/shared'
|
||||
import { useTranslation } from '../../../i18n'
|
||||
@@ -8,7 +8,7 @@ import GuestBadge from '../../shared/GuestBadge'
|
||||
import { Tooltip } from '../../shared/Tooltip'
|
||||
import { PILL } from '../../shared/DialogShell'
|
||||
import { useToast } from '../../shared/Toast'
|
||||
import { parseMeta, typeInfo } from './bookingsModel'
|
||||
import { parseMeta, typeInfo, type BookingGroup } from './bookingsModel'
|
||||
import type { BookingFacts } from './bookingFacts'
|
||||
import { downloadAttachment, openAttachment } from './openAttachment'
|
||||
|
||||
@@ -106,46 +106,46 @@ export function CountPill({ children }: { children: ReactNode }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** A collapsible section head: the label, what the day is, the count, and the chevron on the right. */
|
||||
export function SectionHead({ label, sub, count, open, onToggle }: { label: string; sub?: string; count: number; open: boolean; onToggle: () => void }) {
|
||||
export function BookingGroupHeading({ group, open }: { group: BookingGroup; open: boolean }) {
|
||||
const { label, dayDate, dayTitle, items } = group
|
||||
const Chevron = open ? ChevronUp : ChevronDown
|
||||
return (
|
||||
<button type="button" onClick={onToggle} aria-expanded={open} className="mb-3 flex w-full items-center gap-2 px-0.5 text-start">
|
||||
<span className={EYEBROW} style={fs(11)}>{label}</span>
|
||||
{sub && <span className="truncate font-geist font-medium text-content-muted" style={fs(11.5)}>{sub}</span>}
|
||||
<CountPill>{count}</CountPill>
|
||||
{open
|
||||
? <ChevronUp size={14} strokeWidth={2} className="ms-auto flex-none text-content-faint" />
|
||||
: <ChevronDown size={14} strokeWidth={2} className="ms-auto flex-none text-content-faint" />}
|
||||
<>
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1">
|
||||
<span className="inline-flex min-h-6 max-w-full items-center gap-2 rounded-full border border-edge-faint bg-surface-input px-2.5 font-geist font-semibold text-content" style={fs(11)}>
|
||||
<span>{label}</span>
|
||||
{dayDate && <span className="border-s border-edge ps-2 font-medium text-content-muted">{dayDate}</span>}
|
||||
</span>
|
||||
{dayTitle && <span className="min-w-0 max-w-full truncate font-geist font-semibold text-content" dir="auto" style={fs(11.5)}>{dayTitle}</span>}
|
||||
</span>
|
||||
<span className="ms-auto flex flex-none items-center gap-2">
|
||||
<span className="inline-grid min-h-6 min-w-6 place-items-center rounded-full border border-edge-faint bg-surface-input px-1.5 font-geist font-semibold tabular-nums text-content-muted" style={fs(11)}>{items.length}</span>
|
||||
<Chevron size={14} strokeWidth={2} aria-hidden className="text-content-muted" />
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export function SectionHead({ group, open, onToggle }: { group: BookingGroup; open: boolean; onToggle: () => void }) {
|
||||
const StatusIcon = group.id === 'confirmed' ? Check : group.id === 'pending' ? Clock : group.id === 'transit' ? ArrowLeftRight : null
|
||||
const Chevron = open ? ChevronUp : ChevronDown
|
||||
return (
|
||||
<button type="button" onClick={onToggle} aria-expanded={open} className="mb-3 flex min-h-11 w-full items-center gap-2 rounded-xl border border-edge-faint bg-surface-secondary px-3 py-1.5 text-start transition-colors hover:bg-surface-hover">
|
||||
{StatusIcon ? (
|
||||
<>
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg bg-surface-input text-content-muted">
|
||||
<StatusIcon size={15} strokeWidth={2} aria-hidden="true" />
|
||||
</span>
|
||||
<span className="min-w-0 flex-1 truncate text-control font-semibold text-content">{group.label}</span>
|
||||
<span className="inline-grid size-6 shrink-0 place-items-center rounded-full bg-surface-input text-caption font-medium tabular-nums text-content-muted">{group.items.length}</span>
|
||||
<Chevron size={14} strokeWidth={2} aria-hidden className="shrink-0 text-content-muted" />
|
||||
</>
|
||||
) : <BookingGroupHeading group={group} open={open} />}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The status dot. With the right to edit bookings it is a switch between
|
||||
* confirmed and pending, as on the phone; a transit journey has no status and
|
||||
* shows its dot in the info colour.
|
||||
*/
|
||||
export function StatusDot({ r, canToggle, onToggle, size = 8 }: { r: Reservation; canToggle: boolean; onToggle: () => void; size?: number }) {
|
||||
const { t } = useTranslation()
|
||||
const tone = toneOf(r)
|
||||
const dot = <span className="block flex-none rounded-full" style={{ width: size, height: size, background: toneColor(tone) }} />
|
||||
if (!canToggle || tone === 'transit') return <span className="grid h-[22px] w-[22px] flex-none place-items-center">{dot}</span>
|
||||
const next = tone === 'confirmed' ? t('reservations.pending') : t('reservations.confirmed')
|
||||
const label = t('reservations.status.switchTo', { status: next })
|
||||
return (
|
||||
<Tooltip label={label}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={e => { e.stopPropagation(); onToggle() }}
|
||||
aria-label={label}
|
||||
className="grid h-[22px] w-[22px] flex-none place-items-center rounded-full hover:bg-surface-hover"
|
||||
>
|
||||
{dot}
|
||||
</button>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
/** Text label for the shared trip's booking cards. */
|
||||
export function TypeChip({ type }: { type: string }) {
|
||||
const { t } = useTranslation()
|
||||
const info = typeInfo(type)
|
||||
@@ -157,6 +157,21 @@ export function TypeChip({ type }: { type: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
export function BookingTypeMarker({ booking, inHeader = false }: { booking: Reservation; inHeader?: boolean }) {
|
||||
const { t } = useTranslation()
|
||||
const info = typeInfo(booking.type)
|
||||
const tone = toneOf(booking)
|
||||
const status = tone === 'transit' ? null : t(tone === 'confirmed' ? 'reservations.confirmed' : 'reservations.pending')
|
||||
const label = [t(info.chipKey), status].filter(Boolean).join(', ')
|
||||
return (
|
||||
<span role="img" aria-label={label} title={label}
|
||||
className="grid size-8 flex-none place-items-center rounded-full"
|
||||
style={{ background: inHeader ? 'var(--bg-input)' : toneTint(tone), color: info.color }}>
|
||||
<info.Icon size={16} strokeWidth={2} aria-hidden />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** The square tile with the type's icon, used by rows and the detail pane. */
|
||||
export function TypeTile({ type, size = 32, raised = false }: { type: string; size?: number; raised?: boolean }) {
|
||||
const info = typeInfo(type)
|
||||
|
||||
@@ -293,12 +293,12 @@ describe('groupReservations', () => {
|
||||
const after = buildReservation({ id: 7206, reservation_time: '2025-07-01T10:00' });
|
||||
const undated = buildReservation({ id: 7207 });
|
||||
const groups = groupReservations([undated, after, confirmed, pending, before], 'day', days, '2025-06-01', '2025-06-03', labels);
|
||||
expect(groups.map(g => [g.id, g.label, g.sub, g.items.map(r => r.id)])).toEqual([
|
||||
['before', 'Before the trip', undefined, [7205]],
|
||||
['day-501', 'Day 1', 'on 2025-06-01 Arrival', [7201]],
|
||||
['day-502', 'Day 2', 'on 2025-06-02', [7202]],
|
||||
['after', 'After the trip', undefined, [7206]],
|
||||
['undated', 'No date', undefined, [7207]],
|
||||
expect(groups.map(g => [g.id, g.label, g.dayDate, g.dayTitle, g.items.map(r => r.id)])).toEqual([
|
||||
['before', 'Before the trip', undefined, undefined, [7205]],
|
||||
['day-501', 'Day 1', 'on 2025-06-01', 'Arrival', [7201]],
|
||||
['day-502', 'Day 2', 'on 2025-06-02', undefined, [7202]],
|
||||
['after', 'After the trip', undefined, undefined, [7206]],
|
||||
['undated', 'No date', undefined, undefined, [7207]],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -306,16 +306,16 @@ describe('groupReservations', () => {
|
||||
const onDay = buildReservation({ id: 7208, reservation_time: '2025-06-03T08:00' });
|
||||
const offDays = buildReservation({ id: 7209, reservation_time: '2025-06-10T08:00' });
|
||||
const groups = groupReservations([onDay, offDays], 'day', days, null, null, labels);
|
||||
expect(groups.map(g => [g.id, g.label, g.sub])).toEqual([
|
||||
['day-503', 'Day 3', 'on 2025-06-03 Hike'],
|
||||
['date-2025-06-10', 'on 2025-06-10', undefined],
|
||||
expect(groups.map(g => [g.id, g.label, g.dayDate, g.dayTitle])).toEqual([
|
||||
['day-503', 'Day 3', 'on 2025-06-03', 'Hike'],
|
||||
['date-2025-06-10', 'on 2025-06-10', undefined, undefined],
|
||||
]);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-BKMODEL-036: a day without date or title has no second part', () => {
|
||||
const bare = buildDay({ id: 505, day_number: 5, date: null, title: null });
|
||||
const r = buildReservation({ id: 7210, day_id: 505, reservation_time: '2025-06-02T10:00' });
|
||||
expect(groupReservations([r], 'day', [bare], null, null, labels)[0]).toMatchObject({ id: 'day-505', label: 'Day 5', sub: undefined });
|
||||
expect(groupReservations([r], 'day', [bare], null, null, labels)[0]).toMatchObject({ id: 'day-505', label: 'Day 5', dayDate: undefined, dayTitle: undefined });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -306,8 +306,8 @@ function statusRank(r: Reservation, transitApart: boolean): number {
|
||||
export interface BookingGroup {
|
||||
id: string
|
||||
label: string
|
||||
/** A second part of the head, after a straight cut (a day's date and title). */
|
||||
sub?: string
|
||||
dayDate?: string
|
||||
dayTitle?: string
|
||||
items: Reservation[]
|
||||
}
|
||||
|
||||
@@ -361,7 +361,12 @@ export function groupReservations(sorted: Reservation[], by: GroupBy, days: Day[
|
||||
const day = start ?? (key ? days.find(d => d.date === key.slice(0, 10)) : undefined)
|
||||
if (phase === 'before') push('before', () => ({ id: 'before', label: L.before }), r)
|
||||
else if (phase === 'after') push('after', () => ({ id: 'after', label: L.after }), r)
|
||||
else if (day) push(`day-${day.id}`, () => ({ id: `day-${day.id}`, label: L.dayN(day.day_number), sub: [day.date ? L.dayDate(day.date) : null, day.title].filter(Boolean).join(' ') || undefined }), r)
|
||||
else if (day) push(`day-${day.id}`, () => ({
|
||||
id: `day-${day.id}`,
|
||||
label: L.dayN(day.day_number),
|
||||
dayDate: day.date ? L.dayDate(day.date) : undefined,
|
||||
dayTitle: day.title || undefined,
|
||||
}), r)
|
||||
else if (key) push(`date-${key.slice(0, 10)}`, () => ({ id: `date-${key.slice(0, 10)}`, label: L.dayDate(key.slice(0, 10)) }), r)
|
||||
else push('undated', () => ({ id: 'undated', label: L.undated }), r)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
import { CardHead } from '../shared/dialogParts'
|
||||
|
||||
/**
|
||||
* The pieces the two columns beside the place form share: the Place details
|
||||
@@ -12,20 +13,19 @@ import { fs } from '../shared/DialogShell'
|
||||
* The frame of a column. Its width is the caller's: the same sm:w-80 (320 px) on
|
||||
* both sides of the form, so neither column reads as the more important one.
|
||||
*/
|
||||
export const SIDE_COLUMN = 'flex w-full shrink-0 flex-col self-stretch overflow-hidden rounded-[14px] border border-edge-faint bg-surface-secondary'
|
||||
export const SIDE_COLUMN = 'flex max-h-[60vh] w-full shrink-0 flex-col self-start overflow-hidden rounded-[14px] border border-edge-faint bg-surface-secondary'
|
||||
|
||||
/** The eyebrow a column opens with, its icon on a small white disc. */
|
||||
export function ColumnHead({ icon, children }: { icon: ReactNode; children: ReactNode }) {
|
||||
/** Side columns use the same heading as the editor's other groups. */
|
||||
export function ColumnHead({ icon, children }: { icon: ReactNode; children: string }) {
|
||||
return (
|
||||
<div className="flex flex-none items-center gap-2 px-3.5 pb-2.5 pt-3">
|
||||
<span className="grid h-6 w-6 flex-none place-items-center rounded-full bg-surface-card text-content-muted shadow-sm">{icon}</span>
|
||||
<h3 className="m-0 min-w-0 truncate font-geist font-bold uppercase tracking-[.08em] text-content-muted" style={fs(10)}>{children}</h3>
|
||||
<div className="flex-none px-3 pb-3 pt-3">
|
||||
<CardHead icon={icon} title={children} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** A white card on the grey column, the frame every block of it sits in. */
|
||||
export const COLUMN_CARD = 'rounded-[12px] border border-edge-faint bg-surface-card'
|
||||
export const COLUMN_CARD = 'rounded-[12px] border border-edge-faint bg-surface-input'
|
||||
|
||||
/**
|
||||
* A quiet line in place of content: nothing picked yet, still loading, nothing
|
||||
@@ -42,4 +42,4 @@ export function HintCard({ icon, children }: { icon: ReactNode; children: ReactN
|
||||
}
|
||||
|
||||
/** A white action across the width of a column or a field, like the dialog's secondary buttons. */
|
||||
export const WHITE_BUTTON = 'flex w-full items-center justify-center gap-2 rounded-[10px] bg-surface-card px-3 py-2 font-semibold text-content shadow-sm ring-1 ring-edge-faint transition-colors hover:bg-surface-hover disabled:cursor-default disabled:opacity-50 disabled:hover:bg-surface-card'
|
||||
export const WHITE_BUTTON = 'trek-form-control flex w-full items-center justify-center gap-2 rounded-[10px] border border-edge bg-surface-input px-3 py-2 font-medium text-content transition-colors hover:bg-surface-hover disabled:cursor-default disabled:opacity-50'
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function DayWindowFields({ start, end, endMode = 'route', onSave
|
||||
<span className="text-body text-content-secondary">{t('roadtrip.window.endAt')}</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{(['route', 'stop'] as const).map(mode => (
|
||||
<label key={mode} className={`relative flex min-h-9 flex-1 cursor-pointer items-center rounded-lg border px-3 py-2 text-caption has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-accent ${endMode === mode ? 'border-accent bg-accent-subtle text-accent-on' : 'border-edge bg-surface-input text-content-secondary'}`}>
|
||||
<label key={mode} className={`relative flex min-h-9 flex-1 cursor-pointer items-center rounded-lg border px-3 py-2 text-caption has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-accent ${endMode === mode ? 'border-transparent bg-accent text-accent-text' : 'border-edge bg-surface-input text-content-secondary'}`}>
|
||||
<input type="radio" name="roadtrip-day-end-mode" value={mode} checked={endMode === mode} disabled={!onSave}
|
||||
onChange={() => onSave?.('roadtrip_day_end_mode', mode)}
|
||||
aria-describedby="roadtrip-end-mode-hint" className="sr-only" />
|
||||
|
||||
@@ -10,11 +10,11 @@ const classes = (el: Element | null): string[] => (el?.getAttribute('class') ??
|
||||
const of = (list: string): string[] => list.split(' ').sort()
|
||||
|
||||
describe('FigureBadge', () => {
|
||||
it('FE-FIGURE-BADGE-001: the neutral badge is the white pill of the day plan, the word and the figure split by a hairline', () => {
|
||||
it('FE-FIGURE-BADGE-001: the neutral badge separates its lead and figure with a hairline', () => {
|
||||
const { container } = render(<FigureBadge lead={<Footprints size={10} aria-hidden />} value="240 m" />)
|
||||
const pill = container.firstElementChild!
|
||||
expect(classes(pill)).toEqual(of(
|
||||
'inline-flex h-[20px] flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-card px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint',
|
||||
'inline-flex min-h-5 max-w-full flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-input px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint',
|
||||
))
|
||||
expect(classes(pill.children[0])).toEqual(of('flex min-w-0 items-center gap-1 text-content-faint'))
|
||||
expect(pill.children[1]).toHaveAttribute('aria-hidden')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
import { FS } from './typeScale'
|
||||
|
||||
/**
|
||||
* A fact on a stop's second line: what it is in the quiet ink (an icon or a word), then
|
||||
@@ -20,8 +21,8 @@ const TONES = {
|
||||
pending: { lead: 'text-warning', value: 'text-content-secondary' },
|
||||
} as const
|
||||
|
||||
// White with a light shadow and a hairline, so it still stands off the white card it sits on.
|
||||
const PILL = 'inline-flex h-[20px] flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-card px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint'
|
||||
// The soft surface and hairline keep the facts separate from the stop's title.
|
||||
const PILL = 'inline-flex min-h-6 max-w-full flex-none items-center gap-1 self-start whitespace-nowrap rounded-full bg-surface-input px-2 font-geist font-normal leading-none tabular-nums shadow-sm ring-1 ring-inset ring-edge-faint'
|
||||
|
||||
interface FigureBadgeProps {
|
||||
/** An icon, or a word (`caption`). */
|
||||
@@ -58,7 +59,7 @@ export default function FigureBadge({
|
||||
<>
|
||||
<span
|
||||
className={`flex min-w-0 items-center gap-1 ${value === undefined && (tone === 'neutral' || tone === 'warning') ? colours.value : colours.lead} ${caption ? 'uppercase tracking-[.05em]' : ''}`}
|
||||
style={caption ? fs(9.5) : undefined}
|
||||
style={caption ? fs(10.5) : undefined}
|
||||
>
|
||||
{lead}
|
||||
</span>
|
||||
@@ -85,12 +86,12 @@ export default function FigureBadge({
|
||||
onActivate(e.currentTarget)
|
||||
}}
|
||||
className={`${pill} cursor-pointer transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}
|
||||
style={fs(10.5)}
|
||||
style={{ fontSize: FS.time }}
|
||||
>
|
||||
{body}
|
||||
</span>
|
||||
) : (
|
||||
<span dir={dir} className={pill} style={fs(10.5)}>{body}</span>
|
||||
<span dir={dir} className={pill} style={{ fontSize: FS.time }}>{body}</span>
|
||||
)
|
||||
return tooltip ? <Tooltip label={tooltip}>{badge}</Tooltip> : badge
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId } from 'react'
|
||||
import { MoreHorizontal, Link2 } from 'lucide-react'
|
||||
import { CalendarDays, MoreHorizontal, Link2 } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import CustomSelect from '../shared/CustomSelect'
|
||||
@@ -50,7 +50,7 @@ export default function GoogleRouteImport({ tripId, dayId }: { tripId: number; d
|
||||
{!preview ? <input type="url" value={url} disabled={busy} onChange={e => setUrl(e.target.value)} aria-label="Google Maps URL" placeholder="https://maps.app.goo.gl/…"
|
||||
className="w-full rounded-[10px] border border-edge bg-surface-input px-3 py-2.5 text-content outline-none placeholder:text-content-faint focus:ring-2 focus:ring-[color:var(--text-primary)] disabled:opacity-50"
|
||||
style={fs(13, 'body')} /> : <>
|
||||
<DialogSection label={t('roadtrip.import.day')}>
|
||||
<DialogSection icon={CalendarDays} label={t('roadtrip.import.day')}>
|
||||
<CustomSelect value={target} onChange={value => pickDay(String(value))}
|
||||
options={days.map(day => ({ value: String(day.id), label: day.title || `${t('roadtrip.import.day')} ${day.day_number}` }))} disabled={busy || saved} />
|
||||
</DialogSection>
|
||||
|
||||
@@ -20,10 +20,7 @@ import { FS } from './typeScale'
|
||||
* Widths animate because this sits directly under the fields that feed it: typing a
|
||||
* consumption and watching the bar move is what makes the two ways of stating a range
|
||||
* visibly the same thing.
|
||||
*
|
||||
* No box, no border, no tinted panel. It used to sit in a card of its own, which made it
|
||||
* a second surface inside a dialog whose whole point is one plain column — and the box
|
||||
* was doing nothing the bar was not already doing better.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -98,7 +95,7 @@ export default function RangeStrip({ rangeKm, fillPercent, wearPercent, unit, el
|
||||
: t('roadtrip.limit.fullNote')
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 rounded-xl border border-edge-faint bg-surface-card px-3 py-2.5">
|
||||
<div className="flex flex-col gap-2 rounded-xl border border-edge-faint bg-surface-input px-3 py-2.5">
|
||||
{/* The figure and what it is a figure OF, on one baseline. Wrapping rather than
|
||||
truncating: "per charge" is three words in English and six in Hungarian. */}
|
||||
<div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5">
|
||||
@@ -120,7 +117,7 @@ export default function RangeStrip({ rangeKm, fillPercent, wearPercent, unit, el
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="h-2.5 w-full overflow-hidden rounded-full bg-surface"
|
||||
className="h-2.5 w-full overflow-hidden rounded-full bg-surface-tertiary"
|
||||
role="img"
|
||||
aria-label={shown === null ? note : `${shown} ${getDistanceUnitLabel(unit)} — ${note}`}
|
||||
>
|
||||
|
||||
@@ -46,7 +46,6 @@ export default function RoadtripCategoryPicker({ keys, meta, selected, onToggle
|
||||
aria-expanded={open}
|
||||
aria-haspopup="listbox"
|
||||
aria-label={picked.length ? `${t('roadtrip.poi.looking')}: ${names}` : undefined}
|
||||
style={{ fontSize: FS.control }}
|
||||
className={`${DROPDOWN_TRIGGER} w-full`}
|
||||
>
|
||||
{picked.length ? (
|
||||
@@ -63,6 +62,7 @@ export default function RoadtripCategoryPicker({ keys, meta, selected, onToggle
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
{picked.length === 1 && <span className="min-w-0 truncate font-medium text-content">{names}</span>}
|
||||
</span>
|
||||
) : (
|
||||
<span className="min-w-0 flex-1 truncate text-content-faint">{t('roadtrip.poi.looking')}</span>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import GoogleRouteImport from './GoogleRouteImport'
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import {
|
||||
Search, Plus, RotateCw, AlertTriangle, X, BedDouble, MapPin, ChevronDown,
|
||||
Search, Plus, RotateCw, AlertTriangle, X, BedDouble, MapPin, ChevronDown, Route,
|
||||
} from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
@@ -16,7 +16,7 @@ import { serviceColor } from './roadtripModel'
|
||||
import { alongLabel, offRouteLabel } from './corridorSearchModel'
|
||||
import { CORRIDOR_CATEGORY_BY_KEY, manualStopKindFor } from './stopKinds'
|
||||
import { FS } from './typeScale'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
import { Segmented } from '../shared/dialogParts'
|
||||
import { CORRIDOR_CATEGORY_KEYS, CORRIDOR_SECTION_KM, CORRIDOR_WIDTHS_KM, type RoadtripCorridor } from './useRoadtripCorridor'
|
||||
import type { RoadtripStopType } from '@trek/shared'
|
||||
import type { CorridorPoi } from './useCorridorPois'
|
||||
@@ -378,11 +378,14 @@ export default function RoadtripCorridorPanel({
|
||||
{/* Header: the panel's name. Pulled at, it is the first thing to go: it repeats
|
||||
what the column already is, and a heading that shortens to an ellipsis says less
|
||||
than no heading at all. */}
|
||||
<div className="flex flex-shrink-0 items-center gap-2.5 px-1">
|
||||
<div className="flex min-h-9 flex-shrink-0 items-center gap-2.5 px-1">
|
||||
{narrow ? null : (
|
||||
<h2 className="min-w-0 truncate font-semibold tracking-[-0.022em] text-content" style={{ fontSize: FS.panelTitle }}>
|
||||
{t('roadtrip.poi.title')}
|
||||
</h2>
|
||||
<>
|
||||
<span className="grid size-8 shrink-0 place-items-center rounded-[10px] bg-surface-secondary text-content-muted">
|
||||
<Route size={16} aria-hidden />
|
||||
</span>
|
||||
<h2 className="m-0 min-w-0 truncate text-body font-semibold text-content">{t('roadtrip.poi.title')}</h2>
|
||||
</>
|
||||
)}
|
||||
{tripId !== undefined && tripId > 0 && canImport && (
|
||||
<span className="ms-auto"><GoogleRouteImport tripId={tripId} dayId={corridor.day?.dayId} /></span>
|
||||
@@ -390,9 +393,12 @@ export default function RoadtripCorridorPanel({
|
||||
</div>
|
||||
|
||||
{/* What to look for. */}
|
||||
<div className={`flex flex-shrink-0 flex-col gap-3.5 ${CARD} px-4 pb-3.5 pt-3.5`}>
|
||||
<div className="flex flex-shrink-0 flex-col gap-3.5 rounded-2xl border border-edge-faint bg-surface-secondary p-3">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className={EYEBROW} style={{ fontSize: FS.label }}>{t('roadtrip.poi.looking')}</span>
|
||||
<span className="flex items-center gap-2 text-control font-semibold text-content">
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg bg-surface-input text-content-muted"><Search size={14} aria-hidden /></span>
|
||||
{t('roadtrip.poi.looking')}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<RoadtripCategoryPicker
|
||||
@@ -408,47 +414,18 @@ export default function RoadtripCorridorPanel({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span className="h-px bg-edge-faint" aria-hidden />
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className={EYEBROW} style={{ fontSize: FS.label }}>{t('roadtrip.poi.within')}</span>
|
||||
<div className="flex gap-1 rounded-xl bg-surface-tertiary p-1">
|
||||
{CORRIDOR_WIDTHS_KM.map(km => (
|
||||
<button
|
||||
key={km}
|
||||
type="button"
|
||||
aria-pressed={corridor.widthKm === km}
|
||||
onClick={() => corridor.setWidthKm(km)}
|
||||
style={{ fontSize: FS.control }}
|
||||
className={`flex h-[26px] flex-1 items-center justify-center rounded-lg tabular-nums transition-colors ${
|
||||
corridor.widthKm === km
|
||||
? 'bg-surface-card font-semibold text-content shadow-card'
|
||||
: 'font-medium text-content-muted hover:bg-surface-hover hover:text-content'
|
||||
}`}
|
||||
>
|
||||
{formatDistance(km, distanceUnit)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 [&>[role=group]]:bg-[color:var(--bg-selected)]">
|
||||
<span className="text-caption font-medium text-content">{t('roadtrip.poi.within')}</span>
|
||||
<Segmented
|
||||
label={t('roadtrip.poi.within')}
|
||||
value={String(corridor.widthKm)}
|
||||
onChange={value => corridor.setWidthKm(Number(value))}
|
||||
options={CORRIDOR_WIDTHS_KM.map(km => ({ value: String(km), label: formatDistance(km, distanceUnit) }))}
|
||||
fill
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* One word each, so both can be read at the size an action deserves. The panel
|
||||
they sit in is headed "along the route" and every control above them narrows
|
||||
the same search; repeating that on a button only made it small.
|
||||
|
||||
Their height is the controls' height, not a size of their own. At 38px the
|
||||
search stood a head above the segmented rows it follows and read as a second
|
||||
panel rather than as the end of this one.
|
||||
|
||||
Two halves of one row, because the search finds most of what is out there and
|
||||
not all of it: a good share of the chargers standing at a junction are in
|
||||
nobody's OpenStreetMap extract. The second button is the way to those, and it
|
||||
sits beside the search rather than under it so neither is the afterthought.
|
||||
|
||||
Below `ICON_ONLY_BELOW_PX` the two drop their labels rather than shortening
|
||||
them. A truncated word is worse than no word: "Add manu…" is neither the
|
||||
label nor a shape you recognise, while the plus and the magnifier are both
|
||||
read at a glance and keep their full names for a pointer and a reader. */}
|
||||
{/* Search and manual entry share a row. At narrow widths the icons keep their accessible names. */}
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@@ -458,8 +435,7 @@ export default function RoadtripCorridorPanel({
|
||||
disabled={!canSearch}
|
||||
aria-label={t('roadtrip.poi.search')}
|
||||
title={narrow ? t('roadtrip.poi.search') : undefined}
|
||||
className="flex h-8 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[10px] bg-accent px-3 font-semibold text-accent-text transition-opacity enabled:hover:opacity-90 disabled:opacity-50"
|
||||
style={fs(12, 'body')}
|
||||
className="flex h-9 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full bg-accent px-3 text-control font-semibold text-accent-text transition-opacity enabled:hover:opacity-90 disabled:opacity-50"
|
||||
>
|
||||
{search.loading
|
||||
? <RotateCw size={13} className="shrink-0 animate-spin" aria-hidden />
|
||||
@@ -483,8 +459,7 @@ export default function RoadtripCorridorPanel({
|
||||
// the button carries the one word that fits beside "Search".
|
||||
aria-label={t('roadtrip.poi.addManual')}
|
||||
title={t('roadtrip.poi.addManual')}
|
||||
className="flex h-8 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[10px] border border-edge bg-surface-card px-3 font-semibold text-content transition-colors hover:bg-surface-hover"
|
||||
style={fs(12, 'body')}
|
||||
className="flex h-9 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full border border-edge bg-surface-input px-3 text-control font-semibold text-content transition-colors hover:bg-surface-hover"
|
||||
>
|
||||
<Plus size={13} strokeWidth={2.2} className="shrink-0" aria-hidden />
|
||||
{narrow ? null : <span className="min-w-0 truncate">{t('roadtrip.poi.addManualShort')}</span>}
|
||||
|
||||
@@ -28,7 +28,6 @@ export default function RoadtripDayPicker({ days, value, onChange }: RoadtripDay
|
||||
onClick={() => setOpen(o => !o)}
|
||||
aria-expanded={open}
|
||||
aria-haspopup="listbox"
|
||||
style={{ fontSize: FS.control }}
|
||||
className={DROPDOWN_TRIGGER}
|
||||
>
|
||||
<span className="whitespace-nowrap font-medium text-content">
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Car, Zap, BatteryCharging, BatteryFull, BatteryWarning, Gauge, Route, Sparkles, Link2, Palette,
|
||||
} from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { CardHead, PANEL } from '../shared/dialogParts'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { convertDistance, formatDistance } from '../../utils/units'
|
||||
@@ -110,11 +111,11 @@ function LimitRow({ icon: Icon, label, suffix, value, placeholder, step, derived
|
||||
"min" does — and that column was the reason every section had a right edge of
|
||||
its own. In the flow it simply wraps under a long label and costs nothing. */}
|
||||
<span className="flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<span className="text-content-secondary" style={fs(12.5, 'body')}>{label}</span>
|
||||
<span className="text-body text-content">{label}</span>
|
||||
{/* The unit as a chip rather than as more grey words after the label. "kWh/100 km"
|
||||
set as prose reads as part of the question; on a chip it reads as what the
|
||||
number beside it will be measured in, which is what it is. */}
|
||||
<span className="inline-flex items-center rounded-full bg-surface-card px-2 py-[2px] font-geist leading-none text-content-muted shadow-sm ring-1 ring-inset ring-edge-faint" style={fs(10.5)}>
|
||||
<span className="inline-flex items-center rounded-full bg-surface-input px-2 py-[2px] font-geist leading-none text-content-muted shadow-sm ring-1 ring-inset ring-edge-faint" style={fs(10.5)}>
|
||||
{suffix}
|
||||
</span>
|
||||
</span>
|
||||
@@ -151,7 +152,7 @@ function LimitRow({ icon: Icon, label, suffix, value, placeholder, step, derived
|
||||
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); commit(); (e.target as HTMLInputElement).blur() } }}
|
||||
// The spinners are the other half of the width problem: they eat a third of a
|
||||
// narrow field and nobody sets a driving limit by clicking an arrow.
|
||||
className="w-full rounded-[10px] border border-edge bg-surface-input px-3 py-1.5 text-end tabular-nums text-content outline-none [appearance:textfield] placeholder:text-content-faint focus:ring-2 focus:ring-[color:var(--text-primary)] disabled:opacity-50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
||||
className="trek-form-control w-full rounded-[10px] border border-edge bg-surface-input px-3 py-1.5 text-end tabular-nums text-content outline-none [appearance:textfield] placeholder:text-content-faint focus:ring-2 focus:ring-[color:var(--text-primary)] disabled:opacity-50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
||||
style={fs(13, 'body')}
|
||||
/>
|
||||
)}
|
||||
@@ -181,10 +182,10 @@ function AvoidRow({ icon: Icon, label, hint, on, disabled, onToggle }: {
|
||||
}): React.ReactElement {
|
||||
const hintId = useId()
|
||||
return (
|
||||
<div className={`flex items-center gap-3 ${disabled ? 'opacity-50' : ''}`}>
|
||||
<div className={`flex min-h-10 items-center gap-3 rounded-[10px] bg-surface-input px-3 py-2 ${disabled ? 'opacity-50' : ''}`}>
|
||||
<Icon size={16} className="shrink-0 text-content-faint" aria-hidden />
|
||||
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||||
<span className="text-content-secondary" style={fs(12.5, 'body')}>{label}</span>
|
||||
<span className="text-body text-content">{label}</span>
|
||||
{hint ? <span id={hintId} className="text-caption leading-snug text-content-faint">{hint}</span> : null}
|
||||
</span>
|
||||
{disabled
|
||||
@@ -214,27 +215,14 @@ function Panel({ icon: Icon, title, note, children }: {
|
||||
children: React.ReactNode
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<section className="flex min-w-0 flex-col gap-3 rounded-[14px] border border-edge-faint bg-surface-secondary p-3.5">
|
||||
<SectionTitle icon={Icon}>{title}</SectionTitle>
|
||||
<section className={`${PANEL} min-w-0`}>
|
||||
<CardHead icon={<Icon size={16} aria-hidden />} title={title} />
|
||||
{children}
|
||||
{note ? <SettingsHint>{note}</SettingsHint> : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/** The name of one section, inside its panel. */
|
||||
function SectionTitle({ icon: Icon, children }: {
|
||||
icon: typeof Clock
|
||||
children: React.ReactNode
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<p className="m-0 flex items-center gap-1.5 font-geist font-bold uppercase tracking-[.08em] text-content-faint" style={fs(9.5)}>
|
||||
<Icon size={12} aria-hidden />
|
||||
{children}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
/** Not said, petrol, electric. "Not said" first, because it is what everybody starts on. */
|
||||
const VEHICLES: { key: VehicleKind | null; labelKey: string; Icon: typeof Car }[] = [
|
||||
{ key: null, labelKey: 'roadtrip.limit.vehicleAny', Icon: Car },
|
||||
@@ -417,13 +405,13 @@ export default function RoadtripLimitsCard({ onSave, onResetDayBoundaries, loadi
|
||||
onClick={() => setOpen(true)}
|
||||
disabled={loading}
|
||||
aria-busy={loading}
|
||||
className="flex w-full items-center gap-3 rounded-xl border border-edge-faint bg-surface-card px-3.5 py-3 text-start transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||
className="flex w-full items-center gap-2.5 rounded-2xl border border-edge-faint bg-surface-secondary p-3 text-start transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||
>
|
||||
{/* No icon tile on the trigger: the badges below already carry a clock, a
|
||||
calendar and a pump, and a fourth mark in front of the title only ate the width
|
||||
they need to sit on one line. */}
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-lg bg-surface-input text-content-muted">
|
||||
<SlidersHorizontal size={14} aria-hidden />
|
||||
</span>
|
||||
<span className="flex min-w-0 flex-1 flex-col gap-1">
|
||||
<span className="truncate text-body font-semibold text-content">
|
||||
<span className="truncate text-control font-semibold text-content">
|
||||
{loading ? t('common.loading') : t('roadtrip.limit.title')}
|
||||
</span>
|
||||
{badges.length ? (
|
||||
@@ -438,7 +426,7 @@ export default function RoadtripLimitsCard({ onSave, onResetDayBoundaries, loadi
|
||||
))}
|
||||
</span>
|
||||
) : (
|
||||
<span className="truncate text-content-faint" style={{ fontSize: FS.label }}>
|
||||
<span className="truncate text-caption text-content-muted">
|
||||
{t('roadtrip.limit.none')}
|
||||
</span>
|
||||
)}
|
||||
@@ -548,7 +536,7 @@ export default function RoadtripLimitsCard({ onSave, onResetDayBoundaries, loadi
|
||||
from the browser instead of from a rebuilt listbox. */}
|
||||
<fieldset className="min-w-0">
|
||||
<legend className="sr-only">{t('roadtrip.limit.vehicleLabel')}</legend>
|
||||
<div className="grid grid-cols-3 gap-0.5 rounded-[10px] bg-surface-tertiary p-[3px]">
|
||||
<div className="grid grid-cols-3 gap-0.5 rounded-[10px] bg-surface-input p-[3px]">
|
||||
{VEHICLES.map(({ key, labelKey, Icon }) => (
|
||||
<label key={key ?? 'unset'} className="min-w-0">
|
||||
<input
|
||||
@@ -567,7 +555,7 @@ export default function RoadtripLimitsCard({ onSave, onResetDayBoundaries, loadi
|
||||
onSave?.('roadtrip_vehicle', key ?? '')
|
||||
}}
|
||||
/>
|
||||
<span className="flex min-w-0 cursor-pointer items-center justify-center gap-1.5 rounded-[8px] px-3 py-1.5 text-center font-medium text-content-muted transition-colors hover:text-content peer-checked:bg-surface-card peer-checked:text-content peer-checked:shadow-sm peer-focus-visible:ring-2 peer-focus-visible:ring-accent peer-disabled:pointer-events-none" style={fs(12.5, 'body')}>
|
||||
<span className="flex min-w-0 cursor-pointer items-center justify-center gap-1.5 rounded-[8px] px-3 py-1.5 text-center font-medium text-content-muted transition-colors hover:text-content peer-checked:bg-accent peer-checked:text-accent-text peer-focus-visible:ring-2 peer-focus-visible:ring-accent peer-disabled:pointer-events-none" style={fs(12.5, 'body')}>
|
||||
<Icon size={14} className="shrink-0" aria-hidden />
|
||||
{t(labelKey)}
|
||||
</span>
|
||||
@@ -671,7 +659,7 @@ export default function RoadtripLimitsCard({ onSave, onResetDayBoundaries, loadi
|
||||
so that gap was never asked for. Off by default because it costs a
|
||||
routing request per join and changes every day's kilometres. */}
|
||||
{automaticWindow ? (
|
||||
<div className="flex items-center gap-3" title={t('roadtrip.window.hint')}>
|
||||
<div className="flex min-h-10 items-center gap-3 rounded-[10px] bg-surface-input px-3 py-2" title={t('roadtrip.window.hint')}>
|
||||
<Link2 size={16} className="shrink-0 text-content-faint" aria-hidden />
|
||||
<span className="min-w-0 flex-1 text-body text-content-secondary">{t('roadtrip.line.connect')}</span>
|
||||
<Check size={16} className="text-accent-on" aria-label={t('roadtrip.window.hint')} />
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwi
|
||||
[true, t('roadtrip.mode.roadtrip'), Route],
|
||||
]
|
||||
return (
|
||||
<div className="flex-none px-3 pb-1 pt-3" style={{ background: NEUTRAL_TINT }}>
|
||||
<div className="trek-desktop-panel flex-none px-3 pb-1 pt-3" style={{ background: NEUTRAL_TINT }}>
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label={t('roadtrip.mode.label')}
|
||||
@@ -36,10 +36,7 @@ export default function RoadtripModeSwitch({ active, onChange }: RoadtripModeSwi
|
||||
role="tab"
|
||||
aria-selected={selected}
|
||||
onClick={() => onChange(value)}
|
||||
// Sized off the day plan's own type, like the road trip rail below it: the
|
||||
// switcher sits above both, so it cannot be the largest thing in the column.
|
||||
style={{ fontSize: 'calc(11.5px * var(--fs-scale-body, 1))' }}
|
||||
className={`flex h-[30px] flex-1 items-center justify-center gap-1.5 rounded-lg px-2 transition-colors ${
|
||||
className={`flex h-[30px] min-w-0 flex-1 items-center justify-center gap-1.5 rounded-lg px-2 text-control transition-colors ${
|
||||
selected
|
||||
? 'bg-surface-card font-semibold text-content shadow-card'
|
||||
: 'font-medium text-content-muted hover:bg-surface-hover hover:text-content'
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { CSSProperties } from 'react'
|
||||
// the components, so every component file of the rail stays a Fast Refresh boundary.
|
||||
|
||||
/** The column the markers and the line share, and the gap to the content beside it. */
|
||||
export const RAIL_GRID: CSSProperties = { gridTemplateColumns: '24px 1fr', columnGap: 10 }
|
||||
export const RAIL_GRID: CSSProperties = { gridTemplateColumns: '28px minmax(0, 1fr)', columnGap: 10 }
|
||||
|
||||
/**
|
||||
* The line between two stops.
|
||||
@@ -17,14 +17,14 @@ export const RAIL_DASH: CSSProperties = {
|
||||
backgroundImage: 'repeating-linear-gradient(var(--border-primary) 0 4px, transparent 4px 8px)',
|
||||
}
|
||||
|
||||
/** A 24px disc: a stop's number, or a service stop's icon. */
|
||||
export const DISC = 'grid h-6 w-6 shrink-0 place-items-center rounded-full'
|
||||
/** A 28px disc: a stop's number, or a service stop's icon. */
|
||||
export const DISC = 'grid size-7 shrink-0 place-items-center rounded-full'
|
||||
|
||||
/**
|
||||
* The small caption over a number: the eyebrow the planner's dialogs and cards use, so
|
||||
* the trip head reads like the cards beside it.
|
||||
*/
|
||||
export const STAT_LABEL = 'font-geist font-bold uppercase tracking-[.08em] text-content-faint'
|
||||
export const STAT_LABEL = 'font-medium text-content-muted'
|
||||
|
||||
/**
|
||||
* A pill in a day's head: the date, the drive, the count, a finding.
|
||||
@@ -32,4 +32,4 @@ export const STAT_LABEL = 'font-geist font-bold uppercase tracking-[.08em] text-
|
||||
* The day plan's pill: round, sentence case, quiet ink on the card colour with a soft
|
||||
* shadow, so a day head reads the same in both tabs.
|
||||
*/
|
||||
export const DAY_BADGE = 'inline-flex h-[20px] items-center gap-1 rounded-full px-2 font-geist font-normal uppercase tracking-[.05em] text-content-secondary'
|
||||
export const DAY_BADGE = 'inline-flex min-h-6 items-center gap-1 rounded-full px-2 font-geist font-normal text-content-secondary'
|
||||
|
||||
@@ -22,10 +22,9 @@ import { dayBookings, stopDaysOf } from './stopBookings'
|
||||
import type { Reservation } from '../../types'
|
||||
import type { StayDraft } from './RoadtripStayModal'
|
||||
import { missedLeaveOf, stayDraftOf } from './stayReading'
|
||||
import { RAIL_GRID, STAT_LABEL } from './RoadtripSidebar.constants'
|
||||
import { RefuelBand } from './RoadtripSidebarRefuelBand'
|
||||
import { DriveBand, SpillBlock } from './RoadtripSidebarDriveBands'
|
||||
import { BookendStop, BookingChips, RideBlock, TerminalStop, UndatedRides } from './RoadtripSidebarBookingRows'
|
||||
import { BookendStop, DayBookingList, RideBlock, TerminalStop, UndatedRides } from './RoadtripSidebarBookingRows'
|
||||
import { RouteViaStop, ServiceStop, Stop, type StopVehicle } from './RoadtripSidebarStopRows'
|
||||
import { DayHeader, TripSummary } from './RoadtripSidebarHeaders'
|
||||
|
||||
@@ -511,12 +510,8 @@ export function DaySection({ day, selectedAssignmentId, onSelectStop, onOpenBook
|
||||
better to put them and leaving them out would make the mode look like it
|
||||
lost them. */}
|
||||
{bookings.loose.length ? (
|
||||
<li className="mt-1.5">
|
||||
<div className="grid" style={RAIL_GRID}>
|
||||
<span aria-hidden />
|
||||
<span className={`${STAT_LABEL} px-1.5`} style={{ fontSize: FS.micro }}>{t('roadtrip.bookings.loose')}</span>
|
||||
</div>
|
||||
<BookingChips bookings={bookings.loose} continues={false} canEdit={!!canEditBookings} onOpen={onOpenBooking} />
|
||||
<li className="mt-2">
|
||||
<DayBookingList bookings={bookings.loose} canEdit={!!canEditBookings} onOpen={onOpenBooking} />
|
||||
</li>
|
||||
) : null}
|
||||
</ol>
|
||||
@@ -625,6 +620,7 @@ export default function RoadtripSidebar({
|
||||
}: RoadtripSidebarProps): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
const rail = useElementSize<HTMLDivElement>()
|
||||
const [scrolled, setScrolled] = useState(false)
|
||||
const narrow = rail.width > 0 && rail.width < RAIL_NARROW_PX
|
||||
// One drag state for the whole rail rather than one per day: a stop that cannot leave
|
||||
// its own day is exactly the move a road trip needs when a leg turns out too long.
|
||||
@@ -667,7 +663,7 @@ export default function RoadtripSidebar({
|
||||
return (
|
||||
// The totals hold still while the days move under them: they are the answer to "how
|
||||
// long is this trip", and an answer that scrolls away is one you have to go back for.
|
||||
<div ref={rail.ref} className="flex min-h-0 flex-1 flex-col gap-3 pt-1">
|
||||
<div ref={rail.ref} className="trek-desktop-panel flex min-h-0 flex-1 flex-col gap-2 pt-1">
|
||||
<div className="shrink-0">
|
||||
<TripSummary routes={routes} narrow={narrow} />
|
||||
{routes.dayWindowIssue ? (
|
||||
@@ -677,7 +673,11 @@ export default function RoadtripSidebar({
|
||||
) : null}
|
||||
<UndatedRides rides={undated} onOpenBooking={onOpenBooking} />
|
||||
</div>
|
||||
<div className="roadtrip-rail-scroll flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto pb-3.5">
|
||||
<div
|
||||
className="roadtrip-rail-scroll flex min-h-0 flex-1 flex-col gap-2.5 overflow-y-auto pb-3.5"
|
||||
data-fade-top={scrolled || undefined}
|
||||
onScroll={event => setScrolled(event.currentTarget.scrollTop > 1)}
|
||||
>
|
||||
{routes.days.map(day => (
|
||||
<DaySection
|
||||
key={day.dayId}
|
||||
|
||||
@@ -100,8 +100,7 @@ export function StayBadge({ stay, onEdit }: { stay: StayReading; onEdit?: () =>
|
||||
if (!text && !until && !onEdit) return null
|
||||
return (
|
||||
<FigureBadge
|
||||
caption
|
||||
lead={t('roadtrip.stop.stayShort')}
|
||||
lead={<><Clock size={12} strokeWidth={2} aria-hidden /><span className="sr-only">{t('roadtrip.stop.stayShort')}</span></>}
|
||||
value={(
|
||||
<>
|
||||
{text ?? (until ? null : '+')}
|
||||
@@ -109,7 +108,7 @@ export function StayBadge({ stay, onEdit }: { stay: StayReading; onEdit?: () =>
|
||||
</>
|
||||
)}
|
||||
faint={!text}
|
||||
tooltip={onEdit ? (stay.until ? t('roadtrip.stay.untilHint', { time: formatClockTime(stay.until, is12h) }) : t('roadtrip.stop.stay')) : undefined}
|
||||
tooltip={stay.until ? t('roadtrip.stay.untilHint', { time: formatClockTime(stay.until, is12h) }) : t('roadtrip.stop.stay')}
|
||||
onActivate={onEdit}
|
||||
ariaLabel={onEdit
|
||||
? text || until ? `${t('roadtrip.stop.stay')}: ${[text, until].filter(Boolean).join(' ')}` : t('roadtrip.stay.add')
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { RoadtripStop } from './useRoadtripRoutes'
|
||||
import type { ScheduleEntry, ScheduleWarning } from './roadtripModel'
|
||||
import type { BookendReading } from './roadtripRowModel'
|
||||
import type { Reservation, RouteSegment } from '../../types'
|
||||
import { BookendStop, BookingChips, RideBlock, TerminalStop, UndatedRides } from './RoadtripSidebarBookingRows'
|
||||
import { BookendStop, DayBookingList, RideBlock, TerminalStop, UndatedRides } from './RoadtripSidebarBookingRows'
|
||||
import { tooltipOf } from '../../../tests/helpers/roadtripRail'
|
||||
|
||||
const wrap = (ui: React.ReactElement) => render(<TranslationProvider>{ui}</TranslationProvider>)
|
||||
@@ -317,15 +317,15 @@ describe('RideBlock', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('BookingChips', () => {
|
||||
describe('DayBookingList', () => {
|
||||
const table = booking({ id: 1, type: 'restaurant', title: 'Fischereihafen', reservation_time: '2026-06-01T19:30' })
|
||||
const train = booking({ id: 2, type: 'train', title: 'ICE 1007', status: 'confirmed' })
|
||||
|
||||
it('FE-ROADTRIP-BOOKINGROWS-009: a pill opens when this reader may open it, and the rest stay plain pills that name their booking in the tooltip', () => {
|
||||
const onOpen = vi.fn()
|
||||
const { container } = wrap(<BookingChips bookings={[table, train]} continues canEdit={false} onOpen={onOpen} />)
|
||||
// Each pill says it is a reservation and carries its time; the title is in its name.
|
||||
expect(screen.getAllByText('Reservation')).toHaveLength(2)
|
||||
wrap(<DayBookingList bookings={[table, train]} canEdit={false} onOpen={onOpen} />)
|
||||
expect(screen.getByText('Also booked this day')).toBeInTheDocument()
|
||||
expect(screen.getByText('Fischereihafen')).toBeInTheDocument()
|
||||
expect(screen.getByText('19:30')).toBeInTheDocument()
|
||||
// The table has only its editor, which this reader may not open; the train has a view.
|
||||
expect(screen.queryByRole('button', { name: /Fischereihafen/ })).toBeNull()
|
||||
@@ -333,33 +333,30 @@ describe('BookingChips', () => {
|
||||
const ride = screen.getByRole('button', { name: 'ICE 1007, Confirmed' })
|
||||
fireEvent.click(ride)
|
||||
expect(onOpen).toHaveBeenCalledWith(2)
|
||||
expect(container.querySelector('.w-\\[1\\.5px\\]')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('FE-ROADTRIP-BOOKINGROWS-009b: the word takes the status colour, green once confirmed and amber while pending', () => {
|
||||
wrap(<BookingChips bookings={[table, train]} continues={false} canEdit={false} />)
|
||||
const [pending, confirmed] = screen.getAllByText('Reservation')
|
||||
expect(pending).toHaveClass('text-warning')
|
||||
expect(confirmed).toHaveClass('text-success')
|
||||
it('FE-ROADTRIP-BOOKINGROWS-009b: the booking icon takes its status colour', () => {
|
||||
wrap(<DayBookingList bookings={[table, train]} canEdit={false} />)
|
||||
expect(screen.getByText('Fischereihafen').parentElement).toHaveClass('text-warning')
|
||||
expect(screen.getByText('ICE 1007').parentElement).toHaveClass('text-success')
|
||||
})
|
||||
|
||||
it('FE-ROADTRIP-BOOKINGROWS-010: an editor opens every pill, and without a way to open any they are all plain', () => {
|
||||
const onOpen = vi.fn()
|
||||
const editor = wrap(<BookingChips bookings={[table, train]} continues={false} canEdit onOpen={onOpen} />)
|
||||
const editor = wrap(<DayBookingList bookings={[table, train]} canEdit onOpen={onOpen} />)
|
||||
expect(screen.getAllByRole('button')).toHaveLength(2)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Fischereihafen, Pending' }))
|
||||
expect(onOpen).toHaveBeenCalledWith(1)
|
||||
expect(editor.container.querySelector('.w-\\[1\\.5px\\]')).toBeNull()
|
||||
editor.unmount()
|
||||
|
||||
wrap(<BookingChips bookings={[table, train]} continues={false} canEdit />)
|
||||
wrap(<DayBookingList bookings={[table, train]} canEdit />)
|
||||
expect(screen.queryByRole('button')).toBeNull()
|
||||
expect(screen.getAllByText('Reservation')).toHaveLength(2)
|
||||
expect(screen.getByRole('list').children).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('FE-ROADTRIP-BOOKINGROWS-011: the clock follows the traveller\'s format', () => {
|
||||
settings({ time_format: '12h' })
|
||||
wrap(<BookingChips bookings={[table]} continues={false} canEdit={false} />)
|
||||
wrap(<DayBookingList bookings={[table]} canEdit={false} />)
|
||||
expect(screen.getByText('7:30 PM')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { AlertTriangle, ArrowRight, type LucideIcon } from 'lucide-react'
|
||||
import { AlertTriangle, ArrowRight, Ticket, type LucideIcon } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
@@ -12,7 +12,7 @@ import type { Reservation, RouteSegment } from '../../types'
|
||||
import { bookingOpens, rideReading, terminalReading, type CheckInReading, type RideEnd } from './carrierRide'
|
||||
import FigureBadge from './FigureBadge'
|
||||
import { tintOf } from '../Planner/planParts'
|
||||
import { typeInfo } from '../Planner/bookings/bookingsModel'
|
||||
import { displayTitle, typeInfo } from '../Planner/bookings/bookingsModel'
|
||||
import { bookingClock, bookingIcon } from './stopBookings'
|
||||
import { FS } from './typeScale'
|
||||
import { DISC, RAIL_GRID } from './RoadtripSidebar.constants'
|
||||
@@ -317,27 +317,34 @@ export function RideBlock({ departure, arrival, booking, entries, late, seg, con
|
||||
*
|
||||
* Under the stop's button rather than inside it, because a button cannot hold buttons.
|
||||
*/
|
||||
export function BookingChips({ bookings, continues, canEdit, onOpen }: {
|
||||
export function DayBookingList({ bookings, canEdit, onOpen }: {
|
||||
bookings: Reservation[]
|
||||
continues: boolean
|
||||
/** Whether a table's or a ticket's editor opens for this reader; see `bookingOpens`. */
|
||||
canEdit: boolean
|
||||
onOpen?: (reservationId: number) => void
|
||||
}): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<div className="grid" style={RAIL_GRID}>
|
||||
<span className="flex flex-col items-center" aria-hidden>
|
||||
{continues ? <span className="w-[1.5px] flex-1 rounded-sm bg-edge" /> : null}
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-1 px-1.5 pb-1.5">
|
||||
{bookings.map(r => <ReservationPill key={r.id} booking={r} canEdit={canEdit} onOpen={onOpen} />)}
|
||||
</div>
|
||||
<div className="rounded-xl bg-surface-secondary p-2.5">
|
||||
<h4 className="mb-2 mt-0 flex items-center gap-2 text-control font-semibold text-content">
|
||||
<span className="grid size-6 shrink-0 place-items-center rounded-lg bg-surface-input text-content-muted">
|
||||
<Ticket size={13} aria-hidden />
|
||||
</span>
|
||||
{t('roadtrip.bookings.loose')}
|
||||
</h4>
|
||||
<ul className="m-0 flex list-none flex-col gap-1.5 p-0">
|
||||
{bookings.map(r => (
|
||||
<li key={r.id} className="min-w-0 [&>span]:min-h-7">
|
||||
<ReservationPill booking={r} canEdit={canEdit} onOpen={onOpen} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A booking on a stop's badge row: the status colour, the booking's icon and the word,
|
||||
* A booking on a stop's badge row: the status colour, its icon and its title,
|
||||
* like the day plan's pill under a place, with its time only when that is not already the
|
||||
* arrival on the right. A span with the button role, because the stop row around it is a
|
||||
* button already.
|
||||
@@ -351,23 +358,23 @@ export function ReservationPill({ booking, arrival, canEdit, onOpen }: {
|
||||
}): React.ReactElement {
|
||||
const { t } = useTranslation()
|
||||
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
||||
const icon = React.createElement(bookingIcon(booking.type), { size: 10, strokeWidth: 2.2, 'aria-hidden': true })
|
||||
const icon = React.createElement(bookingIcon(booking.type), { size: 12, strokeWidth: 2, className: 'shrink-0', 'aria-hidden': true })
|
||||
const confirmed = booking.status === 'confirmed'
|
||||
const status = confirmed ? t('reservations.confirmed') : t('reservations.pending')
|
||||
const title = displayTitle(booking) || t('places.formReservation')
|
||||
const clock = bookingClock(booking)
|
||||
const time = clock ? formatClockTime(clock, is12h) : null
|
||||
const shownTime = time && time !== arrival ? time : null
|
||||
const open = onOpen && bookingOpens(booking, canEdit) ? () => onOpen(booking.id) : undefined
|
||||
// The same pill as the stay and the check-in: the word in capitals, a straight cut, the time.
|
||||
return (
|
||||
<FigureBadge
|
||||
caption
|
||||
shrink
|
||||
tone={confirmed ? 'success' : 'pending'}
|
||||
lead={<>{icon}{t('places.formReservation')}</>}
|
||||
lead={<>{icon}<span className="truncate font-[family-name:var(--font-system)] text-control font-semibold text-content">{title}</span></>}
|
||||
value={shownTime ?? undefined}
|
||||
tooltip={`${booking.title} (${status})`}
|
||||
tooltip={`${title} (${status})`}
|
||||
onActivate={open ? () => open() : undefined}
|
||||
ariaLabel={`${booking.title}, ${status}`}
|
||||
ariaLabel={`${title}, ${status}`}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Bike, CarFront, Footprints, Moon, Shuffle, Zap, type LucideIcon } from
|
||||
import MDancingTrek from '../../mobile/components/MDancingTrek'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { fs } from '../shared/DialogShell'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
import { formatDistance } from '../../utils/units'
|
||||
import { formatClockTime } from '../../utils/formatters'
|
||||
@@ -70,11 +69,11 @@ export function DriveBand({ leg, carrier, onAskAlternatives, alternativesOpen }:
|
||||
<Icon size={11} strokeWidth={2} className="shrink-0" aria-hidden />
|
||||
{leg && ride ? (
|
||||
<>
|
||||
{carrier ? <span className="min-w-0 truncate font-medium" style={fs(10.5)}>{carrier.title}</span> : null}
|
||||
{duration ? <span className="shrink-0 font-medium tabular-nums" style={fs(10.5)}>{duration}</span> : null}
|
||||
{carrier ? <span className="min-w-0 truncate font-medium">{carrier.title}</span> : null}
|
||||
{duration ? <span className="shrink-0 font-medium tabular-nums">{duration}</span> : null}
|
||||
</>
|
||||
) : (
|
||||
<span className="min-w-0 truncate font-medium tabular-nums" style={fs(10.5)}>
|
||||
<span className="min-w-0 truncate font-medium tabular-nums">
|
||||
{!leg
|
||||
? t('roadtrip.leg.pending')
|
||||
: t('roadtrip.leg.driveText', {
|
||||
@@ -102,11 +101,12 @@ export function DriveBand({ leg, carrier, onAskAlternatives, alternativesOpen }:
|
||||
type="button"
|
||||
onClick={onAskAlternatives}
|
||||
aria-pressed={alternativesOpen}
|
||||
className={`group/leg my-1 flex w-full items-center gap-1.5 rounded-full py-[3px] pe-1 ps-2.5 text-start font-geist transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent ${
|
||||
className={`group/leg my-1 flex min-h-7 w-full items-center gap-1.5 rounded-full py-1 pe-1 ps-2.5 text-start font-geist transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent ${
|
||||
alternativesOpen
|
||||
? 'bg-surface-selected text-content'
|
||||
: 'bg-surface-tertiary text-content-muted hover:bg-surface-selected'
|
||||
}`}
|
||||
style={{ fontSize: FS.time }}
|
||||
>
|
||||
{band}
|
||||
{/* The open leg darkens its ink, not its box. A filled accent square here put
|
||||
@@ -122,7 +122,7 @@ export function DriveBand({ leg, carrier, onAskAlternatives, alternativesOpen }:
|
||||
</button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<div className="my-1 flex w-full items-center gap-1.5 rounded-full bg-surface-tertiary px-2.5 py-[3px] font-geist text-content-muted">
|
||||
<div className="my-1 flex min-h-7 w-full items-center gap-1.5 rounded-full bg-surface-tertiary px-2.5 py-1 font-geist text-content-muted" style={{ fontSize: FS.time }}>
|
||||
{band}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -69,10 +69,10 @@ export function TripSummary({ routes, narrow }: { routes: RoadtripRoutes; narrow
|
||||
<div className="grid gap-1.5 p-1.5" style={{ gridTemplateColumns: `repeat(${cells.length}, minmax(0, 1fr))` }}>
|
||||
{cells.map(([label, value]) => (
|
||||
<div key={label} className="flex min-w-0 flex-col gap-1.5 rounded-xl px-2.5 pb-2 pt-2" style={{ background: NEUTRAL_TINT }}>
|
||||
<span className={`${STAT_LABEL} truncate`} style={fs(9.5)}>{label}</span>
|
||||
<span className={`${STAT_LABEL} truncate text-caption`} title={label}>{label}</span>
|
||||
<span
|
||||
className="whitespace-nowrap font-semibold leading-none tracking-[-0.03em] tabular-nums text-content"
|
||||
style={fs(17, 'subtitle')}
|
||||
style={{ fontSize: FS.total }}
|
||||
>
|
||||
{splitValue(value)}
|
||||
</span>
|
||||
@@ -112,7 +112,7 @@ function shortDate(iso: string, is12h: boolean, format?: string | null): string
|
||||
|
||||
/**
|
||||
* Roughly how wide a day head pill is: its padding, its icon and the gap after it, and
|
||||
* its text in uppercase Geist at 10px with the pill's letter-spacing.
|
||||
* its text in the same Geist caption as the day plan's pills.
|
||||
*/
|
||||
function pillWidth(text: string): number {
|
||||
return 16 + 11 + 4 + text.length * 6.6
|
||||
@@ -165,7 +165,7 @@ export function DayTile({ day, tint }: { day: RoadtripDay; tint: string | null }
|
||||
{day.date ? (
|
||||
<>
|
||||
<span aria-hidden className="h-px w-[60%] flex-none bg-current opacity-25" />
|
||||
<time dateTime={day.date} aria-label={formatDate(day.date, language)} className="grid h-6 w-full place-items-center font-semibold" style={{ ...fs(9.5), lineHeight: 1 }}>
|
||||
<time dateTime={day.date} aria-label={formatDate(day.date, language)} className="grid h-6 w-full place-items-center font-semibold" style={{ ...fs(11), lineHeight: 1 }}>
|
||||
{shortDate(day.date, is12h, dateFormat)}
|
||||
</time>
|
||||
</>
|
||||
@@ -312,10 +312,10 @@ export function DayHeader({ day, collapsed, onToggle, onFollowTrack, viaCount, t
|
||||
<DayTile day={day} tint={tint} />
|
||||
|
||||
<div className="min-w-0 flex-1 pt-px">
|
||||
<h3 className="m-0 min-w-0 truncate font-bold text-content" style={fs(13.5, 'body')}>
|
||||
<h3 className="m-0 min-w-0 truncate font-bold text-content" style={{ fontSize: FS.dayTitle }}>
|
||||
{day.title || dayName}
|
||||
</h3>
|
||||
<div ref={rowRef} className="mt-1.5 flex min-w-0 flex-nowrap items-center gap-1 overflow-hidden" style={{ fontSize: FS.meta }}>
|
||||
<div ref={rowRef} className="mt-1.5 flex min-w-0 flex-nowrap items-center gap-1 overflow-hidden" style={{ fontSize: FS.time }}>
|
||||
{/* A day that is only the night booked for it has no drive to sum up and no
|
||||
stop to count; the hotel row below says everything it has to say. */}
|
||||
{day.legs.length > 0 ? (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useId, useState } from 'react'
|
||||
import { ParkingSquare, Hourglass, AlertTriangle, BedDouble } from 'lucide-react'
|
||||
import { CalendarCheck, ListFilter, Clock, Zap, ParkingSquare, Hourglass, AlertTriangle, BedDouble } from 'lucide-react'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { PANEL, Segmented } from '../shared/dialogParts'
|
||||
import CustomTimePicker from '../shared/CustomTimePicker'
|
||||
@@ -207,7 +207,7 @@ export default function RoadtripStopPopup({
|
||||
{/* Check-in only, and optional at that: it is the hour the drive can stop for
|
||||
the night, the one thing about a booking the chain uses. A check-out is a
|
||||
booking detail and lives under Days with the rest of them. */}
|
||||
<DialogSection label={t('day.checkIn')}>
|
||||
<DialogSection icon={CalendarCheck} label={t('day.checkIn')}>
|
||||
<CustomTimePicker value={checkIn} onChange={setCheckIn} aria-label={t('day.checkIn')} placeholder="" style={{ width: '100%' }} />
|
||||
</DialogSection>
|
||||
{websiteHref || draft.poi.phone ? (
|
||||
@@ -225,12 +225,12 @@ export default function RoadtripStopPopup({
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DialogSection label={t('roadtrip.stop.kind')}>
|
||||
<DialogSection icon={ListFilter} label={t('roadtrip.stop.kind')}>
|
||||
<div className={PANEL}>
|
||||
<StopKindChips value={stopType} onPick={pickKind} white className="flex flex-wrap gap-1.5" />
|
||||
</div>
|
||||
</DialogSection>
|
||||
<DialogSection label={t('roadtrip.stop.stay')}>
|
||||
<DialogSection icon={Clock} label={t('roadtrip.stop.stay')}>
|
||||
<div className={PANEL}>
|
||||
<StopStayChips value={dwell} onPick={setDwell} white className="flex flex-wrap gap-1.5" />
|
||||
</div>
|
||||
@@ -239,7 +239,7 @@ export default function RoadtripStopPopup({
|
||||
being considered. Only for the kind that has an answer: a petrol station
|
||||
or a bakery asks nothing, so picking either costs no request at all. */}
|
||||
{stopType === 'charging' ? (
|
||||
<DialogSection label={t('roadtrip.charging.availability')}>
|
||||
<DialogSection icon={Zap} label={t('roadtrip.charging.availability')}>
|
||||
<ChargingInfo lat={draft.poi.lat} lng={draft.poi.lng} name={draft.poi.name} />
|
||||
</DialogSection>
|
||||
) : null}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Pencil } from 'lucide-react'
|
||||
import { Clock, Pencil } from 'lucide-react'
|
||||
import EndDayControl, { type EndDayControlProps } from './EndDayControl'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
@@ -25,9 +25,9 @@ export default function VisitControls({ endDay, stay }: { endDay?: EndDayControl
|
||||
const is12h = useSettingsStore(s => s.settings.time_format) === '12h'
|
||||
const until = stay?.until ? t('roadtrip.stay.until', { time: formatClockTime(stay.until, is12h) }) : null
|
||||
return (
|
||||
<div className={`grid items-start gap-3 ${endDay && stay ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
<>
|
||||
{stay && (
|
||||
<DialogSection label={t('roadtrip.stop.stayShort')}>
|
||||
<DialogSection icon={Clock} label={t('roadtrip.stop.stayShort')}>
|
||||
<button type="button" onClick={stay.onEdit} disabled={!stay.onEdit}
|
||||
className={`${VISIT_BOX} w-full text-start transition-colors enabled:hover:bg-surface-hover disabled:cursor-default`}>
|
||||
<span className="flex min-w-0 items-center gap-1.5 font-medium text-content" style={fs(12.5, 'body')}>
|
||||
@@ -39,10 +39,10 @@ export default function VisitControls({ endDay, stay }: { endDay?: EndDayControl
|
||||
</DialogSection>
|
||||
)}
|
||||
{endDay && (
|
||||
<DialogSection label={t('roadtrip.window.title')}>
|
||||
<DialogSection icon={Clock} label={t('roadtrip.window.title')}>
|
||||
<EndDayControl {...endDay} />
|
||||
</DialogSection>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
/** The closed control: one line, on the card's own ground, with the card's edge. */
|
||||
export const DROPDOWN_TRIGGER =
|
||||
'flex h-[32px] items-center gap-2 rounded-xl border border-edge bg-surface-card pe-2 ps-2.5 text-start transition-colors hover:border-content-faint'
|
||||
'flex h-9 items-center gap-2 rounded-[10px] border border-edge bg-surface-input pe-2 ps-2.5 text-start text-control transition-colors hover:border-content-faint'
|
||||
|
||||
/** The list it opens, under it and at least as wide. */
|
||||
export const DROPDOWN_LIST =
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
* Both road trip panels sit beside the day plan and the tab switcher flips between
|
||||
* them, so a road trip whose names ran a size larger than the day plan's read as a
|
||||
* different app.
|
||||
* The two anchors are the day plan's own: a day title is 14px and a place name 12.5px
|
||||
* (`DayPlanSidebar`), and everything here is derived from those. The design handoff was
|
||||
* drawn a fifth larger throughout — its proportions are kept, its absolute sizes are not.
|
||||
* The day title and place name follow `DayPlanSidebar`. Route figures have a little
|
||||
* more room because they carry most of the information in this mode.
|
||||
*
|
||||
* Written as `calc(px * var(--fs-scale-<tier>))` rather than as a tier utility because
|
||||
* the tiers land on 24/18/14/12px and this rail needs the steps between them; the
|
||||
@@ -17,17 +16,17 @@ export const FS = {
|
||||
/** A total in the head. */
|
||||
total: 'calc(20px * var(--fs-scale-title, 1))',
|
||||
/** The unit hanging off one. */
|
||||
totalUnit: 'calc(11.5px * var(--fs-scale-title, 1))',
|
||||
totalUnit: 'calc(13px * var(--fs-scale-title, 1))',
|
||||
/** A day's name — the day plan's own size. */
|
||||
dayTitle: 'calc(14px * var(--fs-scale-body, 1))',
|
||||
dayTitle: 'calc(13.5px * var(--fs-scale-body, 1))',
|
||||
/** A stop's name — the day plan's own size. */
|
||||
name: 'calc(12.5px * var(--fs-scale-body, 1))',
|
||||
name: 'calc(13px * var(--fs-scale-body, 1))',
|
||||
/** A clock reading, and a service stop's dwell. */
|
||||
time: 'calc(11px * var(--fs-scale-caption, 1))',
|
||||
time: 'calc(11.5px * var(--fs-scale-caption, 1))',
|
||||
/** A drive band, a date, a line of explanation. */
|
||||
meta: 'calc(10px * var(--fs-scale-caption, 1))',
|
||||
/** The number in a marker. */
|
||||
marker: 'calc(10.5px * var(--fs-scale-caption, 1))',
|
||||
marker: 'calc(11.5px * var(--fs-scale-caption, 1))',
|
||||
/** A badge, a caption over a total. */
|
||||
label: 'calc(9px * var(--fs-scale-caption, 1))',
|
||||
/** The word "Stay" — the smallest thing in the rail. */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React, { useId } from 'react'
|
||||
import { KeyRound, Plus, Trash2, Copy, Check, AlertTriangle, type LucideIcon } from 'lucide-react'
|
||||
import { KeyRound, Plus, Trash2, Copy, Check, AlertTriangle, ShieldCheck, type LucideIcon } from 'lucide-react'
|
||||
import { PUBLIC_API_SCOPES } from '@trek/shared'
|
||||
import Section from './Section'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { EditorField, GRID_2, INPUT, LABEL } from '../shared/dialogParts'
|
||||
import { CardHead, EditorField, GRID_2, INPUT, LABEL, PANEL } from '../shared/dialogParts'
|
||||
import { SETTINGS_BUTTON_PRIMARY, SETTINGS_ICON_BUTTON, SettingsHint, StatusPill } from './settingsKit'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useDateFormat } from '../../hooks/useDateFormat'
|
||||
@@ -177,6 +177,7 @@ export default function ApiKeysSection(): React.ReactElement {
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className={PANEL}>
|
||||
<EditorField label={t('settings.apiKeys.modal.name')} htmlFor="api-key-name" hint={t('settings.apiKeys.modal.nameHint')}>
|
||||
<input id="api-key-name" type="text" value={newName} onChange={e => setNewName(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') void handleCreate() }}
|
||||
@@ -185,12 +186,11 @@ export default function ApiKeysSection(): React.ReactElement {
|
||||
className={INPUT}
|
||||
data-initial-focus />
|
||||
</EditorField>
|
||||
</div>
|
||||
|
||||
<section role="group" aria-labelledby="api-key-scopes-title">
|
||||
<div className="mb-2 flex items-center gap-2">
|
||||
<span id="api-key-scopes-title" className="font-geist font-bold uppercase tracking-[.08em] text-content-faint" style={fs(9.5)}>
|
||||
{t('settings.apiScopes.title')}
|
||||
</span>
|
||||
<section role="group" aria-label={t('settings.apiScopes.title')} className={PANEL}>
|
||||
<div className="flex items-center gap-2">
|
||||
<CardHead icon={<ShieldCheck size={16} aria-hidden />} title={t('settings.apiScopes.title')} />
|
||||
<button type="button"
|
||||
onClick={() => setNewScopes(allSelected ? new Set() : new Set(PUBLIC_API_SCOPES))}
|
||||
className="ms-auto flex-none rounded-full px-2 py-0.5 font-semibold text-content-muted transition-colors hover:bg-surface-tertiary hover:text-content"
|
||||
@@ -198,13 +198,13 @@ export default function ApiKeysSection(): React.ReactElement {
|
||||
{allSelected ? t('common.deselectAll') : t('common.selectAll')}
|
||||
</button>
|
||||
</div>
|
||||
<SettingsHint className="mb-3">{t('settings.apiScopes.hint')}</SettingsHint>
|
||||
<div className={GRID_2}>
|
||||
{PUBLIC_API_SCOPES.map(scope => (
|
||||
<ScopeOption key={scope} icon={API_SCOPE_ICONS[scope]} label={t(`settings.apiScopes.${scope}`)}
|
||||
checked={newScopes.has(scope)} onToggle={() => toggleScope(scope)} />
|
||||
))}
|
||||
</div>
|
||||
<SettingsHint>{t('settings.apiScopes.hint')}</SettingsHint>
|
||||
{newScopes.size === 0 && (
|
||||
<p className="m-0 mt-2 text-danger" style={fs(11.5)}>{t('settings.apiScopes.noneSelected')}</p>
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { type ReactNode } from 'react'
|
||||
import { Paintbrush, Eye, LayoutDashboard, Sun, Moon, Monitor, RotateCcw } from 'lucide-react'
|
||||
import { Smartphone, Paintbrush, Eye, LayoutDashboard, Sun, Moon, Monitor, RotateCcw } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { DialogSection, fs } from '../shared/DialogShell'
|
||||
import { Segmented } from '../shared/dialogParts'
|
||||
@@ -219,7 +219,7 @@ export default function AppearanceSettingsTab(): React.ReactElement {
|
||||
icon={LayoutDashboard}
|
||||
hint={tr('settings.appearance.dashboardWidgetsHint', 'Choose which widgets appear on the dashboard — independently for desktop and mobile.')}
|
||||
>
|
||||
<DialogSection label={tr('settings.appearance.desktop', 'Desktop')}>
|
||||
<DialogSection icon={Monitor} label={tr('settings.appearance.desktop', 'Desktop')}>
|
||||
<div className="flex flex-col gap-3">
|
||||
{DESKTOP_GROUPS.map((g) => {
|
||||
const masterOn = g.master ? cfg.dashboard.desktop[g.master] : true
|
||||
@@ -253,7 +253,7 @@ export default function AppearanceSettingsTab(): React.ReactElement {
|
||||
</div>
|
||||
</DialogSection>
|
||||
|
||||
<DialogSection label={tr('settings.appearance.mobile', 'Mobile')}>
|
||||
<DialogSection icon={Smartphone} label={tr('settings.appearance.mobile', 'Mobile')}>
|
||||
<div className="flex flex-col gap-3">
|
||||
{MOBILE_GROUPS.map((g) => (
|
||||
<WidgetGroup key={g.id} caption={tr(`settings.appearance.group.${g.id}`, g.fallback)}>
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useId } from 'react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { useFormatDate } from '../../hooks/useDateFormat'
|
||||
import { useToast } from '../shared/Toast'
|
||||
import { Trash2, Copy, Terminal, Plus, Check, Key, KeyRound, RefreshCw, AlertTriangle, Link2 } from 'lucide-react'
|
||||
import { Trash2, Copy, Terminal, Plus, Check, Key, KeyRound, RefreshCw, AlertTriangle, Link2, LayoutTemplate, ShieldCheck } from 'lucide-react'
|
||||
import PhotoProvidersSection from './PhotoProvidersSection'
|
||||
import AirTrailConnectionSection from './AirTrailConnectionSection'
|
||||
import MailImportSection from './MailImportSection'
|
||||
@@ -14,8 +14,8 @@ import ApiKeysSection from './ApiKeysSection'
|
||||
import ScopeGroupPicker from '../OAuth/ScopeGroupPicker'
|
||||
import ConfirmDialog from '../shared/ConfirmDialog'
|
||||
import { Tooltip } from '../shared/Tooltip'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { EditorField, INPUT, Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
import { CardHead, EditorField, INPUT, PANEL, Segmented, TEXTAREA } from '../shared/dialogParts'
|
||||
import { SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, SETTINGS_ICON_BUTTON, SettingRows, SettingsColumns, SettingsHint, StatusPill } from './settingsKit'
|
||||
import { OAUTH_PRESETS, useMcpIntegration, type OAuthClient } from './useMcpIntegration'
|
||||
import { useIntegrationGates } from './useIntegrationGates'
|
||||
@@ -415,6 +415,7 @@ function CreateTokenDialog({ S }: { S: IntegrationsState }) {
|
||||
<CopyValue value={mcpCreatedToken} copied={copiedKey === 'new-token'} label={t('settings.mcp.copy')} onCopy={() => handleCopy(mcpCreatedToken, 'new-token')} wrap />
|
||||
</>
|
||||
) : (
|
||||
<div className={PANEL}>
|
||||
<EditorField label={t('settings.mcp.modal.tokenName')} htmlFor={`${labelId}-name`}>
|
||||
<input id={`${labelId}-name`} type="text" value={mcpNewName} onChange={e => setMcpNewName(e.target.value)}
|
||||
onKeyDown={e => e.key === 'Enter' && handleCreateMcpToken()}
|
||||
@@ -422,6 +423,7 @@ function CreateTokenDialog({ S }: { S: IntegrationsState }) {
|
||||
className={INPUT}
|
||||
data-initial-focus />
|
||||
</EditorField>
|
||||
</div>
|
||||
)}
|
||||
</DialogShell>
|
||||
)
|
||||
@@ -472,7 +474,8 @@ function ClientForm({ S, labelId }: { S: IntegrationsState; labelId: string }) {
|
||||
const { t, oauthNewName, setOauthNewName, oauthNewUris, setOauthNewUris, oauthNewScopes, setOauthNewScopes, oauthIsMachine, setOauthIsMachine } = S
|
||||
return (
|
||||
<>
|
||||
<DialogSection label={t('settings.oauth.modal.presets')}>
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<LayoutTemplate size={16} aria-hidden />} title={t('settings.oauth.modal.presets')} />
|
||||
<div className="flex flex-wrap gap-1.5" style={fs(12.5, 'body')}>
|
||||
{OAUTH_PRESETS.map(preset => (
|
||||
<button
|
||||
@@ -488,8 +491,9 @@ function ClientForm({ S, labelId }: { S: IntegrationsState; labelId: string }) {
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</DialogSection>
|
||||
</div>
|
||||
|
||||
<div className={PANEL}>
|
||||
<EditorField label={t('settings.oauth.modal.clientName')} htmlFor={`${labelId}-name`}>
|
||||
<input id={`${labelId}-name`} type="text" value={oauthNewName} onChange={e => setOauthNewName(e.target.value)}
|
||||
placeholder={t('settings.oauth.modal.clientNamePlaceholder')}
|
||||
@@ -507,11 +511,13 @@ function ClientForm({ S, labelId }: { S: IntegrationsState; labelId: string }) {
|
||||
className={`${TEXTAREA} font-mono`} />
|
||||
</EditorField>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<DialogSection label={t('settings.oauth.modal.scopes')}>
|
||||
<SettingsHint className="mb-2.5">{t('settings.oauth.modal.scopesHint')}</SettingsHint>
|
||||
<div className={PANEL}>
|
||||
<CardHead icon={<ShieldCheck size={16} aria-hidden />} title={t('settings.oauth.modal.scopes')} />
|
||||
<ScopeGroupPicker selected={oauthNewScopes} onChange={setOauthNewScopes} />
|
||||
</DialogSection>
|
||||
<SettingsHint>{t('settings.oauth.modal.scopesHint')}</SettingsHint>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user