mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
fix(planner): booking codes stay blurred in the edit forms too
With "Blur booking codes" on, the bookings list and the transport details hid a code, but opening the same booking to edit it printed the code in the clear: the reservation and transport forms with every per-segment code of a flight or train, the hotel editor in the day panel and the three phone sheets. The stay's own code in the day panel, the booking strip in the place inspector and the booking lines under a stay and a stop on the phone showed it plainly as well. One shared BookingCodeInput and BlurredCode now carry the setting to all of them. A filled code field stays blurred until it is hovered or focused, so clicking, tapping or tabbing into it still reveals the code for editing, and the value is saved exactly as typed. With the setting off nothing changes, and the PDF export and the share pages stay as they were.
This commit is contained in:
@@ -3,6 +3,8 @@ import type { ReactNode, MouseEvent, CSSProperties } from 'react'
|
||||
import PlaceAvatar from '../../../../components/shared/PlaceAvatar'
|
||||
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
|
||||
import MarkdownText from '../../../../components/shared/MarkdownText'
|
||||
import { BlurredCode } from '../../../../components/shared/BookingCode'
|
||||
import { useBlurBookingCodes } from '../../../../hooks/useBlurBookingCodes'
|
||||
import { RES_ICONS, getNoteIcon } from '../../../../components/Planner/DayPlanSidebar.constants'
|
||||
import { noteSurface } from '../../../../components/Planner/noteSurface'
|
||||
import { getDisplayTimeForDay, getSpanPhase } from '../../../../utils/dayMerge'
|
||||
@@ -113,6 +115,7 @@ function AvatarRing({ children, className = '', style }: { children: ReactNode;
|
||||
}
|
||||
|
||||
const TIME_CHIP = 'flex-none whitespace-nowrap rounded-[6px] bg-[color:var(--m-ic)] px-[6px] py-px font-geist text-[0.65625rem] font-semibold'
|
||||
const ROW_CODE = 'flex-none whitespace-nowrap font-geist text-[0.71875rem] text-m-muted'
|
||||
|
||||
// ── b3) Place row ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -131,17 +134,23 @@ export function PlaceRow({ assignment, fullPlace, linkedReservations, chrome, re
|
||||
const place = assignment.place
|
||||
const CatIcon = getCategoryIcon(place?.category?.icon)
|
||||
const time = fmtTime(place?.place_time, chrome)
|
||||
const blurCodes = useBlurBookingCodes()
|
||||
// One line per booking on the stop (#2201). A single one keeps the bare
|
||||
// status line it always had; once there are several, the title tells them
|
||||
// apart, since "Confirmed" twice over says nothing.
|
||||
const bookingLines = linkedReservations.map(r => ({
|
||||
id: r.id,
|
||||
text: [
|
||||
// A code under the blur setting cannot stay inside the line, because the
|
||||
// first line goes through the Markdown caption and that only takes a string.
|
||||
// It is kept apart as `code` and drawn blurred right after the line.
|
||||
const bookingLines = linkedReservations.map(r => {
|
||||
const code = r.confirmation_number ? `#${r.confirmation_number}` : ''
|
||||
const parts = [
|
||||
linkedReservations.length > 1 ? r.title : '',
|
||||
r.status === 'confirmed' ? t('dayplan.confirmed') : t('dayplan.pendingRes'),
|
||||
r.confirmation_number ? `#${r.confirmation_number}` : '',
|
||||
].filter(Boolean).join(' · '),
|
||||
}))
|
||||
]
|
||||
return blurCodes && code
|
||||
? { id: r.id, text: `${parts.filter(Boolean).join(' · ')} ·`, code }
|
||||
: { id: r.id, text: [...parts, code].filter(Boolean).join(' · '), code: '' }
|
||||
})
|
||||
const sub = bookingLines.length > 0
|
||||
? bookingLines[0].text
|
||||
: place?.address || place?.description || ''
|
||||
@@ -191,11 +200,13 @@ export function PlaceRow({ assignment, fullPlace, linkedReservations, chrome, re
|
||||
<div className="mt-[2px] flex min-w-0 items-center gap-1.5">
|
||||
{time && <span className={TIME_CHIP}>{time}</span>}
|
||||
{sub && <MarkdownText clamp className="min-w-0 font-geist text-[0.71875rem] text-m-muted">{sub}</MarkdownText>}
|
||||
{bookingLines[0]?.code && <BlurredCode interactive={false} className={ROW_CODE}>{bookingLines[0].code}</BlurredCode>}
|
||||
</div>
|
||||
)}
|
||||
{bookingLines.slice(1).map(line => (
|
||||
<div key={line.id} className="mt-[2px] flex min-w-0 items-center gap-1.5">
|
||||
<span className="min-w-0 truncate font-geist text-[0.71875rem] text-m-muted">{line.text}</span>
|
||||
{line.code && <BlurredCode interactive={false} className={ROW_CODE}>{line.code}</BlurredCode>}
|
||||
</div>
|
||||
))}
|
||||
{assignment.notes && (
|
||||
|
||||
@@ -4,6 +4,7 @@ import MSheet from '../../../components/MSheet'
|
||||
import MIconBtn from '../../../components/MIconBtn'
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect'
|
||||
import CustomTimePicker from '../../../../components/shared/CustomTimePicker'
|
||||
import { BookingCodeInput } from '../../../../components/shared/BookingCode'
|
||||
import { accommodationsApi } from '../../../../api/client'
|
||||
import { applyStayStops } from '../../../../store/stayStops'
|
||||
import { useTranslation } from '../../../../i18n'
|
||||
@@ -204,8 +205,7 @@ export default function MAccommodationSheet({ planner, shell }: MTripSheetsProps
|
||||
|
||||
{/* Confirmation */}
|
||||
<Eyebrow className="mb-[5px] mt-3">{t('day.confirmation')}</Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
<BookingCodeInput
|
||||
value={form.confirmation}
|
||||
onChange={e => setForm(f => ({ ...f, confirmation: e.target.value }))}
|
||||
placeholder="ABC-12345"
|
||||
|
||||
@@ -17,6 +17,7 @@ import { getTransportForDay, hasCarrierEndpointOnDay } from '../../../../utils/d
|
||||
import { splitReservationDateTime } from '../../../../utils/formatters'
|
||||
import { dayCoMapsUrl, dayGoogleMapsUrl, optimizeDayOrder } from '../lib/dayRoute'
|
||||
import GoogleMapsIcon from '../../../../components/shared/GoogleMapsIcon'
|
||||
import { BlurredCode } from '../../../../components/shared/BookingCode'
|
||||
import { splitNoteTime } from '../lib/dayNotes'
|
||||
import { weatherIconFor } from '../plan/planTimelineModel'
|
||||
import type { Assignment, DayNote, Reservation } from '../../../../types'
|
||||
@@ -566,7 +567,8 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-[0.6875rem] text-m-muted">
|
||||
{linked.status === 'confirmed' ? t('reservations.confirmed') : t('reservations.pending')}
|
||||
{linked.confirmation_number ? ` · #${linked.confirmation_number}` : ''}
|
||||
{/* The strip is a button already, so the code gets the plain blur, not a toggle. */}
|
||||
{linked.confirmation_number ? <> · <BlurredCode interactive={false}>{`#${linked.confirmation_number}`}</BlurredCode></> : ''}
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { typeToCostCategory } from '@trek/shared'
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect'
|
||||
import CustomTimePicker from '../../../../components/shared/CustomTimePicker'
|
||||
import { CustomDatePicker } from '../../../../components/shared/CustomDateTimePicker'
|
||||
import { BookingCodeInput } from '../../../../components/shared/BookingCode'
|
||||
import { Eyebrow, FIELD_AREA_CLS, FIELD_CLS, FormSheetFooter, FormSheetHeader } from './PlSheetChrome'
|
||||
import PlFileAttach from './PlFileAttach'
|
||||
import { buildAssignmentOptions } from '../../../../components/Planner/assignmentOptions'
|
||||
@@ -513,8 +514,7 @@ export default function MReservationSheet({ planner, onOpenExpense }: MReservati
|
||||
<div className="mt-3 flex gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<Eyebrow className="mb-[5px] uppercase">{t('reservations.confirmationCode')}</Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
<BookingCodeInput
|
||||
value={form.confirmation_number}
|
||||
onChange={e => set('confirmation_number', e.target.value)}
|
||||
placeholder={t('reservations.confirmationPlaceholder')}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { orderedEndpoints, parseReservationMetadata } from '../../../../utils/fl
|
||||
import { typeToCostCategory } from '@trek/shared'
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect'
|
||||
import CustomTimePicker from '../../../../components/shared/CustomTimePicker'
|
||||
import { BookingCodeInput } from '../../../../components/shared/BookingCode'
|
||||
import AirportSelect, { type Airport } from '../../../../components/Planner/AirportSelect'
|
||||
import LocationSelect, { type LocationPoint } from '../../../../components/Planner/LocationSelect'
|
||||
import TransitSearchPanel from '../../../../components/Planner/TransitSearchPanel'
|
||||
@@ -809,8 +810,7 @@ export default function MTransportFormSheet({ planner, onOpenExpense }: MTranspo
|
||||
{writesFlightLegs && (
|
||||
<div className="mt-2">
|
||||
<Eyebrow className="mb-[5px] uppercase">{t('reservations.confirmationCode')}</Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
<BookingCodeInput
|
||||
value={wp.confirmation_number}
|
||||
onChange={e => updateWp({ confirmation_number: e.target.value })}
|
||||
placeholder={t('reservations.confirmationPlaceholder')}
|
||||
@@ -899,8 +899,7 @@ export default function MTransportFormSheet({ planner, onOpenExpense }: MTranspo
|
||||
{writesTrainLegs && (
|
||||
<div className="mt-2">
|
||||
<Eyebrow className="mb-[5px] uppercase">{t('reservations.confirmationCode')}</Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
<BookingCodeInput
|
||||
value={wp.confirmation_number}
|
||||
onChange={e => updateWp({ confirmation_number: e.target.value })}
|
||||
placeholder={t('reservations.confirmationPlaceholder')}
|
||||
@@ -1029,8 +1028,7 @@ export default function MTransportFormSheet({ planner, onOpenExpense }: MTranspo
|
||||
<div className="mt-3 flex gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<Eyebrow className="mb-[5px] uppercase">{t('reservations.confirmationCode')}</Eyebrow>
|
||||
<input
|
||||
type="text"
|
||||
<BookingCodeInput
|
||||
value={form.confirmation_number}
|
||||
onChange={e => set('confirmation_number', e.target.value)}
|
||||
placeholder={t('reservations.confirmationPlaceholder')}
|
||||
|
||||
Reference in New Issue
Block a user