Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(client): settle the two findings Sonar raised on the audit branch

Mauricec5d10dfd6fb5
diff --git a/client/src/mobile/components/MToastHost.tsx b/client/src/mobile/components/MToastHost.tsx
index 316c99d20..0d29b7b31 100644
--- a/client/src/mobile/components/MToastHost.tsx
+++ b/client/src/mobile/components/MToastHost.tsx
@@ -27,6 +27,26 @@ const TYPE_DOT: Partial<Record<ToastType, MStatus>> = {
warning: 'pending',
}
+function MToastPill({ toast, onDismiss }: { toast: MToast; onDismiss: (id: number) => void }) {
+ const dot = TYPE_DOT[toast.type]
+ const wraps = toast.message.length > PILL_CHARS
+ return (
+ <div
+ role={toast.sticky ? 'button' : undefined}
+ tabIndex={toast.sticky ? 0 : undefined}
+ onClick={toast.sticky ? () => onDismiss(toast.id) : undefined}
+ onKeyDown={toast.sticky ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onDismiss(toast.id) } } : undefined}
+ className={`flex max-w-full gap-2 bg-m-act px-4 py-2 text-[0.75rem] font-semibold text-m-actfg shadow-[0_10px_30px_-8px_rgba(0,0,0,.5)] ${
+ wraps ? 'items-start rounded-2xl' : 'items-center rounded-full'
+ } ${toast.sticky ? 'pointer-events-auto cursor-pointer' : ''} ${toast.removing ? 'm-toast-out' : 'm-toast-in'}`}
+ >
+ {dot && <MStatusDot status={dot} size={6} className={wraps ? 'mt-[0.45rem]' : ''} />}
+ {/* No display utility next to line-clamp: Tailwind emits it later and kills the clamp. */}
+ <span className={`min-w-0 ${wraps ? 'line-clamp-4 leading-[1.45]' : 'truncate'}`}>{toast.message}</span>
+ </div>
+ )
+}
+
/**
* Mobile toast presenter. Takes over the global `window.__addToast` bridge
* (fed by useToast / store/notify) while the mobile shell is mounted, so every
@@ -78,26 +98,9 @@ export default function MToastHost() {
return (
<div className="pointer-events-none fixed inset-x-0 bottom-[calc(var(--bottom-nav-h,84px)+16px)] z-[90] flex flex-col-reverse items-center gap-2 px-6">
- {toasts.map((toast) => {
- const dot = TYPE_DOT[toast.type]
- const wraps = toast.message.length > PILL_CHARS
- return (
- <div
- key={toast.id}
- role={toast.sticky ? 'button' : undefined}
- tabIndex={toast.sticky ? 0 : undefined}
- onClick={toast.sticky ? () => dismissToast(toast.id) : undefined}
- onKeyDown={toast.sticky ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); dismissToast(toast.id) } } : undefined}
- className={`flex max-w-full gap-2 bg-m-act px-4 py-2 text-[0.75rem] font-semibold text-m-actfg shadow-[0_10px_30px_-8px_rgba(0,0,0,.5)] ${
- wraps ? 'items-start rounded-2xl' : 'items-center rounded-full'
- } ${toast.sticky ? 'pointer-events-auto cursor-pointer' : ''} ${toast.removing ? 'm-toast-out' : 'm-toast-in'}`}
- >
- {dot && <MStatusDot status={dot} size={6} className={wraps ? 'mt-[0.45rem]' : ''} />}
- {/* No display utility next to line-clamp: Tailwind emits it later and kills the clamp. */}
- <span className={`min-w-0 ${wraps ? 'line-clamp-4 leading-[1.45]' : 'truncate'}`}>{toast.message}</span>
- </div>
- )
- })}
+ {toasts.map((toast) => (
+ <MToastPill key={toast.id} toast={toast} onDismiss={dismissToast} />
+ ))}
</div>
)
}
diff --git a/client/src/utils/dayOrder.ts b/client/src/utils/dayOrder.ts
index 0b6f465be..f02e3fad5 100644
--- a/client/src/utils/dayOrder.ts
+++ b/client/src/utils/dayOrder.ts
@@ -95,7 +95,7 @@ export const getAccommodationAnchors = (
const farthestFrom = (h: Accommodation): EdgeStop | undefined => {
if (!stops?.length) return undefined
const from = at(h)
- const far = stops.reduce((a, b) => (haversineKm(from, b) > haversineKm(from, a) ? b : a))
+ const far = stops.reduce((a, b) => (haversineKm(from, b) > haversineKm(from, a) ? b : a), stops[0])
return { isPlace: true, time: null, lat: far.lat, lng: far.lng }
}
const hasStops = !!stops?.length