fix(ui): refine trip forms and planner empty states

This commit is contained in:
Maurice
2026-12-02 22:03:08 +01:00
parent 59e5c5a3c9
commit 01ad13623c
19 changed files with 286 additions and 183 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
"src/components/Admin/AdminPluginsPanel.test.tsx": 2704,
"src/components/Admin/AdminPluginsPanel.tsx": 1265,
"src/components/Budget/CostsPanel.test.tsx": 2725,
"src/components/Budget/CostsPanel.tsx": 1607,
"src/components/Budget/CostsPanel.tsx": 1588,
"src/components/Map/MapView.tsx": 1191,
"src/components/Map/MapViewGL.test.tsx": 2919,
"src/components/Map/MapViewGL.tsx": 2083,
@@ -17,6 +17,7 @@ import { amountToInputString, currencyDecimals } from '../../utils/formatters'
import { localIsoDate } from '../../utils/localDate'
import type { ExpensePrefill } from './CostsPanel'
import type { BudgetItem } from '../../types'
import type { CostsSettlement } from './costsModel'
// The split and receipt fields guard their own precision on every keystroke, so the
// guard has to follow the currency: a three-decimal one (KWD, BHD, …) seeds three
@@ -329,3 +330,24 @@ export function expenseEditorFor(
if (receipt) return { key: 'receipt', editing: null, prefill: receipt, close: closeReceipt }
return null
}
/** Expenses and settle-up payments grouped newest day first in the Costs ledger. */
export function groupLedgerByDay(expenses: readonly BudgetItem[], payments: readonly CostsSettlement[], locale: string, noDate: string) {
const entries = [
...expenses.map(e => ({ kind: 'expense' as const, date: e.expense_date || '', e })),
...payments.map(s => ({ kind: 'payment' as const, date: settlementDate(s), s })),
].sort((a, b) => b.date.localeCompare(a.date))
const groups = new Map<string, typeof entries>()
for (const entry of entries) {
let label = noDate
if (entry.date) {
try {
label = new Date(entry.date + 'T00:00:00Z').toLocaleDateString(locale, { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' })
} catch { label = entry.date }
}
const group = groups.get(label)
if (group) group.push(entry)
else groups.set(label, [entry])
}
return [...groups].map(([day, entries]) => ({ day, entries }))
}
@@ -944,13 +944,13 @@ describe('CostsPanel — overview', () => {
expect(labels).toEqual(['Food & drink', 'Transport'])
expect(within(breakdown).getByText('90 €')).toBeInTheDocument()
expect(within(breakdown).getByText('30 €')).toBeInTheDocument()
})
});
it('FE-W5COSTS-006: an empty trip shows the empty ledger and the empty breakdown', async () => {
it('FE-W5COSTS-006: an empty trip shows the empty ledger without a total or category breakdown', async () => {
mount([])
expect(await screen.findByText('No expenses yet. Add your first one.')).toBeInTheDocument()
expect(screen.getByText('No expenses yet.')).toBeInTheDocument()
expect(await screen.findByText('No expenses yet. Add your first one.')).toBeInTheDocument();
expect(screen.queryByRole('region', { name: 'Total trip spend' })).toBeNull();
expect(screen.queryByRole('region', { name: 'By category' })).toBeNull();
expect(screen.getByText("Everyone's square")).toBeInTheDocument()
})
+20 -40
View File
@@ -13,7 +13,7 @@ import { CustomDatePicker } from '../shared/CustomDateTimePicker'
import { useReceiptScan } from './useReceiptScan'
import { ReceiptScanModal } from './ReceiptScanModal'
import { SPLIT_COLORS } from './BudgetPanel.constants'
import { finalBudgetFor, finalBudgetSources, formerParticipantRows, NOTE_MAX, paidByUser, readUserNote, settlementDate } from './CostsPanel.helpers'
import { groupLedgerByDay, finalBudgetFor, finalBudgetSources, formerParticipantRows, NOTE_MAX, paidByUser, readUserNote } from './CostsPanel.helpers'
import { COST_CATEGORY_LIST, catMeta } from './costsCategories'
import {
baseTotal as baseTotalOf, booked as bookedAmount, isUnfinished as isUnfinishedModel, lineOf as lineOfModel, memberShareOf,
@@ -52,12 +52,6 @@ interface CostsPanelProps {
tripMembers?: TripMember[]
}
// One row in the unified Costs ledger — either an expense or a settle-up payment,
// carrying the date used to group it by day.
type LedgerEntry =
| { kind: 'expense'; date: string; e: BudgetItem }
| { kind: 'payment'; date: string; s: Settlement }
const round2 = (n: number) => Math.round(n * 100) / 100
const FIELD_H = 40 // shared height for the amount / currency / day row in the modal
const COSTS_VIEW_KEY = 'trek:costs-view'
@@ -66,6 +60,7 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
const { trip, budgetItems, deleteBudgetItem, loadBudgetItems, addBudgetItem, updateBudgetItem } = useTripStore()
const can = useCanDo()
const canEdit = can('budget_edit', trip)
const hasExpenses = budgetItems.length > 0
const receiptScan = useReceiptScan(tripId, canEdit)
const toast = useToast()
const { t, locale } = useTranslation()
@@ -143,27 +138,9 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
// Nobody paid, so nobody owes (#2225).
const myShareOf = (e: BudgetItem) => settledShareOf(e, ctx)
// ── day grouping ─────────────────────────────────────────────────────────
const dayGroups = useMemo(() => {
const entries: LedgerEntry[] = [
...filtered.map(e => ({ kind: 'expense' as const, date: e.expense_date || '', e })),
...filteredSettlements.map(s => ({ kind: 'payment' as const, date: settlementDate(s), s })),
]
const labelOf = (date: string) => {
if (!date) return t('costs.noDate')
try { return new Date(date + 'T00:00:00Z').toLocaleDateString(locale, { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' }) } catch { return date }
}
// Newest day first; within a day, expenses before payments (insertion order).
const sorted = entries.slice().sort((a, b) => (b.date || '').localeCompare(a.date || ''))
const groups: { day: string; entries: LedgerEntry[] }[] = []
for (const en of sorted) {
const day = labelOf(en.date)
let g = groups.find(x => x.day === day)
if (!g) { g = { day, entries: [] }; groups.push(g) }
g.entries.push(en)
}
return groups
}, [filtered, filteredSettlements, locale, t])
const noDate = t('costs.noDate')
const dayGroups = useMemo(() => groupLedgerByDay(filtered, filteredSettlements, locale, noDate), [filtered, filteredSettlements, locale, noDate])
const emptyLedger = !hasExpenses && dayGroups.length === 0
// ── filter dropdown options (category + single day) ──────────────────────
const categoryOptions = useMemo(() => [
@@ -285,8 +262,8 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
}} />
{/* ── Summary cards; with nothing to split (#2689) the total stands alone ── */}
{!splitting ? <div style={{ marginBottom: 36 }}>{totalCard}</div> : (
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 16, marginBottom: 36 }} className="costs-summary">
{!splitting ? (hasExpenses && <div style={{ marginBottom: 36 }}>{totalCard}</div>) : (
<div style={{ display: 'grid', gridTemplateColumns: hasExpenses ? 'repeat(4, minmax(0, 1fr))' : 'repeat(3, minmax(0, 1fr))', gap: 16, marginBottom: 36 }} className="costs-summary">
<SummaryCard label={t('costs.youOwe')} sub={t('costs.youOweSub')} amount={balancesKnown ? totals.owe : null} currency={base} locale={locale}
icon={<ArrowDown size={18} />} tone="owe" failed={settlementError}
foot={totals.owe > 0.01
@@ -302,7 +279,7 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
foot={totals.outstandingCount > 0
? <span><b>{totals.outstandingCount}</b> {t('costs.outstandingItems', { count: totals.outstandingCount })}</span>
: settledUp && <span className="text-content-faint">{t('costs.allSettled')}</span>} />
{totalCard}
{hasExpenses && totalCard}
</div>)}
{/* ── Main grid ── */}
@@ -310,10 +287,10 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
sidebar the last, so it lines up with the total-spend card. */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', columnGap: 16, rowGap: 32, alignItems: 'start' }} className="costs-grid">
{/* expenses */}
<div className="costs-main" style={{ gridColumn: 'span 3', minWidth: 0 }}>
<div className="costs-main" style={{ gridColumn: emptyLedger ? '1 / -1' : 'span 3', minWidth: 0 }}>
{dayBanner}
{view === 'table' ? (
{emptyLedger ? <EmptyState scene="costs" title={t('costs.emptyText')} /> : view === 'table' && hasExpenses ? (
filtered.length === 0 && budgetItems.length > 0 ? (
<div className="text-content-faint" style={{ textAlign: 'center', padding: '60px 20px' }}>{t('costs.noMatch')}</div>
) : (
@@ -379,14 +356,14 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
</>}
{/* by category; the table view sums up four ways instead */}
{view === 'table' ? (
{hasExpenses && (view === 'table' ? (
<CostsTableSummary items={filtered} baseTotal={baseTotal} toBase={booked} fmt={v => fmt(v)} personName={personName} splitting={splitting} />
) : (
<section aria-label={t('costs.byCategory')} className={SIDE_CARD}>
{sideHead(t('costs.byCategory'))}
<div className="px-4 py-4">{categoryBars}</div>
</section>
)}
))}
<CostsModeCard trip={trip} memberCount={people.length} canEdit={canEdit} className={SIDE_CARD} />
</div>
</div>
@@ -493,7 +470,7 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, paddingTop: 8 }}>
{/* Total card */}
<section style={{ background: 'linear-gradient(135deg,#1f2937,#111827)', color: '#fff', borderRadius: 22, padding: '20px 20px 16px', boxShadow: '0 8px 24px -8px rgba(0,0,0,0.28)' }}>
{hasExpenses ? <section style={{ background: 'linear-gradient(135deg,#1f2937,#111827)', color: '#fff', borderRadius: 22, padding: '20px 20px 16px', boxShadow: '0 8px 24px -8px rgba(0,0,0,0.28)' }}>
<div style={{ fontSize: 'calc(11.5px * var(--fs-scale-caption, 1))', textTransform: 'uppercase', letterSpacing: '0.12em', color: 'rgba(255,255,255,0.6)', fontWeight: 600 }}>{t('costs.totalSpend')}</div>
<div style={{ fontSize: 'calc(44px * var(--fs-scale-title, 1))', fontWeight: 700, letterSpacing: '-0.04em', lineHeight: 1, marginTop: 8, display: 'flex', alignItems: 'baseline' }}>{bigMoney(totals.totalSpend, 24, 'rgba(255,255,255,0.6)')}</div>
{splitting && <div style={{ display: 'flex', gap: 18, marginTop: 12, fontSize: 'calc(12px * var(--fs-scale-body, 1))', color: 'rgba(255,255,255,0.6)', flexWrap: 'wrap' }}>
@@ -512,7 +489,10 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
<ScanLine size={16} /> {t('costs.scan.button')}
</button>
)}
</section>
</section> : <div className="flex flex-wrap justify-end gap-2">
{receiptScan.offered && <DialogButton onClick={receiptScan.open}>{t('costs.scan.button')}</DialogButton>}
{canEdit && <DialogButton variant="primary" onClick={() => { setEditing(null); setModalOpen(true) }}>{t('costs.addExpense')}</DialogButton>}
</div>}
{/* Owe / Owed, outstanding and settling up: only with something to split (#2689) */}
{splitting && <>
@@ -582,7 +562,7 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
<CustomSelect value={dayFilter} onChange={v => setDayFilter(String(v))} options={dayOptions} size="sm" searchable style={{ flex: 1, minWidth: 0 }} />
</div>
{dayBanner}
{dayGroups.length === 0
{emptyLedger ? <EmptyState scene="costs" title={t('costs.emptyText')} /> : dayGroups.length === 0
? <div className="text-content-faint" style={{ textAlign: 'center', padding: '36px 16px', fontSize: 'calc(13px * var(--fs-scale-body, 1))' }}>{search ? t('costs.noMatch') : t('costs.emptyText')}</div>
: dayGroups.map(g => {
const dtot = g.entries.reduce((a, en) => en.kind === 'expense' ? a + baseTotal(en.e) : a, 0)
@@ -611,10 +591,10 @@ export default function CostsPanel({ tripId, tripMembers = [] }: CostsPanelProps
</>}
{/* By category */}
<div className={cardCls} style={{ borderRadius: 18, padding: 16 }}>
{hasExpenses && <div className={cardCls} style={{ borderRadius: 18, padding: 16 }}>
<div className={labelCls} style={{ marginBottom: 14 }}>{t('costs.byCategory')}</div>
{categoryBars}
</div>
</div>}
<CostsModeCard trip={trip} memberCount={people.length} canEdit={canEdit} className={`${cardCls} rounded-[18px]`} />
</div>
)
@@ -153,4 +153,9 @@ describe('ListsRail', () => {
renderRail({ onSelectLibrary: vi.fn(), libraryCount: null });
expect(screen.getByRole('button', { name: /All places/ })).toHaveTextContent(/^All places$/);
});
it('hides All places when the library is known to be empty', () => {
renderRail({ onSelectLibrary: vi.fn(), libraryCount: 0 });
expect(screen.queryByRole('button', { name: /All places/ })).not.toBeInTheDocument();
});
});
@@ -75,7 +75,7 @@ export default function ListsRail(props: ListsRailProps): React.ReactElement {
</Tooltip>
</div>
{onSelectLibrary && (
{onSelectLibrary && libraryCount !== 0 && (
<div className="col-row">
<button type="button" onClick={onSelectLibrary} className={`col-row-btn${libraryActive ? ' on' : ''}`} aria-current={libraryActive ? 'page' : undefined}>
<span className="ico tile"><Globe2 size={15} /></span>
@@ -83,11 +83,11 @@ function DayRowTourPills({ tour, stageKey }: { tour: TourListItem; stageKey?: st
}
// Description line, one line like every stop's.
function SublineDescription({ text, isTourPlace }: { text: string; isTourPlace: boolean }) {
function SublineDescription({ text, isTourPlace, fade }: { text: string; isTourPlace: boolean; fade: boolean }) {
return (
<div
data-testid={isTourPlace ? 'trip-plan-tour-description' : undefined}
className="collab-note-md min-w-0 flex-1 text-content-faint"
className={`collab-note-md min-w-0 flex-1 text-content-faint${fade ? 'trek-fade-end' : ''}`}
style={{
...fs(10.5),
overflow: 'hidden',
@@ -115,13 +115,15 @@ export function DayPlanPlaceSubline({
}: DayPlanPlaceSublineProps) {
const { locale } = useTranslation();
const dayRowTour = tourTimes?.tour;
const wrapTourFacts = !!dayRowTour || hasPlannedTimes(tourTimes);
const description = place.description || place.address || cat?.name;
if (!(dayRowTour || place.place_time || hasPlannedTimes(tourTimes) || description)) return null;
if (!(wrapTourFacts || place.place_time || description)) return null;
return (
// The description stays on one line and gives way first. The pills wrap rather
// than run out of the row: a tour carries a time, its duration and its distance,
// and in the narrow day column the last of them used to be cut off unseen.
<div className="trek-fade-end mt-0.5 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 overflow-hidden">
// At a regular stop, the time stays readable and only the description gives way.
// A tour can wrap its time, duration and distance in the narrow day column.
<div
className={`mt-0.5 flex min-w-0 items-center gap-x-1.5 overflow-hidden ${wrapTourFacts ? 'trek-fade-end flex-wrap gap-y-1' : 'flex-nowrap'}`}
>
{place.place_time && dayRowTour && (
// TIME-02: a tour's end, typed or worked out from its start and its time.
<TimePill quiet>
@@ -143,7 +145,7 @@ export function DayPlanPlaceSubline({
tourTimes && <PlannedTourPills tourTimes={tourTimes} />
)}
{dayRowTour && <WalkProgressPill tour={dayRowTour} assignmentId={assignmentId} />}
{description && <SublineDescription text={description} isTourPlace={isTourPlace} />}
{description && <SublineDescription text={description} isTourPlace={isTourPlace} fade={!wrapTourFacts} />}
</div>
);
}
@@ -142,12 +142,12 @@ describe('TripFormModal', () => {
const trip = buildTrip({ id: 1, title: 'Iceland Adventure' });
render(<TripFormModal {...defaultProps} trip={trip} />);
expect(screen.getByDisplayValue('Iceland Adventure')).toBeInTheDocument();
expect(screen.getByRole('textbox', { name: 'Title' }).closest('header')).toBeInTheDocument();
});
it('FE-COMP-TRIPFORM-012: shows Title label', () => {
it('FE-COMP-TRIPFORM-012: puts the only trip title field in the dialog header', () => {
render(<TripFormModal {...defaultProps} />);
// dashboard.tripTitle = "Title"
expect(screen.getByText('Title')).toBeInTheDocument();
expect(screen.getByRole('textbox', { name: 'Title' }).closest('header')).toBeInTheDocument();
});
it('FE-COMP-TRIPFORM-013: shows Cover Image section', () => {
+37 -21
View File
@@ -513,28 +513,30 @@ export default function TripFormModal({
<div className={`${panelCls} flex-1`}>
<CardHead
icon={<Type size={16} strokeWidth={2} />}
title={t('trip.form.aboutTitle')}
hint={t('trip.form.aboutHint')}
title={embedded ? t('trip.form.aboutTitle') : t('dashboard.tripDescription')}
hint={embedded ? t('trip.form.aboutHint') : undefined}
/>
<div>
<label className={labelCls}>
{t('dashboard.tripTitle')} <span className="text-danger">*</span>
</label>
<input
data-initial-focus={(!embedded && canEditTrip) || undefined}
type="text"
value={formData.title}
onChange={(e) => canEditTrip && update('title', e.target.value)}
required
readOnly={!canEditTrip}
placeholder={t('dashboard.tripTitlePlaceholder')}
className={inputCls}
/>
</div>
{embedded && (
<div>
<label className={labelCls}>
{t('dashboard.tripTitle')} <span className="text-danger">*</span>
</label>
<input
type="text"
value={formData.title}
onChange={(e) => canEditTrip && update('title', e.target.value)}
required
readOnly={!canEditTrip}
placeholder={t('dashboard.tripTitlePlaceholder')}
className={inputCls}
/>
</div>
)}
<div>
<label className={labelCls}>{t('dashboard.tripDescription')}</label>
{embedded && <label className={labelCls}>{t('dashboard.tripDescription')}</label>}
<textarea
aria-label={t('dashboard.tripDescription')}
value={formData.description}
onChange={(e) => canEditTrip && update('description', e.target.value)}
readOnly={!canEditTrip}
@@ -831,9 +833,23 @@ export default function TripFormModal({
}
: onClose
}
eyebrow={pendingReview ? undefined : isEditing ? t('dashboard.editTrip') : undefined}
title={
pendingReview ? reviewTitle : isEditing ? trip?.title || t('dashboard.editTrip') : t('dashboard.createTrip')
eyebrow={pendingReview ? undefined : t(isEditing ? 'dashboard.editTrip' : 'dashboard.createTrip')}
title={pendingReview ? reviewTitle : undefined}
titleInput={
pendingReview
? undefined
: {
value: formData.title,
label: t('dashboard.tripTitle'),
placeholder: t('dashboard.tripTitlePlaceholder'),
readOnly: !canEditTrip,
required: true,
onChange: (value) => canEditTrip && update('title', value),
onKeyDown: (event) => {
if (canEditTrip && !busy && event.key === 'Enter' && !event.nativeEvent.isComposing)
void handleSubmit(event);
},
}
}
/>
}
+3 -1
View File
@@ -199,7 +199,8 @@ export interface HeaderTitleInput {
/** The field's accessible name, e.g. the old "Title *" label. */
label: string
placeholder?: string
autoFocus?: boolean
autoFocus?: boolean;
readOnly?: boolean;
required?: boolean
maxLength?: number
onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void
@@ -253,6 +254,7 @@ export function DialogHeader(p: DialogHeaderProps) {
aria-label={f.label}
placeholder={f.placeholder}
ref={f.autoFocus ? focusRevealedEditor : undefined}
readOnly={f.readOnly}
required={f.required}
maxLength={f.maxLength}
className="-mx-2 block w-[calc(100%+16px)] rounded-[10px] border-0 bg-transparent px-2 py-0.5 font-bold tracking-[-0.01em] text-content outline-none placeholder:font-semibold placeholder:text-content-faint hover:bg-surface-card focus:bg-surface-card focus:shadow-sm dark:bg-transparent dark:hover:bg-surface-card dark:focus:bg-surface-card"
@@ -54,7 +54,7 @@ export default function MCollListNav({
'flex w-full items-center gap-[10px] rounded-[11px] p-[10px] text-start outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--m-act)]';
return (
<>
{onSelectLibrary && (
{onSelectLibrary && libraryCount !== 0 && (
<button
type="button"
onClick={onSelectLibrary}
@@ -17,7 +17,8 @@ import type { TripCardBadge } from '../../../api/client'
import MDemoWelcome from './MDemoWelcome'
import { IcsSubscribeModal } from '../../../components/Planner/IcsSubscribeModal'
import PluginWidgets from '../../../components/Plugins/PluginWidgets'
import { entityGradient } from '../../../utils/gradients'
import { entityGradient } from '../../../utils/gradients';
import MContextMenu from '../../components/MContextMenu';
import MGlassBar from '../../components/MGlassBar'
import MIconBtn from '../../components/MIconBtn'
import MSegmented from '../../components/MSegmented'
@@ -174,7 +175,6 @@ export default function MDashboard(): React.ReactElement {
{showEmpty && (
<div className="mt-[10px] flex flex-col items-center rounded-[20px] border border-[color:var(--m-gbr)] bg-[color:var(--m-glass)] px-4 py-8 text-center">
<MDancingTrek scene="dashboard" size={96} className="mb-2" />
<div className="text-[0.9375rem] font-bold">{t('dashboard.emptyTitle')}</div>
<div className="mt-1 font-geist text-[0.6875rem] text-m-muted">{t('dashboard.emptyText')}</div>
<button
@@ -151,8 +151,29 @@ export default function MNewTripSheet({ open, trip: tripProp, onClose, onSave, o
<FormSheetHeader
icon={Luggage}
title={isEditing ? t('dashboard.editTrip') : t('dashboard.createTrip')}
subtitle={isEditing ? trip?.title : undefined}
onClose={onClose}
titleField={
<input
type="text"
value={title}
onChange={(e) => {
if (canEditTrip) {
setError('');
setTitle(e.target.value);
}
}}
readOnly={!canEditTrip}
required
placeholder={t('dashboard.tripTitlePlaceholder')}
aria-label={t('dashboard.tripTitle')}
className="-ms-1 block min-h-10 w-full min-w-0 rounded-lg bg-transparent px-1 text-subtitle font-bold leading-tight text-m-ink outline-none placeholder:text-m-faint focus:bg-[color:var(--m-ic)] focus-visible:ring-2 focus-visible:ring-accent"
onKeyDown={(e) => {
if (!canEditTrip || busy || e.key !== 'Enter' || e.nativeEvent.isComposing) return;
e.preventDefault();
void handleSave();
}}
/>
}
onClose={onClose}
closeLabel={t('common.cancel')}
/>
@@ -165,16 +186,7 @@ export default function MNewTripSheet({ open, trip: tripProp, onClose, onSave, o
</div>
)}
<Eyebrow className="mb-[5px] mt-2 uppercase">{t('dashboard.tripTitle')}</Eyebrow>
<input
value={title}
onChange={e => { if (canEditTrip) { setError(''); setTitle(e.target.value) } }}
readOnly={!canEditTrip}
placeholder={t('dashboard.tripTitlePlaceholder')}
aria-label={t('dashboard.tripTitle')}
className={`${FIELD_CLS} font-semibold`}
/>
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('dashboard.tripDescription')}</Eyebrow>
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('dashboard.tripDescription')}</Eyebrow>
<textarea
value={description}
onChange={e => { if (canEditTrip) { setError(''); setDescription(e.target.value) } }}
@@ -89,7 +89,9 @@ import { SHEET_PRIMARY, SHEET_SECONDARY } from './MTripSheetUi'
interface FormSheetHeaderProps {
/** 40px rounded icon tile left of the title (place edit / import sheets). */
icon?: LucideIcon
title: ReactNode
title: ReactNode;
/** Editable name directly under the sheet actions's title. */
titleField?: ReactNode;
/** Geist 11.5px subline under the title (note sheet: "Day n · title"). */
subtitle?: ReactNode
/** Replaces the icon tile, e.g. a back button on the import sub-steps. */
@@ -101,7 +103,9 @@ interface FormSheetHeaderProps {
}
/** Form-sheet header: optional tile, 17px/700 title, 34px close. No hairline. */
export function FormSheetHeader({ icon: Icon, title, subtitle, leading, trailing, onClose, closeLabel }: FormSheetHeaderProps) {
export function FormSheetHeader({ icon: Icon, title,
titleField,
subtitle, leading, trailing, onClose, closeLabel }: FormSheetHeaderProps) {
return (
<div className="m-fs-head flex flex-none items-center gap-3 px-[18px] pb-2 pt-4">
{leading}
@@ -113,7 +117,16 @@ export function FormSheetHeader({ icon: Icon, title, subtitle, leading, trailing
<div className="min-w-0 flex-1">
{/* Two lines before it ends in an ellipsis: "Редактировать бронирование"
and "Eintrag bearbeiten" were cut after one at phone width. */}
<div className="line-clamp-2 break-words text-[1.0625rem] font-bold leading-tight text-m-ink">{title}</div>
<div
className={
titleField
? 'truncate font-geist text-caption font-bold uppercase tracking-wide text-m-muted'
: 'line-clamp-2 break-words text-[1.0625rem] font-bold leading-tight text-m-ink'
}
>
{title}
</div>
{titleField}
{subtitle && <div className="truncate font-geist text-[0.71875rem] text-m-muted">{subtitle}</div>}
</div>
{trailing}
+103 -66
View File
@@ -134,31 +134,49 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
// The summary: what the trip costs and who owes whom. Beside the expenses on
// a window with room for two panes, above them everywhere else.
const hasExpenses = budgetItems.length > 0;
const summary = (
<>
{/* Hero — "Total Trip Spend" (spec §3.1). Fixed dark card, both themes. */}
<div className="rounded-[20px] p-4 shadow-[0_18px_44px_-18px_rgba(0,0,0,.5)]" style={{ background: '#15151A', color: '#F5F5F7' }}>
<div className="font-geist text-[0.625rem] font-bold uppercase tracking-[.09em]" style={{ color: 'rgba(245,245,247,.55)' }}>
{t('costs.totalSpend')}
</div>
<div className="mt-1 font-geist text-[1.875rem] font-extrabold tabular-nums tracking-[-0.02em]">
{formatMoney(totals.totalSpend, base, locale)}
</div>
{/* Categories left out below (#2819) leave this total too, which it says. */}
{leftOutLabel && <div className="mt-[2px] text-caption opacity-70">{leftOutLabel}</div>}
{/* Each figure under its own label, so the two pairs never read as one run.
{hasExpenses && (
<div
className="rounded-[20px] p-4 shadow-[0_18px_44px_-18px_rgba(0,0,0,.5)]"
style={{ background: '#15151A', color: '#F5F5F7' }}
>
<div
className="font-geist text-[0.625rem] font-bold uppercase tracking-[.09em]"
style={{ color: 'rgba(245,245,247,.55)' }}
>
{t('costs.totalSpend')}
</div>
<div className="mt-1 font-geist text-[1.875rem] font-extrabold tabular-nums tracking-[-0.02em]">
{formatMoney(totals.totalSpend, base, locale)}
</div>
{/* Categories left out below (#2819) leave this total too, which it says. */}
{leftOutLabel && <div className="mt-[2px] text-caption opacity-70">{leftOutLabel}</div>}
{/* Each figure under its own label, so the two pairs never read as one run.
Only with something to split (#2689), like everything owed below. */}
{splitting && <div className="mt-[8px] flex flex-wrap gap-x-[22px] gap-y-[6px] text-[0.6875rem]" style={{ color: 'rgba(245,245,247,.7)' }}>
<span className="flex flex-col">
{t('costs.yourShare')}
<b className="tabular-nums" style={{ color: '#F5F5F7' }}>{formatMoney(totals.myShare, base, locale)}</b>
</span>
<span className="flex flex-col">
{t('costs.youPaid')}
<b className="tabular-nums" style={{ color: '#F5F5F7' }}>{formatMoney(totals.myPaid, base, locale)}</b>
</span>
</div>}
</div>
{splitting && (
<div
className="mt-[8px] flex flex-wrap gap-x-[22px] gap-y-[6px] text-[0.6875rem]"
style={{ color: 'rgba(245,245,247,.7)' }}
>
<span className="flex flex-col">
{t('costs.yourShare')}
<b className="tabular-nums" style={{ color: '#F5F5F7' }}>
{formatMoney(totals.myShare, base, locale)}
</b>
</span>
<span className="flex flex-col">
{t('costs.youPaid')}
<b className="tabular-nums" style={{ color: '#F5F5F7' }}>
{formatMoney(totals.myPaid, base, locale)}
</b>
</span>
</div>
)}
</div>
)}
{splitting && <>
{/* You owe / You're owed (spec §3.2). The two tiles stand level and each
@@ -315,50 +333,68 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
{/* By category (spec §3.5). A tap leaves a category out of the totals
for a look without it (#2819); the row stays, dimmed. */}
<div className="mt-2 rounded-2xl border border-[color:var(--m-rowbr)] bg-m-card p-[13px]">
<div className="flex items-center gap-2">
<div className="font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint">{t('costs.byCategory')}</div>
{leftOutLabel && (
<button
type="button"
onClick={countAllCats}
className="ms-auto flex flex-none items-center gap-1 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-[9px] py-[3px] text-caption font-semibold text-m-muted"
>
<RotateCcw size={11} strokeWidth={2.2} />
{t('costs.breakdown.countAll')}
</button>
{hasExpenses && (
<div className="mt-2 rounded-2xl border border-[color:var(--m-rowbr)] bg-m-card p-[13px]">
<div className="flex items-center gap-2">
<div className="font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint">
{t('costs.byCategory')}
</div>
{leftOutLabel && (
<button
type="button"
onClick={countAllCats}
className="ms-auto flex flex-none items-center gap-1 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-[9px] py-[3px] text-caption font-semibold text-m-muted"
>
<RotateCcw size={11} strokeWidth={2.2} />
{t('costs.breakdown.countAll')}
</button>
)}
</div>
{/* What is left out is said once, under the total above. */}
{!leftOutLabel && catBreakdown.length > 1 && (
<p className="mt-1 text-caption text-m-faint">{t('costs.breakdown.hint')}</p>
)}
{catBreakdown.length === 0 ? (
<p className="mt-2 font-geist text-[0.71875rem] text-m-faint">{t('costs.noCategories')}</p>
) : (
catBreakdown.map((c) => {
const meta = COST_CAT_META[c.key];
const name = t(meta.labelKey);
const action = c.leftOut
? t('costs.breakdown.countIn', { category: name })
: t('costs.breakdown.leaveOut', { category: name });
return (
<button
key={c.key}
type="button"
aria-label={action}
onClick={() => toggleLeftOutCat(c.key)}
className={`block w-full pb-[2px] pt-[6px] text-start ${c.leftOut ? 'opacity-45' : ''}`}
>
<span className="flex items-center gap-[7px]">
<span className="h-2 w-2 flex-none rounded-full" style={{ background: meta.color }} />
<span className="min-w-0 flex-1 truncate font-geist text-[0.65625rem] font-semibold text-m-muted">
{name}
</span>
<span
dir="ltr"
className={`ms-auto flex-none font-geist text-[0.65625rem] font-bold tabular-nums text-m-ink ${c.leftOut ? 'line-through' : ''}`}
>
{formatMoney(c.amount, base, locale)}
</span>
</span>
<span className="mt-1 block h-1 overflow-hidden rounded-full bg-[color:var(--m-ic)]">
<span
className="block h-full rounded-full"
style={{ width: `${c.widthPct}%`, background: meta.color }}
/>
</span>
</button>
);
})
)}
</div>
{/* What is left out is said once, under the total above. */}
{!leftOutLabel && catBreakdown.length > 1 && <p className="mt-1 text-caption text-m-faint">{t('costs.breakdown.hint')}</p>}
{catBreakdown.length === 0 ? (
<p className="mt-2 font-geist text-[0.71875rem] text-m-faint">{t('costs.noCategories')}</p>
) : (
catBreakdown.map(c => {
const meta = COST_CAT_META[c.key]
const name = t(meta.labelKey)
const action = c.leftOut ? t('costs.breakdown.countIn', { category: name }) : t('costs.breakdown.leaveOut', { category: name })
return (
<button
key={c.key}
type="button"
aria-label={action}
onClick={() => toggleLeftOutCat(c.key)}
className={`block w-full pb-[2px] pt-[6px] text-start ${c.leftOut ? 'opacity-45' : ''}`}
>
<span className="flex items-center gap-[7px]">
<span className="h-2 w-2 flex-none rounded-full" style={{ background: meta.color }} />
<span className="min-w-0 flex-1 truncate font-geist text-[0.65625rem] font-semibold text-m-muted">{name}</span>
<span dir="ltr" className={`ms-auto flex-none font-geist text-[0.65625rem] font-bold tabular-nums text-m-ink ${c.leftOut ? 'line-through' : ''}`}>{formatMoney(c.amount, base, locale)}</span>
</span>
<span className="mt-1 block h-1 overflow-hidden rounded-full bg-[color:var(--m-ic)]">
<span className="block h-full rounded-full" style={{ width: `${c.widthPct}%`, background: meta.color }} />
</span>
</button>
)
})
)}
</div>
)}
{costsMode.offered && (
<div className="mt-2 flex items-start gap-3 rounded-2xl border border-[color:var(--m-rowbr)] bg-m-card p-[13px]">
@@ -382,8 +418,8 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
return (
<>
<TabPanes aside={summary} asideLabel={t('budget.title')}>
{/* Expenses — header, search, filters (spec §3.6). One block, so on a wide
<TabPanes aside={hasExpenses || splitting ? summary : null} asideLabel={t('budget.title')}>
{/* Expenses — header, search, filters (spec §3.6). One block, so on a wide
window the search field keeps to the column like the heading above it. */}
<section aria-label={t('costs.expenses')}>
{/* The currency the tab reads the trip in (#1683) sits by the heading, as on the desktop. */}
@@ -564,7 +600,8 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
)
)}
</section>
</TabPanes>
{!hasExpenses && !splitting && costsMode.offered && summary}
</TabPanes>
{/* Add / edit expense — the shared desktop modal (spec §3.9); not rebuilt here. */}
{expenseModalOpen && (
@@ -73,7 +73,7 @@ export function CardGrid({ children }: { children: ReactNode }) {
* reader keeps their place: the row at the top of the list stays at the top.
*/
export function TabPanes({ aside, asideLabel, children }: { aside: ReactNode; asideLabel: string; children: ReactNode }) {
const split = useIsSplit()
const split = useIsSplit() && aside != null;
const body = useRef<HTMLDivElement>(null)
const list = useRef<HTMLDivElement>(null)
// How far the list has moved under the top edge of its scroll body, read on
+19 -15
View File
@@ -104,13 +104,18 @@ function DashboardPageDesktop(): React.ReactElement {
const {
demoMode, locale, t, navigate,
spotlight, heroBundle, stats, upcoming, gridTrips, isLoading,
showFirstTripPrompt,
loadError, retryLoad,
tripFilter, setTripFilter, viewMode, toggleViewMode,
showForm, setShowForm, editingTrip, setEditingTrip,
deleteTrip, setDeleteTrip, copyTrip, setCopyTrip, applyCoverUpdate,
handleCreate, handleUpdate, confirmDelete, handleArchive, handleUnarchive, confirmCopy,
allSubOpen, setAllSubOpen, search,
} = useDashboard()
} = useDashboard();
const openCreate = () => {
setEditingTrip(null);
setShowForm(true);
};
// Dashboard widget visibility (from the appearance config). Phones never reach this
// component — DashboardPage routes them to MDashboard — so only the desktop set applies.
@@ -222,22 +227,18 @@ function DashboardPageDesktop(): React.ReactElement {
/>
)}
{/* "No trips yet" only when there really are none — a user whose trips are
all finished has a hero, and telling them to create their first trip is
simply wrong (#1706). Same condition the mobile dashboard already uses. */}
{search.active && gridTrips.length === 0 && (
{search.active && gridTrips.length === 0 && (
<div className="trips-empty">
<EmptyState scene="dashboard" title={t('dashboard.search.empty', { query: search.query.trim() })} />
</div>
)}
{!search.active && gridTrips.length === 0 && !spotlight && tripFilter === 'planned' && !isLoading && !loadError && (
<div className="trips-empty">
<EmptyState scene="dashboard" title={t('dashboard.emptyTitle')} />
</div>
)}
<div className={`trips${viewMode === 'list' ? ' list-view' : ''}`}>
{showFirstTripPrompt && (
<p className="sr-only" role="status">
{t('dashboard.emptyTitle')}
</p>
)}
<div className={`trips${viewMode === 'list' ? ' list-view' : ''}`}>
{gridTrips.map(trip => (
<TripCard
key={trip.id}
@@ -260,7 +261,10 @@ function DashboardPageDesktop(): React.ReactElement {
</>
)}
{tripFilter === 'planned' && !search.active && !isLoading && (
<button type="button" className="add-trip-card" onClick={() => { setEditingTrip(null); setShowForm(true) }}>
<button type="button"
className={`add-trip-card${showFirstTripPrompt ? 'col-span-full' : ''}`}
onClick={openCreate}
>
<div>
<div className="circ"><Plus size={20} /></div>
<div className="ttl">{t('dashboard.newTrip')}</div>
@@ -286,8 +290,8 @@ function DashboardPageDesktop(): React.ReactElement {
<button type="button"
className="fab-new-trip"
onClick={() => { setEditingTrip(null); setShowForm(true) }}
aria-label={t('dashboard.newTrip')}
onClick={openCreate}
aria-label={t('dashboard.newTrip')}
title={t('dashboard.newTrip')}
>
<Plus size={22} strokeWidth={2.4} />
@@ -39,7 +39,7 @@ export function useCollections() {
const navigate = useNavigate()
const { id: routeId } = useParams<{ id: string }>()
// /places is the overview of every place (PLC-07); the lists live below it.
const isLibrary = useMatch({ path: '/places', end: true }) != null
const isLibraryRoute = useMatch({ path: '/places', end: true }) != null;
const toast = useToast()
const dm = useSettingsStore(s => s.settings.dark_mode)
@@ -100,7 +100,8 @@ export function useCollections() {
const [listsLoaded, setListsLoaded] = useState(false)
useEffect(() => { loadAll().then(() => setListsLoaded(true), () => setListsLoaded(false)) }, [])
// All places and All saved in the rail, each place once; read again when a list changes.
const libraryCount = useLibraryCount(collections)
const libraryCount = useLibraryCount(collections);
const isLibrary = isLibraryRoute && libraryCount?.all !== 0;
// Central admin-defined categories, for assigning a category to a saved place.
const [categories, setCategories] = useState<Category[]>([])
+10 -1
View File
@@ -232,13 +232,22 @@ export function useDashboard() {
const gridTrips = search.active ? search.results
: tripFilter === 'archive' ? archivedTrips
: tripFilter === 'completed' ? rest.filter(t => getTripStatus(t) === 'past')
: rest.filter(t => getTripStatus(t) !== 'past')
: rest.filter(t => getTripStatus(t) !== 'past');
const showFirstTripPrompt =
tripFilter === 'planned' &&
!search.active &&
!isLoading &&
!loadError &&
!authCheckFailed &&
trips.length === 0 &&
archivedTrips.length === 0;
return {
// cross-cutting
demoMode, locale, t, navigate,
// data + derived
spotlight, heroBundle, stats, upcoming, gridTrips, isLoading,
showFirstTripPrompt,
loadError: loadError || authCheckFailed, retryLoad,
// Pull-to-refresh on mobile: the same quiet read, no loading state.
refreshQuietly,