mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
fix(ci): repair trip tag checks and shared booking build
Restore the category label used by shared bookings, keep measured tag-menu positioning, and fix form queries and schema formatting. Collapse the Route label within narrow toolbars.
This commit is contained in:
@@ -1175,7 +1175,6 @@ 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) {
|
||||
@@ -1251,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
|
||||
@@ -1441,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' }}>
|
||||
@@ -2520,7 +2503,7 @@ 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 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={() => {
|
||||
@@ -2541,11 +2524,11 @@ 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={14} strokeWidth={2} />
|
||||
{!narrowPanel && t('dayplan.route')}
|
||||
<span className="whitespace-nowrap [@container(max-width:340px)]:hidden">{t('dayplan.route')}</span>
|
||||
</button>
|
||||
{/* The day's travel mode as one segmented control. */}
|
||||
<div role="group" aria-label={t('dayplan.transportMode.change')}
|
||||
|
||||
@@ -145,6 +145,18 @@ export function SectionHead({ group, open, onToggle }: { group: BookingGroup; op
|
||||
)
|
||||
}
|
||||
|
||||
/** Text label for the shared trip's booking cards. */
|
||||
export function TypeChip({ type }: { type: string }) {
|
||||
const { t } = useTranslation()
|
||||
const info = typeInfo(type)
|
||||
return (
|
||||
<span className="inline-flex flex-none items-center gap-1 rounded-full border border-edge-faint bg-surface-card px-2 py-[2px] font-geist font-bold uppercase tracking-[.06em] text-content-muted" style={fs(9.5)}>
|
||||
<info.Icon size={11} strokeWidth={2.2} style={{ color: info.color }} />
|
||||
{t(info.chipKey)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export function BookingTypeMarker({ booking, inHeader = false }: { booking: Reservation; inHeader?: boolean }) {
|
||||
const { t } = useTranslation()
|
||||
const info = typeInfo(booking.type)
|
||||
|
||||
@@ -200,8 +200,8 @@ describe('TripFormModal', () => {
|
||||
const user = userEvent.setup();
|
||||
seedStore(useAuthStore, { tripRemindersEnabled: true });
|
||||
render(<TripFormModal {...defaultProps} trip={null} />);
|
||||
await user.click(screen.getByRole('button', { name: 'Reminder', exact: true }));
|
||||
const reminder = within(await screen.findByRole('group', { name: 'Reminder', exact: true }));
|
||||
await user.click(screen.getByRole('button', { name: /^Reminder$/ }));
|
||||
const reminder = within(await screen.findByRole('group', { name: /^Reminder$/ }));
|
||||
expect(reminder.getByRole('button', { name: 'None' })).toBeInTheDocument();
|
||||
expect(reminder.getByRole('button', { name: '1 day' })).toBeInTheDocument();
|
||||
expect(reminder.getByRole('button', { name: '3 days' })).toBeInTheDocument();
|
||||
@@ -213,15 +213,15 @@ describe('TripFormModal', () => {
|
||||
seedStore(useAuthStore, { tripRemindersEnabled: false });
|
||||
render(<TripFormModal {...defaultProps} trip={null} />);
|
||||
expect(screen.getByText(/Trip reminders are disabled/i)).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: 'Reminder', exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: /^Reminder$/ })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-COMP-TRIPFORM-021: custom reminder input appears and accepts value', async () => {
|
||||
const user = userEvent.setup();
|
||||
seedStore(useAuthStore, { tripRemindersEnabled: true });
|
||||
render(<TripFormModal {...defaultProps} trip={null} />);
|
||||
await user.click(screen.getByRole('button', { name: 'Reminder', exact: true }));
|
||||
await user.click(await screen.findByRole('button', { name: 'Custom', exact: true }));
|
||||
await user.click(screen.getByRole('button', { name: /^Reminder$/ }));
|
||||
await user.click(await screen.findByRole('button', { name: /^Custom$/ }));
|
||||
// custom reminder input has max=30
|
||||
const customInput = document.querySelector('input[max="30"]') as HTMLInputElement;
|
||||
expect(customInput).toBeInTheDocument();
|
||||
@@ -1007,8 +1007,8 @@ describe('TripFormModal', () => {
|
||||
render(<TripFormModal {...defaultProps} trip={null} onSave={onSave} />);
|
||||
|
||||
await user.type(screen.getByPlaceholderText(/Summer in Japan/i), 'Reminder Trip');
|
||||
await user.click(screen.getByRole('button', { name: 'Reminder', exact: true }));
|
||||
await user.click(await screen.findByRole('button', { name: '9 days', exact: true }));
|
||||
await user.click(screen.getByRole('button', { name: /^Reminder$/ }));
|
||||
await user.click(await screen.findByRole('button', { name: /^9 days$/ }));
|
||||
await submitNewTrip(user);
|
||||
|
||||
await waitFor(() => expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reminder_days: 9 })));
|
||||
@@ -1020,8 +1020,8 @@ describe('TripFormModal', () => {
|
||||
const onSave = vi.fn().mockResolvedValue({});
|
||||
render(<TripFormModal {...defaultProps} trip={null} onSave={onSave} />);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Reminder', exact: true }));
|
||||
await user.click(await screen.findByRole('button', { name: 'Custom', exact: true }));
|
||||
await user.click(screen.getByRole('button', { name: /^Reminder$/ }));
|
||||
await user.click(await screen.findByRole('button', { name: /^Custom$/ }));
|
||||
const custom = document.querySelector('input[max="30"]') as HTMLInputElement;
|
||||
expect(custom.value).toBe('7');
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i
|
||||
})
|
||||
const menuOpen = active && suggestions.length > 0 && !!position
|
||||
const activeTag = menuOpen ? suggestions[highlighted] : undefined
|
||||
const { flipped, ...menuStyle } = position ?? { flipped: false }
|
||||
useOverlay(menuOpen, closeMenu, true)
|
||||
|
||||
const add = (name: string) => {
|
||||
@@ -182,7 +183,8 @@ export function TripTagField({ tags, draft, onChange, onDraftChange, readOnly, i
|
||||
ref={menuRef}
|
||||
id={menuId}
|
||||
className="trek-select-menu fixed z-[99999] flex flex-wrap content-start gap-1.5 overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-card p-2 shadow-lg"
|
||||
style={{ top: position.top, bottom: position.bottom, left: position.left, width: position.width, maxHeight: position.maxHeight }}
|
||||
data-side={flipped ? 'top' : 'bottom'}
|
||||
style={menuStyle}
|
||||
role="listbox"
|
||||
aria-label={t('dashboard.tags.existing')}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user