mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
feat: quality of life sweep from the feature discussions
Small requests from the discussions, each built end to end: planner and map (cycling mode, date first headings, clear a day, stay times per day, off-route stops, map lock, compact unplanned markers, pending stays, cable car, transit quick picks), places (location filter, category from OSM, open in maps, geo: link, image from an attachment, enrichment on file import, places near a pin, place name language, Amap first in China), lists and costs (packed counter, inherited sharing, Markdown to-dos, payment notes, bookings CSV, my plan PDF), sharing (unplanned places, travel only, without photos), journey (photo zoom, drafts, photo order, trip suggestion, day jump), atlas (region counter, region bucket list, places per country), vacay half company holidays, studio copy and paste plus the book's own layouts, and RESTORE_FROM_BACKUP for a first start restore.
This commit is contained in:
@@ -14,6 +14,7 @@ import DawarichIcon from '../../../components/shared/DawarichIcon'
|
||||
import DawarichAtlasDialog from '../../../components/Dawarich/DawarichAtlasDialog'
|
||||
import { useAddonStore } from '../../../store/addonStore'
|
||||
import { countryStatus } from '../../../pages/atlas/atlasModel'
|
||||
import AtlasCountryPlaces from '../../../components/Atlas/AtlasCountryPlaces'
|
||||
|
||||
const removeBtnCls = 'mt-4 w-full rounded-full bg-[rgba(214,39,59,.12)] py-[11px] text-center text-[0.8125rem] font-bold text-[color:var(--m-st-danger)]' // theme-lint-disable — fixed status-danger tint
|
||||
|
||||
@@ -191,8 +192,12 @@ export default function MAtlas() {
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-[1.0625rem] font-extrabold text-m-ink">{resolveName(selectedCountry)}</div>
|
||||
<div className="mt-[2px] font-geist text-[0.6875rem] text-m-muted">
|
||||
{countryDetail.places.length} {t('atlas.places')} · {countryDetail.trips.length} {t('atlas.trips')}
|
||||
<div className="mt-[4px] flex flex-wrap gap-1">
|
||||
{[[countryDetail.places.length, t('atlas.places')], [countryDetail.trips.length, t('atlas.trips')]].map(([n, label]) => (
|
||||
<span key={label} className="rounded-full bg-[color:var(--m-ic)] px-2 py-[1px] font-geist text-[0.625rem] font-bold tabular-nums text-m-muted">
|
||||
{n} {label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<MIconBtn variant="neutral" size={34} onClick={() => setDetailOpen(false)} ariaLabel={t('common.close')}>
|
||||
@@ -208,6 +213,12 @@ export default function MAtlas() {
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{/* Every place counted for the country, by trip (#2174). */}
|
||||
{countryDetail.places.length > 0 && (
|
||||
<div className="mt-4 max-h-[46vh] overflow-y-auto">
|
||||
<AtlasCountryPlaces variant="mobile" detail={countryDetail} onOpenTrip={id => navigate(`/trips/${id}`)} />
|
||||
</div>
|
||||
)}
|
||||
{countryDetail.manually_marked && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -157,6 +157,8 @@ export default function MAtlasCountryPopup({ atlas }: MAtlasCountryPopupProps) {
|
||||
name: confirmAction.name,
|
||||
country_code: confirmAction.code,
|
||||
target_date: targetDate,
|
||||
// A region wish hatches that region on the map, not the whole country (#1901).
|
||||
region_code: confirmAction.regionCode ?? null,
|
||||
})
|
||||
setBucketList((prev) => [r.data.item, ...prev])
|
||||
} catch (err) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import MSheet from '../../components/MSheet'
|
||||
import MCollCategoryPicker from './MCollCategoryPicker'
|
||||
import { STATUS_SPEC } from './collectionsMobileModel'
|
||||
import { CancelPill, Eyebrow, INPUT_CLS, PrimaryPill, SheetFooter, SheetHeader, TEXTAREA_CLS } from './MCollSheetKit'
|
||||
import { usePlaceLanguage } from '../../../hooks/usePlaceLanguage'
|
||||
|
||||
type MapsPlace = Record<string, unknown>
|
||||
const str = (v: unknown): string | undefined => (typeof v === 'string' && v ? v : undefined)
|
||||
@@ -36,6 +37,7 @@ interface MCollAddSheetProps {
|
||||
*/
|
||||
export default function MCollAddSheet({ open, collectionId, collectionName, lists, categories, onClose, onAdded, t }: MCollAddSheetProps) {
|
||||
const { language } = useTranslation()
|
||||
const placeLang = usePlaceLanguage()
|
||||
const toast = useToast()
|
||||
const [query, setQuery] = useState('')
|
||||
const [results, setResults] = useState<MapsPlace[]>([])
|
||||
@@ -69,7 +71,7 @@ export default function MCollAddSheet({ open, collectionId, collectionName, list
|
||||
if (!query.trim() || searching) return
|
||||
setSearching(true)
|
||||
try {
|
||||
const res = await mapsApi.search(query, language)
|
||||
const res = await mapsApi.search(query, placeLang)
|
||||
setResults((res.places as MapsPlace[]) || [])
|
||||
} catch (err) {
|
||||
toast.error(getApiErrorMessage(err, t('places.mapsSearchError')))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { localIsoDate } from '../../../utils/localDate'
|
||||
import { Camera, Plus, Image, Images, X, MapPin, Locate, Trash2, CheckCircle2, MinusCircle, ChevronUp, ChevronDown, EyeOff, Play } from 'lucide-react'
|
||||
import { Briefcase, Camera, Plus, Image, Images, X, MapPin, Locate, Trash2, CheckCircle2, MinusCircle, ChevronUp, ChevronDown, EyeOff, Play } from 'lucide-react'
|
||||
import MSheet from '../../components/MSheet'
|
||||
import MIconBtn from '../../components/MIconBtn'
|
||||
import MToggle from '../../components/MToggle'
|
||||
@@ -20,6 +20,9 @@ import { photoUrl, posterlessVideo, geoOnceErrorKey, isValidGeoPoint } from '../
|
||||
import JournalBody from '../../../components/Journey/JournalBody'
|
||||
import { ProviderPicker, type ProviderPhotoGroup } from '../../../components/Journey/JourneyDetailPageProviderPicker'
|
||||
import { journeyWeatherCategory, MOBILE_MOODS, MOBILE_WEATHERS } from './mobileJourneyMeta'
|
||||
import { useJourneyTripSuggestion } from '../../../components/Journey/useJourneyTripSuggestion'
|
||||
import { useEntryPhotoOrder } from '../../../components/Journey/useEntryPhotoOrder'
|
||||
import { usePlaceLanguage } from '../../../hooks/usePlaceLanguage'
|
||||
|
||||
const PRO_COLOR = '#2FA37A'
|
||||
const CON_COLOR = '#D6273B'
|
||||
@@ -87,6 +90,7 @@ export default function MJourneyEntrySheet({
|
||||
onClose, onSave, onUploadPhotos, onAddProviderPhotos, onDelete, onDone,
|
||||
}: MJourneyEntrySheetProps) {
|
||||
const { t, language } = useTranslation()
|
||||
const placeLang = usePlaceLanguage()
|
||||
const toast = useToast()
|
||||
// Which verdict row to hand the caret after the next render — see addVerdictRow.
|
||||
const verdictFocusRef = useRef<string | null>(null)
|
||||
@@ -105,11 +109,16 @@ export default function MJourneyEntrySheet({
|
||||
const [mood, setMood] = useState(entry.mood || '')
|
||||
const [weather, setWeather] = useState(entry.weather || '')
|
||||
const [statsExcluded, setStatsExcluded] = useState(entry.stats_excluded ?? false)
|
||||
// The trip this day belongs to, when the journey does not follow it yet (#2265).
|
||||
const tripSuggestion = useJourneyTripSuggestion(entry.journey_id, trips.map(tr => tr.trip_id), entryDate, !readOnly)
|
||||
const [isDraft, setIsDraft] = useState(entry.is_draft ?? false)
|
||||
const [pros, setPros] = useState<string[]>(entry.pros_cons?.pros ?? [])
|
||||
const [cons, setCons] = useState<string[]>(entry.pros_cons?.cons ?? [])
|
||||
const [tags, setTags] = useState<string[]>(entry.tags ?? [])
|
||||
const [tagInput, setTagInput] = useState('')
|
||||
const [photos, setPhotos] = useState<(JourneyPhoto | GalleryPhoto)[]>(entry.photos || [])
|
||||
// Sends a photo to the front in one request, the same way the desktop editor does (#824).
|
||||
const photoOrder = useEntryPhotoOrder(entry.id, photos, setPhotos)
|
||||
const [pendingFiles, setPendingFiles] = useState<File[]>([])
|
||||
const [pendingLinkIds, setPendingLinkIds] = useState<number[]>([])
|
||||
const [pendingProviderGroups, setPendingProviderGroups] = useState<PendingProviderGroup[]>([])
|
||||
@@ -195,7 +204,7 @@ export default function MJourneyEntrySheet({
|
||||
setLocationLng(pos.lng)
|
||||
|
||||
const [placeResult, weatherResult] = await Promise.allSettled([
|
||||
mapsApi.reverse(pos.lat, pos.lng, language),
|
||||
mapsApi.reverse(pos.lat, pos.lng, placeLang),
|
||||
weatherApi.getCurrent(pos.lat, pos.lng, language),
|
||||
])
|
||||
if (!active) return
|
||||
@@ -213,7 +222,7 @@ export default function MJourneyEntrySheet({
|
||||
})
|
||||
|
||||
return () => { active = false }
|
||||
}, [quickCapture, readOnly, entry.location_lat, entry.location_lng, entry.entry_date, t, language])
|
||||
}, [quickCapture, readOnly, entry.location_lat, entry.location_lng, entry.entry_date, t, language, placeLang])
|
||||
|
||||
const isDirty =
|
||||
title !== (entry.title || '') ||
|
||||
@@ -224,6 +233,7 @@ export default function MJourneyEntrySheet({
|
||||
mood !== (entry.mood || '') ||
|
||||
weather !== (entry.weather || '') ||
|
||||
statsExcluded !== (entry.stats_excluded ?? false) ||
|
||||
isDraft !== (entry.is_draft ?? false) ||
|
||||
pros.filter(p => p.trim()).join('\n') !== (entry.pros_cons?.pros ?? []).join('\n') ||
|
||||
cons.filter(c => c.trim()).join('\n') !== (entry.pros_cons?.cons ?? []).join('\n') ||
|
||||
tags.join('\n') !== (entry.tags ?? []).join('\n') ||
|
||||
@@ -271,6 +281,7 @@ export default function MJourneyEntrySheet({
|
||||
location_lat: locationLat,
|
||||
location_lng: locationLng,
|
||||
stats_excluded: offersStatsToggle ? statsExcluded : undefined,
|
||||
is_draft: isDraft,
|
||||
mood: mood || null,
|
||||
weather: weather || null,
|
||||
tags: tags.filter(tag => tag.trim()),
|
||||
@@ -339,7 +350,7 @@ export default function MJourneyEntrySheet({
|
||||
}
|
||||
locationTimerRef.current = setTimeout(async () => {
|
||||
try {
|
||||
const res = await mapsApi.search(query)
|
||||
const res = await mapsApi.search(query, placeLang)
|
||||
setLocationResults((res.places || []).slice(0, 6).map((p: { name: string; address?: string; lat: number | string; lng: number | string }) => ({
|
||||
name: p.name, address: p.address, lat: Number(p.lat), lng: Number(p.lng),
|
||||
})))
|
||||
@@ -366,7 +377,7 @@ export default function MJourneyEntrySheet({
|
||||
setLocationResults([])
|
||||
setShowLocationResults(false)
|
||||
try {
|
||||
const data = await mapsApi.reverse(pos.lat, pos.lng, language)
|
||||
const data = await mapsApi.reverse(pos.lat, pos.lng, placeLang)
|
||||
const name = data.name || data.address
|
||||
// Only replace the coordinate fallback — don't clobber a search
|
||||
// result the user may have picked while the reverse call was in flight.
|
||||
@@ -634,25 +645,7 @@ export default function MJourneyEntrySheet({
|
||||
{!readOnly && idx > 0 && photos.length > 1 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
// The PATCHes stay outside the updater — StrictMode invokes it
|
||||
// twice in dev and would send the whole batch a second time.
|
||||
const prevOrder = photos
|
||||
const next = [...photos]
|
||||
const [moved] = next.splice(idx, 1)
|
||||
next.unshift(moved)
|
||||
setPhotos(next)
|
||||
// Same as the desktop editor: the order is shared with the other
|
||||
// members, the share view and the PDF, so a run the server refused
|
||||
// outright goes back instead of passing for saved.
|
||||
void (async () => {
|
||||
const results = await Promise.allSettled(next.map((ph, i) => journeyApi.updatePhoto(ph.id, { sort_order: i })))
|
||||
const rejected = results.filter(r => r.status === 'rejected') as PromiseRejectedResult[]
|
||||
if (rejected.length === 0) return
|
||||
toast.error(getApiErrorMessage(rejected[0].reason, t('common.error')))
|
||||
if (rejected.length === results.length) setPhotos(prevOrder)
|
||||
})()
|
||||
}}
|
||||
onClick={() => photoOrder.makeFirst(idx)}
|
||||
className="absolute bottom-[3px] left-[3px] rounded-full bg-black/60 px-[6px] py-[1px] font-geist text-[0.5rem] font-bold text-white"
|
||||
>
|
||||
{t('journey.editor.photoFirst')}
|
||||
@@ -828,6 +821,20 @@ export default function MJourneyEntrySheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{tripSuggestion.trip && (
|
||||
<div className={`mt-3 flex items-center gap-3 px-3 py-[10px] ${fieldShell}`}>
|
||||
<Briefcase size={15} strokeWidth={2} className="flex-none text-m-muted" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[0.75rem] font-semibold text-m-ink [overflow-wrap:anywhere]">{tripSuggestion.trip.title}</div>
|
||||
<div className="mt-[2px] font-geist text-[0.65625rem] leading-[1.4] text-m-muted">{t('journey.editor.tripSuggestionHint')}</div>
|
||||
</div>
|
||||
<button type="button" onClick={() => void tripSuggestion.link()} disabled={tripSuggestion.linking}
|
||||
className="flex-none rounded-full bg-m-act px-3 py-[6px] text-[0.6875rem] font-bold text-m-actfg disabled:opacity-50">
|
||||
{t('journey.trips.linkTrip')}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Location */}
|
||||
<div className="relative mt-3">
|
||||
<div className={`${eyebrow} mb-[5px]`}>{t('journey.editor.location')}</div>
|
||||
@@ -897,6 +904,15 @@ export default function MJourneyEntrySheet({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Kept among the contributors until it is ready (#696). */}
|
||||
<div className={`mt-3 flex items-center gap-3 px-3 py-[10px] ${fieldShell}`}>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[0.75rem] font-semibold text-m-ink">{t('journey.editor.draft')}</div>
|
||||
<div className="mt-[2px] font-geist text-[0.65625rem] leading-[1.4] text-m-muted">{t('journey.editor.draftHint')}</div>
|
||||
</div>
|
||||
<MToggle checked={isDraft} onChange={setIsDraft} disabled={readOnly} ariaLabel={t('journey.editor.draft')} />
|
||||
</div>
|
||||
|
||||
{/* Mood */}
|
||||
{showMood && !captureOnly && <>
|
||||
<div className={`${eyebrow} mb-[6px] mt-3`}>{t('journey.editor.mood')}</div>
|
||||
|
||||
@@ -48,6 +48,13 @@ export default function MSettingsGeneral() {
|
||||
on: boolean
|
||||
value: (on: boolean) => boolean
|
||||
}[] = [
|
||||
{
|
||||
key: 'day_date_first',
|
||||
label: t('settings.dayDateFirst'),
|
||||
sub: t('settings.dayDateFirstHint'),
|
||||
on: settings.day_date_first === true,
|
||||
value: (on) => on,
|
||||
},
|
||||
{
|
||||
key: 'map_booking_labels',
|
||||
label: t('settings.bookingLabels'),
|
||||
@@ -62,6 +69,13 @@ export default function MSettingsGeneral() {
|
||||
on: settings.map_always_show_routes === true,
|
||||
value: (on) => on,
|
||||
},
|
||||
{
|
||||
key: 'map_compact_unplanned',
|
||||
label: t('settings.compactUnplanned'),
|
||||
sub: t('settings.compactUnplannedHint'),
|
||||
on: settings.map_compact_unplanned === true,
|
||||
value: (on) => on,
|
||||
},
|
||||
{
|
||||
key: 'map_poi_pill_enabled',
|
||||
label: t('settings.mapPoiPill'),
|
||||
|
||||
@@ -353,6 +353,7 @@ export default function MMapArea({ planner, shell }: MMapAreaProps) {
|
||||
dayPlaces={onStage ? undefined : planner.dayPlaces}
|
||||
route={stageMap ? stageMap.lines : planner.overviewActive ? planner.tripOverview.lines : planner.route}
|
||||
routeColors={stageMap ? stageMap.lineColors : planner.overviewActive ? planner.tripOverview.lineColors : undefined}
|
||||
routeWalking={stageMap || planner.overviewActive ? undefined : planner.routeWalking}
|
||||
accessLines={stageMap ? stageMap.accessLines : undefined}
|
||||
// A hit somebody tapped in the search sheet, a stop shown from its sheet, or the
|
||||
// stations the fuel search is offering take the camera while their day is on
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { useRef, useState, type MouseEvent } from 'react'
|
||||
import {
|
||||
ArrowRight, BedDouble, CalendarDays, CalendarRange, ChevronRight, Compass, LogIn, LogOut,
|
||||
MapPin, Pencil, PencilLine, Route, Ticket, TrainFront, Undo2,
|
||||
Car, Footprints, Zap, RotateCcw, TramFront,
|
||||
} from 'lucide-react'
|
||||
import { ArrowRight, BedDouble, CalendarDays, CalendarRange, ChevronRight, Compass, LogIn, LogOut, MapPin, Pencil, PencilLine, Route, Ticket, TrainFront, Undo2, RotateCcw, TramFront } from 'lucide-react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import { useContextMenu, ContextMenu } from '../../../../components/shared/ContextMenu'
|
||||
import MarkdownText from '../../../../components/shared/MarkdownText'
|
||||
import { fmtTransitDuration } from '../../../../components/Planner/transitDisplay'
|
||||
import { routeModeIcon } from '../../../../components/Planner/routeModes'
|
||||
import { formatTime } from '../../../../utils/formatters'
|
||||
import { useMPlanTimeline, type MPlanTimelineController } from './useMPlanTimeline'
|
||||
import { cityPillsForDay, weatherIconFor } from './planTimelineModel'
|
||||
@@ -46,12 +43,11 @@ export default function MPlanTimeline({ planner, shell }: MPlanTimelineProps) {
|
||||
const canEditPlaces = can('place_edit', trip)
|
||||
// Per-segment travel mode (#1281): tap a connector → pick the leg's mode.
|
||||
const legMenu = useContextMenu()
|
||||
const modeIcon = (key: string) => (key === 'walking' ? Footprints : key.startsWith('plugin:') ? Zap : Car)
|
||||
const openLegMenu = (e: MouseEvent, assignmentId: number, seg: RouteSegment) => {
|
||||
// Public transit sits under the road profiles, as on the desktop (#2398).
|
||||
const transitLeg = tl.transitLegFor(seg)
|
||||
legMenu.open(e, [
|
||||
...tl.routeModeOptions.map(o => ({ label: o.label, icon: modeIcon(o.key), onClick: () => tl.setLegMode(assignmentId, o.key) })),
|
||||
...tl.routeModeOptions.map(o => ({ label: o.label, icon: routeModeIcon(o.key), onClick: () => tl.setLegMode(assignmentId, o.key) })),
|
||||
...(transitLeg ? [{ label: t('transit.title'), icon: TramFront, onClick: () => tl.planTransitLeg(transitLeg) }] : []),
|
||||
{ divider: true },
|
||||
{ label: t('dayplan.transportMode.useDefault'), icon: RotateCcw, onClick: () => tl.setLegMode(assignmentId, null) },
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BedDouble, Car, ChevronDown, ChevronUp, Clock, Footprints, Pencil, Route, StickyNote, Ticket, X, Zap } from 'lucide-react'
|
||||
import { BedDouble, ChevronDown, ChevronUp, Clock, Footprints, Pencil, Route, StickyNote, Ticket, X, Zap } from 'lucide-react'
|
||||
import { routeModeIcon } from '../../../../components/Planner/routeModes'
|
||||
import type { ReactNode, MouseEvent, CSSProperties } from 'react'
|
||||
import PlaceAvatar from '../../../../components/shared/PlaceAvatar'
|
||||
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
|
||||
@@ -451,7 +452,7 @@ export function TransitRow({ res, transit, dayId, open, chrome, reorder, drag, o
|
||||
/** The connector line of a routed leg — the leg's own mode (#1281) picks icon and duration. */
|
||||
function TravelLine({ seg }: { seg: RouteSegment }) {
|
||||
const mode = seg.mode
|
||||
const Icon = mode === 'walking' ? Footprints : mode?.startsWith('plugin:') ? Zap : Car
|
||||
const Icon = routeModeIcon(mode)
|
||||
const durationText = seg.durationText ?? (mode === 'walking' ? seg.walkingText : seg.drivingText)
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -157,6 +157,8 @@ export function buildPlanRows(opts: {
|
||||
if (row.kind === 'place') {
|
||||
const place = row.assignment.place
|
||||
if (place?.lat == null || place?.lng == null) continue
|
||||
// Out of the route (#2532): the drive passes it by, so no leg starts or ends here.
|
||||
if (row.assignment.route_excluded) continue
|
||||
const at: [number, number] = [place.lat, place.lng]
|
||||
connect(prev, at)
|
||||
// The leg's mode is stored on its ORIGIN place assignment (#1281), so carry
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useTripStore } from '../../../../store/tripStore'
|
||||
import { useRouteCalculation } from '../../../../hooks/useRouteCalculation'
|
||||
import { assignmentsApi, reservationsApi, weatherApi } from '../../../../api/client'
|
||||
import { usePluginStore } from '../../../../store/pluginStore'
|
||||
import { useRouteModeOptions } from '../../../../components/Planner/routeModes'
|
||||
import { getDayBookendHotels } from '../../../../utils/dayOrder'
|
||||
import { getDisplayTimeForDay, getMergedItems, getTransportForDay, hasCarrierEndpointOnDay, isCarrierTransport } from '../../../../utils/dayMerge'
|
||||
import { dayCoMapsUrl, dayExportStops, dayGoogleMapsUrl, optimizeDayOrder, type DayCarrier } from '../lib/dayRoute'
|
||||
@@ -368,15 +368,7 @@ export function useMPlanTimeline(planner: TripPlanner) {
|
||||
: null
|
||||
|
||||
// ── Per-segment travel mode (#1281) ──
|
||||
const activePlugins = usePluginStore(s => s.plugins)
|
||||
const routeModeOptions = useMemo(() => {
|
||||
const opts: Array<{ key: string; label: string }> = [
|
||||
{ key: 'driving', label: t('mobileTrip.profileDriving') },
|
||||
{ key: 'walking', label: t('mobileTrip.profileWalking') },
|
||||
]
|
||||
for (const p of activePlugins) for (const prof of p.routeProfiles ?? []) opts.push({ key: `plugin:${p.id}/${prof.id}`, label: prof.label })
|
||||
return opts
|
||||
}, [activePlugins, t])
|
||||
const routeModeOptions = useRouteModeOptions()
|
||||
|
||||
// Set the mode of the leg leaving a stop — optimistic, then persisted; null clears
|
||||
// the override back to the day default. Sticky against the whole-day picker.
|
||||
|
||||
@@ -10,7 +10,7 @@ import { RtAutoRow, RtBookendRow, RtBookingChips, RtDryRow, RtLegRow, RtRideRow,
|
||||
import MBadge from '../../../components/MBadge'
|
||||
import MDancingTrek from '../../../components/MDancingTrek'
|
||||
import { formatDurationShort } from '../../../../components/Roadtrip/roadtripModel'
|
||||
import { getNavigationTargets } from '../../../../components/Planner/placeNavigation'
|
||||
import { navigationTargetLabel, getNavigationTargets } from '../../../../components/Planner/placeNavigation'
|
||||
import { useSettingsStore } from '../../../../store/settingsStore'
|
||||
import { formatDistance } from '../../../../utils/units'
|
||||
import { formatClockTime } from '../../../../utils/formatters'
|
||||
@@ -419,7 +419,7 @@ function UpNext({ planner, shell, rt, stageDayId, onOpen }: {
|
||||
className={`flex h-11 flex-1 items-center justify-center gap-[7px] rounded-full bg-m-act text-[0.8125rem] font-semibold text-m-actfg shadow-[0_10px_24px_-10px_rgba(0,0,0,.45)] ${targets.length ? '' : 'pointer-events-none opacity-40'}`}
|
||||
>
|
||||
<Navigation size={15} strokeWidth={2.2} aria-hidden="true" />
|
||||
{targets.length === 1 ? targets[0].label : t('inspector.navigation')}
|
||||
{targets.length === 1 ? navigationTargetLabel(targets[0], t) : t('inspector.navigation')}
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -15,7 +15,7 @@ import { formatDurationShort } from '../../../../components/Roadtrip/roadtripMod
|
||||
import { roadtripRows, stageOf, type StopRow } from '../../../../components/Roadtrip/roadtripRowModel'
|
||||
import { readStay, shownStay } from '../../../../components/Roadtrip/stayReading'
|
||||
import { STOP_KIND_BY_KEY } from '../../../../components/Roadtrip/stopKinds'
|
||||
import { getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation'
|
||||
import { navigationTargetLabel, getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation'
|
||||
import { NavigationMenu } from '../../../../components/shared/NavigationMenu'
|
||||
import { formatDistance } from '../../../../utils/units'
|
||||
import { Eyebrow, displayTime } from '../sheets/MTripSheetUi'
|
||||
@@ -411,7 +411,7 @@ export default function MRtStopSheet({ planner, shell }: MTripSheetsProps) {
|
||||
tileRef={navBtnRef}
|
||||
icon={<Navigation size={16} strokeWidth={2} />}
|
||||
label={t('inspector.navigation')}
|
||||
value={navTargets.length === 1 ? navTargets[0].label : undefined}
|
||||
value={navTargets.length === 1 ? navigationTargetLabel(navTargets[0], t) : undefined}
|
||||
onClick={openDirections}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { Check, FileDown } from 'lucide-react'
|
||||
import { placesApi } from '../../../../api/client'
|
||||
import { useAuthStore } from '../../../../store/authStore'
|
||||
import MToggle from '../../../components/MToggle'
|
||||
import { Eyebrow, FormSheetFooter } from './PlSheetChrome'
|
||||
import type { TripPlanner } from '../MTripShell'
|
||||
|
||||
@@ -37,6 +39,9 @@ export default function ImpFileStep({ planner, onBack, onDone }: ImpFileStepProp
|
||||
const [summary, setSummary] = useState<ImportSummary | null>(null)
|
||||
const [gpxOpts, setGpxOpts] = useState({ waypoints: true, routes: true, tracks: true })
|
||||
const [kmlOpts, setKmlOpts] = useState({ points: true, paths: true })
|
||||
// The Google pass the list import offers, for a file's points too (#2536).
|
||||
const canEnrich = useAuthStore(s => s.hasMapsKey)
|
||||
const [enrich, setEnrich] = useState(false)
|
||||
|
||||
const validateFile = (f: File): string | null => {
|
||||
const ext = f.name.toLowerCase().split('.').pop()
|
||||
@@ -77,12 +82,12 @@ export default function ImpFileStep({ planner, onBack, onDone }: ImpFileStepProp
|
||||
const ext = f.name.toLowerCase().split('.').pop()
|
||||
try {
|
||||
if (ext === 'gpx') {
|
||||
const result = await placesApi.importGpx(tripId, f, gpxOpts)
|
||||
const result = await placesApi.importGpx(tripId, f, { ...gpxOpts, enrich: enrich && canEnrich })
|
||||
gpxCreated += result.count ?? 0
|
||||
totalSkipped += result.skipped ?? 0
|
||||
if (result.places?.length > 0) gpxIds.push(...result.places.map((p: { id: number }) => p.id))
|
||||
} else {
|
||||
const result = await placesApi.importMapFile(tripId, f, kmlOpts)
|
||||
const result = await placesApi.importMapFile(tripId, f, { ...kmlOpts, enrich: enrich && canEnrich })
|
||||
kmlCreated += result.count ?? 0
|
||||
if (result.places?.length > 0) kmlIds.push(...result.places.map((p: { id: number }) => p.id))
|
||||
const s = result.summary as ImportSummary | undefined
|
||||
@@ -208,6 +213,16 @@ export default function ImpFileStep({ planner, onBack, onDone }: ImpFileStepProp
|
||||
/>
|
||||
)}
|
||||
|
||||
{canEnrich && ((isGpx && gpxOpts.waypoints) || (isKml && kmlOpts.points)) && (
|
||||
<div className="mt-3 flex items-start gap-3">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[0.78125rem] font-semibold text-m-ink">{t('places.enrichOnImport')}</div>
|
||||
<div className="mt-[2px] font-geist text-[0.65625rem] leading-[1.4] text-m-faint">{t('places.enrichOnImportFileHint')}</div>
|
||||
</div>
|
||||
<MToggle checked={enrich} onChange={setEnrich} ariaLabel={t('places.enrichOnImport')} className="mt-[2px]" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{summary && (
|
||||
<div className="mt-3 rounded-[13px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-3 py-[10px]">
|
||||
<div className="font-geist text-[0.71875rem] text-m-muted">
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import {
|
||||
CalendarDays, Car, Compass, Footprints, Hotel, MapPin, Pencil, Plus, RotateCcw,
|
||||
Route as RouteIcon, TramFront, Zap,
|
||||
} from 'lucide-react'
|
||||
import { CalendarDays, Compass, Eraser, Hotel, MapPin, Pencil, Plus, RotateCcw, Route as RouteIcon, TramFront } from 'lucide-react'
|
||||
import type { WeatherResult } from '@trek/shared'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import type { MTripSheetsProps } from '../MTripShell'
|
||||
import { useTranslation } from '../../../../i18n'
|
||||
import { weatherApi } from '../../../../api/client'
|
||||
import { useSettingsStore } from '../../../../store/settingsStore'
|
||||
import { usePluginStore } from '../../../../store/pluginStore'
|
||||
import { routeModeIcon, useRouteModeOptions } from '../../../../components/Planner/routeModes'
|
||||
import { dayHeadingParts } from '../../../../utils/dayLabel'
|
||||
import { stayDayTimes } from '../../../../components/Planner/stayDayTimes'
|
||||
import { useDayNotes } from '../../../../hooks/useDayNotes'
|
||||
import { RES_ICONS, getNoteIcon } from '../../../../components/Planner/DayPlanSidebar.constants'
|
||||
import { getDayBookendHotels, isDayInAccommodationRange } from '../../../../utils/dayOrder'
|
||||
@@ -45,24 +44,13 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
const canEditReservations = planner.can('reservation_edit', planner.trip)
|
||||
const tripHasDates = Boolean(planner.trip?.start_date && planner.trip?.end_date)
|
||||
|
||||
// Route-profile pills: the built-ins plus every profile an active routeProvider
|
||||
// plugin declared (same key format as the desktop picker, 'plugin:<id>/<profile>').
|
||||
const activePlugins = usePluginStore(s => s.plugins)
|
||||
const routeProfileOptions = useMemo(() => {
|
||||
const opts: Array<{ key: string; label: string }> = [
|
||||
{ key: 'driving', label: t('mobileTrip.profileDriving') },
|
||||
{ key: 'walking', label: t('mobileTrip.profileWalking') },
|
||||
]
|
||||
for (const p of activePlugins) {
|
||||
for (const prof of p.routeProfiles ?? []) opts.push({ key: `plugin:${p.id}/${prof.id}`, label: prof.label })
|
||||
}
|
||||
return opts
|
||||
}, [activePlugins, t])
|
||||
const routeProfileOptions = useRouteModeOptions()
|
||||
|
||||
const isFahrenheit = useSettingsStore(s => s.settings.temperature_unit) === 'fahrenheit'
|
||||
const timeFormat = useSettingsStore(s => s.settings.time_format) || '24h'
|
||||
const blurCodes = useSettingsStore(s => s.settings.blur_booking_codes)
|
||||
const optimizeFromAccommodation = useSettingsStore(s => s.settings.optimize_from_accommodation)
|
||||
const dateFirst = useSettingsStore(s => s.settings.day_date_first === true)
|
||||
|
||||
const dayAssignments = useMemo<Assignment[]>(() => {
|
||||
if (!day) return []
|
||||
@@ -240,6 +228,7 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
: null
|
||||
// A day_number of 0 is as unusable as a missing one — both fall back to the row position.
|
||||
const dayLabel = day?.title || t('planner.dayN', { n: day ? day.day_number || dayIndex + 1 : '?' })
|
||||
const heading = dayHeadingParts(dayLabel, formattedDate, dateFirst)
|
||||
const WeatherIcon = weatherIconFor(weather?.main)
|
||||
|
||||
const stayBadge = (acc: (typeof dayAccommodations)[number]) => {
|
||||
@@ -270,7 +259,7 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<span className="truncate">{dayLabel}</span>
|
||||
<span className="truncate">{heading.primary}</span>
|
||||
{canEditDays && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -283,7 +272,7 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
sub={formattedDate}
|
||||
sub={heading.secondary}
|
||||
onClose={shell.closeSheet}
|
||||
closeLabel={t('common.close')}
|
||||
/>
|
||||
@@ -346,7 +335,7 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
{routable && (
|
||||
<div className={`flex overflow-hidden rounded-full ${INNER_CLS}`}>
|
||||
{routeProfileOptions.map(p => {
|
||||
const ProfileIcon = p.key === 'driving' ? Car : p.key === 'walking' ? Footprints : Zap
|
||||
const ProfileIcon = routeModeIcon(p.key)
|
||||
const active = planner.routeProfile === p.key
|
||||
return (
|
||||
<button
|
||||
@@ -394,6 +383,16 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
{t('dayplan.optimize')}
|
||||
</button>
|
||||
)}
|
||||
{canEditDays && dayAssignments.length > 0 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => planner.handleClearDay(day.id)}
|
||||
className={`flex items-center gap-[5px] rounded-full px-3 py-[7px] text-[0.75rem] font-semibold text-m-ink ${INNER_CLS}`}
|
||||
>
|
||||
<Eraser size={13} strokeWidth={2} />
|
||||
{t('dayplan.clearDay')}
|
||||
</button>
|
||||
)}
|
||||
{canEditDays && tripHasDates && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -494,6 +493,10 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
<div className="flex flex-col gap-2">
|
||||
{dayAccommodations.map(acc => {
|
||||
const badge = stayBadge(acc)
|
||||
const times = stayDayTimes(acc, day.id)
|
||||
// The desk time carries the arrival or departure colour itself (#2393),
|
||||
// so the head keeps its room for the name and drops the badge.
|
||||
const badgeAtTime = times.checkIn || times.checkOut
|
||||
const linked = planner.reservations.find(r => String(r.accommodation_id ?? '') === String(acc.id))
|
||||
return (
|
||||
<div key={acc.id} className={`rounded-[16px] px-3 py-[11px] ${INNER_CLS}`}>
|
||||
@@ -523,9 +526,11 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
<span className={`flex-none rounded-full border px-[7px] py-[2px] text-[0.5625rem] font-bold uppercase tracking-[.05em] ${badge.cls}`}>
|
||||
{badge.label}
|
||||
</span>
|
||||
{!badgeAtTime && (
|
||||
<span className={`flex-none rounded-full border px-[7px] py-[2px] text-[0.5625rem] font-bold uppercase tracking-[.05em] ${badge.cls}`}>
|
||||
{badge.label}
|
||||
</span>
|
||||
)}
|
||||
{canEditDays && acc.place_id != null && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -537,16 +542,17 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{(acc.check_in || acc.check_out || acc.confirmation) && (
|
||||
{(badgeAtTime || acc.confirmation) && (
|
||||
<div className="mt-[10px] flex gap-[6px]">
|
||||
{acc.check_in && (
|
||||
{times.checkIn && acc.check_in && (
|
||||
<StatBox
|
||||
value={`${displayTime(acc.check_in, locale, timeFormat)}${acc.check_in_end ? ` – ${displayTime(acc.check_in_end, locale, timeFormat)}` : ''}`}
|
||||
label={t('day.checkIn')}
|
||||
labelTone="confirmed"
|
||||
/>
|
||||
)}
|
||||
{acc.check_out && (
|
||||
<StatBox value={displayTime(acc.check_out, locale, timeFormat)} label={t('day.checkOut')} />
|
||||
{times.checkOut && acc.check_out && (
|
||||
<StatBox value={displayTime(acc.check_out, locale, timeFormat)} label={t('day.checkOut')} labelTone="danger" />
|
||||
)}
|
||||
{acc.confirmation && (
|
||||
<StatBox value={acc.confirmation} label={t('day.confirmation')} blurred={blurCodes} />
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import { CalendarPlus, ChevronRight, FileDown, Share2 } from 'lucide-react'
|
||||
import { CalendarPlus, ChevronRight, FileDown, Share2, UserRound } from 'lucide-react'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import { IcsSubscribeModal } from '../../../../components/Planner/IcsSubscribeModal'
|
||||
import { useTripStore } from '../../../../store/tripStore'
|
||||
import { useSettingsStore } from '../../../../store/settingsStore'
|
||||
import { useRoadtripSettings } from '../../../../hooks/useRoadtripSettings'
|
||||
import { useTranslation } from '../../../../i18n'
|
||||
import { useAuthStore } from '../../../../store/authStore'
|
||||
import { hasPersonalPlan } from '../../../../components/PDF/pdfScope'
|
||||
import { INNER_CLS, TileHeader } from './MTripSheetUi'
|
||||
import type { MTripSheetsProps } from '../MTripShell'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
@@ -27,7 +29,9 @@ export default function MExportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
const open = shell.sheet?.id === 'export'
|
||||
const dayNotes = useTripStore(s => s.dayNotes)
|
||||
const [subscribeOpen, setSubscribeOpen] = useState(false)
|
||||
const [pdfBusy, setPdfBusy] = useState(false)
|
||||
const [pdfBusy, setPdfBusy] = useState<false | 'all' | 'mine'>(false)
|
||||
const myId = useAuthStore(s => s.user?.id)
|
||||
const offerMine = myId != null && hasPersonalPlan(planner.storedAssignments, planner.reservations)
|
||||
const [icsBusy, setIcsBusy] = useState(false)
|
||||
const [gpxBusy, setGpxBusy] = useState(false)
|
||||
// The subscription link reads the trip without an account, so it needs the
|
||||
@@ -35,12 +39,12 @@ export default function MExportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
// not: that is a file this member may already read.
|
||||
const canManageShare = planner.can('share_manage', planner.trip)
|
||||
|
||||
const exportPdf = async () => {
|
||||
const exportPdf = async (mine = false) => {
|
||||
if (!planner.trip || pdfBusy) return
|
||||
const flatNotes = Object.entries(dayNotes).flatMap(([dayId, notes]) =>
|
||||
notes.map(n => ({ ...n, day_id: Number(dayId) })),
|
||||
)
|
||||
setPdfBusy(true)
|
||||
setPdfBusy(mine ? 'mine' : 'all')
|
||||
try {
|
||||
// See DayPlanSidebarToolbar: loaded on demand, not with the trip.
|
||||
const { downloadTripPDF } = await import('../../../../components/PDF/TripPDF')
|
||||
@@ -57,6 +61,7 @@ export default function MExportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
timeFormat,
|
||||
distanceUnit,
|
||||
showServiceStops,
|
||||
onlyUserId: mine ? myId : undefined,
|
||||
})
|
||||
} catch (e) {
|
||||
planner.toast.error(`${t('dayplan.pdfError')}: ${e instanceof Error ? e.message : String(e)}`)
|
||||
@@ -130,10 +135,18 @@ export default function MExportSheet({ planner, shell }: MTripSheetsProps) {
|
||||
<div className="flex flex-col gap-2">
|
||||
<ExportRow
|
||||
icon={FileDown}
|
||||
title={pdfBusy ? t('common.loading') : t('dayplan.pdf')}
|
||||
title={pdfBusy === 'all' ? t('common.loading') : t('dayplan.pdf')}
|
||||
sub={t('dayplan.pdfTooltip')}
|
||||
onClick={() => void exportPdf()}
|
||||
/>
|
||||
{offerMine && (
|
||||
<ExportRow
|
||||
icon={UserRound}
|
||||
title={pdfBusy === 'mine' ? t('common.loading') : t('dayplan.pdfMine')}
|
||||
sub={t('dayplan.pdfMineSub')}
|
||||
onClick={() => void exportPdf(true)}
|
||||
/>
|
||||
)}
|
||||
<ExportRow
|
||||
icon={FileDown}
|
||||
title={icsBusy ? t('common.loading') : t('mobileTrip.icsDownload')}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo, useRef, useState } from 'react'
|
||||
import DawarichIcon from '../../../../components/shared/DawarichIcon'
|
||||
import {
|
||||
Bookmark, Camera, ChevronRight, ExternalLink, Loader2, Map as MapIcon, Navigation, Paperclip,
|
||||
Pencil, Phone, Plus, Route, Trash2, Upload, X,
|
||||
Pencil, Phone, Plus, Route, RouteOff, Trash2, Upload, X,
|
||||
} from 'lucide-react'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import type { MTripSheetsProps } from '../MTripShell'
|
||||
@@ -22,7 +22,7 @@ import { avatarSrc } from '../../../../utils/avatarSrc'
|
||||
import { safeHttpUrl } from '../../../../utils/safeUrl'
|
||||
import { openFile } from '../../../../utils/fileDownload'
|
||||
import { filesForPlace } from '../../../../utils/placeFiles'
|
||||
import { getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation'
|
||||
import { navigationTargetLabel, getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation'
|
||||
import { NavigationMenu } from '../../../../components/shared/NavigationMenu'
|
||||
import { getAssignmentReservations } from '../../../../utils/dayMerge'
|
||||
import type { Assignment, Day, Reservation, TripMember } from '../../../../types'
|
||||
@@ -402,6 +402,18 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
|
||||
className={`flex items-center gap-1 rounded-full py-1 pl-[10px] text-[0.75rem] font-semibold ${INNER_CLS} ${canEditDays ? 'pr-1' : 'pr-[10px]'}`}
|
||||
>
|
||||
{day.title || t('planner.dayN', { n: (day.day_number ?? planner.days.indexOf(day) + 1) || '?' })}
|
||||
{canEditDays && place.lat != null && place.lng != null && (
|
||||
// In or out of that day's route (#2532); the icon says which it is.
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => { planner.tripActions.setAssignmentRouteExcluded(planner.tripId, day.id, assignment.id, !assignment.route_excluded).catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))) }}
|
||||
aria-label={assignment.route_excluded ? t('dayplan.includeInRoute') : t('dayplan.excludeFromRoute')}
|
||||
aria-pressed={!!assignment.route_excluded}
|
||||
className={`flex h-[18px] w-[18px] items-center justify-center rounded-full ${assignment.route_excluded ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'}`}
|
||||
>
|
||||
<RouteOff size={10} strokeWidth={2.4} />
|
||||
</button>
|
||||
)}
|
||||
{canEditDays && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -609,7 +621,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
|
||||
<ActionCircle
|
||||
ref={navBtnRef}
|
||||
onClick={openDirections}
|
||||
label={navTargets.length === 1 ? navTargets[0].label : t('inspector.navigation')}
|
||||
label={navTargets.length === 1 ? navigationTargetLabel(navTargets[0], t) : t('inspector.navigation')}
|
||||
>
|
||||
<Navigation size={15} strokeWidth={2} />
|
||||
</ActionCircle>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Bike, Bus, Car, CarTaxiFront, Check, ChevronDown, ChevronUp, Plane, Plus, Route, Sailboat, Ship, Train, TrainFront, TramFront, Trash2, X } from 'lucide-react'
|
||||
import { Bike, Bus, Car, CarTaxiFront, Check, ChevronDown, ChevronUp, Plane, Plus, Route, Sailboat, CableCar, Ship, Train, TrainFront, TramFront, Trash2, X } from 'lucide-react'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import { useAddonStore } from '../../../../store/addonStore'
|
||||
import { useTranslation } from '../../../../i18n'
|
||||
@@ -30,7 +30,7 @@ export interface MTransportFormSheetProps {
|
||||
onOpenExpense: (req: BookingExpenseRequest) => void
|
||||
}
|
||||
|
||||
const TRANSPORT_TYPES = ['flight', 'train', 'bus', 'car', 'taxi', 'bicycle', 'cruise', 'ferry', 'transit', 'transport_other'] as const
|
||||
const TRANSPORT_TYPES = ['flight', 'train', 'bus', 'car', 'taxi', 'bicycle', 'cruise', 'ferry', 'cable_car', 'transit', 'transport_other'] as const
|
||||
type TransportType = typeof TRANSPORT_TYPES[number]
|
||||
|
||||
const TYPE_OPTIONS = [
|
||||
@@ -42,6 +42,7 @@ const TYPE_OPTIONS = [
|
||||
{ value: 'bicycle', labelKey: 'reservations.type.bicycle', Icon: Bike },
|
||||
{ value: 'cruise', labelKey: 'reservations.type.cruise', Icon: Ship },
|
||||
{ value: 'ferry', labelKey: 'reservations.type.ferry', Icon: Sailboat },
|
||||
{ value: 'cable_car', labelKey: 'reservations.type.cable_car', Icon: CableCar },
|
||||
{ value: 'transport_other', labelKey: 'reservations.type.transport_other', Icon: Route },
|
||||
]
|
||||
|
||||
|
||||
@@ -62,10 +62,17 @@ interface StatBoxProps {
|
||||
label: ReactNode
|
||||
blurred?: boolean
|
||||
onClick?: () => void
|
||||
/** Colours the label, so a check-in or check-out time carries its own state. */
|
||||
labelTone?: 'confirmed' | 'danger'
|
||||
}
|
||||
|
||||
const LABEL_TONE: Record<NonNullable<StatBoxProps['labelTone']>, string> = {
|
||||
confirmed: 'font-bold uppercase tracking-[.05em] text-[color:var(--m-st-confirmed)]',
|
||||
danger: 'font-bold uppercase tracking-[.05em] text-[color:var(--m-st-danger)]',
|
||||
}
|
||||
|
||||
/** Small stat box (check-in / times / code): value 700 tabular over a faint Geist label. */
|
||||
export function StatBox({ value, label, blurred = false, onClick }: StatBoxProps) {
|
||||
export function StatBox({ value, label, blurred = false, onClick, labelTone }: StatBoxProps) {
|
||||
const box = 'min-w-0 flex-1 rounded-[10px] bg-[color:var(--m-ic)] px-[9px] py-[7px] text-center'
|
||||
const inner = (
|
||||
<>
|
||||
@@ -74,7 +81,7 @@ export function StatBox({ value, label, blurred = false, onClick }: StatBoxProps
|
||||
>
|
||||
{value}
|
||||
</div>
|
||||
<div className="truncate font-geist text-[0.5625rem] text-m-faint">{label}</div>
|
||||
<div className={`truncate font-geist text-[0.5625rem] ${labelTone ? LABEL_TONE[labelTone] : 'text-m-faint'}`}>{label}</div>
|
||||
</>
|
||||
)
|
||||
// A tappable stat is a real button — value and label give it its name. Without
|
||||
|
||||
@@ -206,6 +206,18 @@ export default function MTripSheets({ planner, shell }: MTripSheetsProps) {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Clear-day confirm behind the day sheet's "Clear day" (#2470). */}
|
||||
<MConfirmSheet
|
||||
open={planner.clearDayId != null}
|
||||
onClose={planner.cancelClearDay}
|
||||
title={planner.clearDayTitle}
|
||||
message={t('dayplan.clearDayBody')}
|
||||
confirmLabel={t('dayplan.clearDay')}
|
||||
cancelLabel={t('common.cancel')}
|
||||
danger
|
||||
onConfirm={() => { void planner.confirmClearDay() }}
|
||||
/>
|
||||
|
||||
{/* Delete-day confirm behind the days sheet's delete buttons. Mounted
|
||||
last, so it opens over that sheet; the list of what goes with the day
|
||||
comes ready made from the planner, the same one the desktop shows. */}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { pointFromBox } from '../../../../hooks/useLocationBias'
|
||||
import { usePlaceSuggestions } from '../../../../hooks/usePlaceSuggestions'
|
||||
import { FIELD_CLS } from './PlSheetChrome'
|
||||
import type { TripPlanner } from '../MTripShell'
|
||||
import { usePlaceLanguage } from '../../../../hooks/usePlaceLanguage'
|
||||
|
||||
/** Fields a search pick can contribute to the place form. */
|
||||
export interface PlSearchPick {
|
||||
@@ -92,7 +93,9 @@ function placeToPick(place: MapsPlace): PlSearchPick {
|
||||
* detection — the mobile counterpart of PlaceFormModal's search block.
|
||||
*/
|
||||
export default function PlPlaceSearch({ planner, locationBias, onPick, onResolvingChange }: PlPlaceSearchProps) {
|
||||
const { t, language, toast } = planner
|
||||
const { t, toast } = planner
|
||||
// Place names in the language the user picked for them, the app's otherwise (#1799).
|
||||
const language = usePlaceLanguage()
|
||||
const [query, setQuery] = useState('')
|
||||
const [results, setResults] = useState<MapsPlace[]>([])
|
||||
const [suggestions, setSuggestions] = useState<Suggestion[]>([])
|
||||
|
||||
@@ -15,7 +15,7 @@ import { budgetApi } from '../../../../api/client'
|
||||
import MCostSheet from '../sheets/MCostSheet'
|
||||
import { ReceiptPreviewModal } from '../../../../components/Budget/ReceiptPreviewModal'
|
||||
import { useFreezeMissingRates } from '../../../../components/Budget/useFreezeMissingRates'
|
||||
import { finalBudgetFor, finalBudgetSources, paidByUser, readUserNote, settlementDate } from '../../../../components/Budget/CostsPanel.helpers'
|
||||
import { finalBudgetFor, finalBudgetSources, NOTE_MAX, paidByUser, readUserNote, settlementDate } from '../../../../components/Budget/CostsPanel.helpers'
|
||||
import { catMeta, COST_CAT_META } from '../../../../components/Budget/costsCategories'
|
||||
import CustomSelect from '../../../../components/shared/CustomSelect'
|
||||
import { CustomDatePicker } from '../../../../components/shared/CustomDateTimePicker'
|
||||
@@ -24,7 +24,7 @@ import { localToday } from '../../../../components/Planner/today'
|
||||
import MConfirmSheet from '../../settings/MConfirmSheet'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import MChip from '../../../components/MChip'
|
||||
import { Eyebrow, FIELD_CLS, FormSheetFooter, FormSheetHeader } from '../sheets/PlSheetChrome'
|
||||
import { Eyebrow, FIELD_AREA_CLS, FIELD_CLS, FormSheetFooter, FormSheetHeader } from '../sheets/PlSheetChrome'
|
||||
import { CountPill, TabScroller } from './tabChrome'
|
||||
import { STATUS_COLOR, type MTabScreenProps } from './tabModel'
|
||||
import {
|
||||
@@ -635,9 +635,6 @@ function ExpenseRow({ item, ctx, base, locale, t, canEdit, onEdit, onDelete, onT
|
||||
const borderColor = tint(meta.color, 0.55)
|
||||
const members = item.members || []
|
||||
const note = readUserNote(item)
|
||||
// A phone row has no width to spare for a note, so it stays folded away and
|
||||
// the card itself is the handle — no extra control, no extra height.
|
||||
const [noteOpen, setNoteOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="mt-2 flex items-center gap-[6px]">
|
||||
@@ -709,24 +706,7 @@ function ExpenseRow({ item, ctx, base, locale, t, canEdit, onEdit, onDelete, onT
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{note && (
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={noteOpen}
|
||||
onClick={() => setNoteOpen(v => !v)}
|
||||
className="mt-[7px] flex w-full items-center gap-[7px] rounded-xl bg-[color:var(--m-ic)] px-[9px] py-[6px] text-left"
|
||||
>
|
||||
<StickyNote size={11} strokeWidth={2} className="flex-none text-m-faint" />
|
||||
<span className={`min-w-0 flex-1 text-[0.6875rem] leading-[1.5] text-m-muted ${noteOpen ? 'whitespace-pre-wrap [overflow-wrap:anywhere]' : 'truncate'}`}>
|
||||
{note}
|
||||
</span>
|
||||
<ChevronDown
|
||||
size={12}
|
||||
strokeWidth={2}
|
||||
className={`flex-none text-m-faint transition-transform duration-200 ${noteOpen ? 'rotate-180' : ''}`}
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
{note && <RowNote note={note} />}
|
||||
</div>
|
||||
|
||||
{canEdit && (
|
||||
@@ -743,6 +723,32 @@ function ExpenseRow({ item, ctx, base, locale, t, canEdit, onEdit, onDelete, onT
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A row's note, folded to one line until tapped: a phone row has no width to
|
||||
* spare for it. Expenses and payments (#2340) share it.
|
||||
*/
|
||||
function RowNote({ note }: { note: string }) {
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen(v => !v)}
|
||||
className="mt-[7px] flex w-full items-center gap-[7px] rounded-xl bg-[color:var(--m-ic)] px-[9px] py-[6px] text-left"
|
||||
>
|
||||
<StickyNote size={11} strokeWidth={2} className="flex-none text-m-faint" />
|
||||
<span className={`min-w-0 flex-1 text-[0.6875rem] leading-[1.5] text-m-muted ${open ? 'whitespace-pre-wrap [overflow-wrap:anywhere]' : 'truncate'}`}>
|
||||
{note}
|
||||
</span>
|
||||
<ChevronDown
|
||||
size={12}
|
||||
strokeWidth={2}
|
||||
className={`flex-none text-m-faint transition-transform duration-200 ${open ? 'rotate-180' : ''}`}
|
||||
/>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A recorded settle-up payment mixed into the day-grouped ledger (spec 03
|
||||
* §3.7 desktop parity — see `CostsPanel.tsx`'s `SettlementRow`). Edit opens
|
||||
@@ -786,6 +792,7 @@ function PaymentRow({ settlement, ctx, base, locale, t, personName, canEdit, onE
|
||||
{formatMoney(amount, base, locale)}
|
||||
</span>
|
||||
</div>
|
||||
{settlement.note && <RowNote note={settlement.note} />}
|
||||
</div>
|
||||
|
||||
{canEdit && (
|
||||
@@ -905,6 +912,7 @@ function AddPaymentSheet({ open, editing, onClose, tripId, base, tripCurrency, p
|
||||
const [amount, setAmount] = useState('')
|
||||
const [currency, setCurrency] = useState(base)
|
||||
const [day, setDay] = useState(localToday())
|
||||
const [note, setNote] = useState('')
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -915,6 +923,7 @@ function AddPaymentSheet({ open, editing, onClose, tripId, base, tripCurrency, p
|
||||
setAmount(editing ? amountToInputString(editing.amount, cur) : '')
|
||||
setCurrency(cur)
|
||||
setDay(editing ? settlementDate(editing) : localToday())
|
||||
setNote(editing?.note || '')
|
||||
setSaving(false)
|
||||
}, [open, editing, me, base, people])
|
||||
|
||||
@@ -924,7 +933,7 @@ function AddPaymentSheet({ open, editing, onClose, tripId, base, tripCurrency, p
|
||||
const save = async () => {
|
||||
if (!valid || saving) return
|
||||
setSaving(true)
|
||||
const data = withFallbackFx({ from_user_id: fromId, to_user_id: toId, amount: amt, currency, settled_at: day }, tripCurrency)
|
||||
const data = withFallbackFx({ from_user_id: fromId, to_user_id: toId, amount: amt, currency, settled_at: day, note: note.trim() || null }, tripCurrency)
|
||||
try {
|
||||
if (editing) await budgetApi.updateSettlement(tripId, editing.id, data)
|
||||
else await budgetApi.createSettlement(tripId, data)
|
||||
@@ -985,6 +994,16 @@ function AddPaymentSheet({ open, editing, onClose, tripId, base, tripCurrency, p
|
||||
<CustomDatePicker value={day} onChange={setDay} style={{ width: '100%' }} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Eyebrow className="mb-[6px] mt-[14px] uppercase">{t('costs.note')}</Eyebrow>
|
||||
<textarea
|
||||
value={note}
|
||||
onChange={e => setNote(e.target.value)}
|
||||
rows={2}
|
||||
maxLength={NOTE_MAX}
|
||||
placeholder={t('costs.paymentNotePlaceholder')}
|
||||
className={FIELD_AREA_CLS}
|
||||
/>
|
||||
</div>
|
||||
<FormSheetFooter onCancel={onClose} cancelLabel={t('common.cancel')} onSubmit={save} submitLabel={editing ? t('common.save') : t('costs.addPayment')} submitDisabled={!valid || saving} />
|
||||
</MSheet>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState, useCallback } from 'react'
|
||||
import type { LucideIcon } from 'lucide-react'
|
||||
import {
|
||||
Briefcase, Check, CheckCheck, ChevronDown, ChevronUp, HandHelping,
|
||||
Briefcase, Check, CheckCheck, ChevronDown, ChevronUp, HandHelping, Minus,
|
||||
Download, FileSpreadsheet, FileText, LayoutTemplate, MoreHorizontal, Package, Pencil, Plus, Printer, RotateCcw, Save as SaveIcon,
|
||||
Trash2, UserPlus, UserRound,
|
||||
} from 'lucide-react'
|
||||
@@ -18,7 +18,7 @@ import type { TripPlanner } from '../MTripShell'
|
||||
import MConfirmSheet from '../../settings/MConfirmSheet'
|
||||
import { FIELD_CLS } from '../sheets/PlSheetChrome'
|
||||
import { TabScroller } from './tabChrome'
|
||||
import { katColor } from '../../../../components/Packing/packingListPanel.helpers'
|
||||
import { katColor, newItemSharing, packedOf } from '../../../../components/Packing/packingListPanel.helpers'
|
||||
import { BAG_COLORS, PACKING_PLACEHOLDER_NAME } from '../../../../components/Packing/packingListPanel.constants'
|
||||
import {
|
||||
formatWeight, groupPackingItems, isLastCustomItemInCategory, isPackingPlaceholder,
|
||||
@@ -121,7 +121,8 @@ export default function MPackingListTab({ planner }: { planner: TripPlanner }) {
|
||||
} else {
|
||||
await tripActions.addPackingItem(
|
||||
tripId,
|
||||
{ name, category, visibility: view === 'personal' ? 'personal' : 'common' } as Parameters<typeof tripActions.addPackingItem>[1],
|
||||
// In "my list", shared the way the category's own items all are (#2241).
|
||||
{ name, category, ...newItemSharing(items, category, view, currentUserId) } as Parameters<typeof tripActions.addPackingItem>[1],
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
@@ -827,6 +828,10 @@ function PackingItemRow({ item, planner, currentUserId, editMode, canEdit, bagTr
|
||||
const ownerAvatarUrl = ownerMember?.avatar_url ?? (item.owner_id === me?.id ? me?.avatar_url ?? null : null)
|
||||
|
||||
const toggle = () => tripActions.togglePackingItem(tripId, item.id, !item.checked)
|
||||
// Multi-piece items count their pieces into the bag (#2296).
|
||||
const quantity = item.quantity || 1
|
||||
const packed = packedOf(item)
|
||||
const partlyPacked = !item.checked && packed > 0
|
||||
|
||||
const assignBag = async (bagId: number | null) => {
|
||||
setBagPickerOpen(false)
|
||||
@@ -850,7 +855,7 @@ function PackingItemRow({ item, planner, currentUserId, editMode, canEdit, bagTr
|
||||
aria-label={item.name}
|
||||
aria-pressed={!!item.checked}
|
||||
className={`flex h-[22px] w-[22px] flex-none items-center justify-center rounded-[7px] border-[1.5px] ${
|
||||
item.checked ? 'border-m-act bg-m-act text-m-actfg' : 'border-[color:var(--m-rowbr)] text-transparent'
|
||||
item.checked ? 'border-m-act bg-m-act text-m-actfg' : partlyPacked ? 'border-m-act text-transparent' : 'border-[color:var(--m-rowbr)] text-transparent'
|
||||
}`}
|
||||
>
|
||||
<Check size={12} strokeWidth={3} />
|
||||
@@ -893,11 +898,27 @@ function PackingItemRow({ item, planner, currentUserId, editMode, canEdit, bagTr
|
||||
</span>
|
||||
)}
|
||||
|
||||
{(item.quantity || 1) > 1 && (
|
||||
<span className="flex-none rounded-full bg-[color:var(--m-ic)] px-2 py-[2px] font-geist text-[0.625rem] font-bold tabular-nums text-m-muted">
|
||||
{item.quantity}×
|
||||
{quantity > 1 && (canEdit && !isPlaceholder ? (
|
||||
<span
|
||||
role="group"
|
||||
aria-label={t('packing.packedCount', { packed, total: quantity })}
|
||||
className={`flex flex-none items-center rounded-full font-geist text-[0.625rem] font-bold tabular-nums ${partlyPacked ? 'bg-[color:color-mix(in_srgb,var(--m-act)_14%,transparent)] text-m-ink' : 'bg-[color:var(--m-ic)] text-m-muted'}`}
|
||||
>
|
||||
<button type="button" aria-label={t('packing.packedLess')} disabled={packed <= 0} onClick={() => tripActions.setPackedCount(tripId, item.id, packed - 1)}
|
||||
className="flex h-[22px] w-[22px] items-center justify-center disabled:opacity-30">
|
||||
<Minus size={11} strokeWidth={2.6} />
|
||||
</button>
|
||||
<span className="min-w-[26px] text-center">{packed}/{quantity}</span>
|
||||
<button type="button" aria-label={t('packing.packedMore')} disabled={packed >= quantity} onClick={() => tripActions.setPackedCount(tripId, item.id, packed + 1)}
|
||||
className="flex h-[22px] w-[22px] items-center justify-center disabled:opacity-30">
|
||||
<Plus size={11} strokeWidth={2.6} />
|
||||
</button>
|
||||
</span>
|
||||
)}
|
||||
) : (
|
||||
<span className="flex-none rounded-full bg-[color:var(--m-ic)] px-2 py-[2px] font-geist text-[0.625rem] font-bold tabular-nums text-m-muted">
|
||||
{partlyPacked ? `${packed}/${quantity}` : `${quantity}×`}
|
||||
</span>
|
||||
))}
|
||||
|
||||
{/* A weight nobody entered is not worth a column: "— g" on every row
|
||||
cost as much width as a real value (#1525). */}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Check, Flag, Plus, User } from 'lucide-react'
|
||||
import type { TodoCreateItemRequest, TodoUpdateItemRequest } from '@trek/shared'
|
||||
import MSheet from '../../../components/MSheet'
|
||||
import { CustomDatePicker } from '../../../../components/shared/CustomDateTimePicker'
|
||||
import MarkdownEditable from '../../../../components/shared/MarkdownEditable'
|
||||
import { Eyebrow, FIELD_AREA_CLS, FIELD_CLS, FormSheetFooter, FormSheetHeader } from '../sheets/PlSheetChrome'
|
||||
import { avatarSrc } from '../../../../utils/avatarSrc'
|
||||
import type { TodoItem, TripMember } from '../../../../types'
|
||||
@@ -133,12 +134,21 @@ export default function MTaskSheet({ planner, open, itemId, categories, members,
|
||||
/>
|
||||
|
||||
<Eyebrow className="mb-[5px] mt-3 uppercase">{t('todo.detail.description')}</Eyebrow>
|
||||
<textarea
|
||||
<MarkdownEditable
|
||||
value={description}
|
||||
onChange={e => setDescription(e.target.value)}
|
||||
rows={3}
|
||||
placeholder={t('todo.descriptionPlaceholder')}
|
||||
className={FIELD_AREA_CLS}
|
||||
canEdit
|
||||
editLabel={t('todo.editDescription')}
|
||||
className="rounded-[12px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-3 py-[10px] font-geist text-[0.78125rem] leading-[1.5] text-m-ink [overflow-wrap:break-word]"
|
||||
renderEditor={editor => (
|
||||
<textarea
|
||||
value={description}
|
||||
onChange={e => setDescription(e.target.value)}
|
||||
rows={3}
|
||||
{...editor}
|
||||
placeholder={t('todo.descriptionPlaceholder')}
|
||||
className={FIELD_AREA_CLS}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('todo.detail.priority')}</Eyebrow>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
sortTodoRows, todoCategories, todoCategoryOpenCount, todoCounts, type TodoSmartFilter,
|
||||
} from './listsModel'
|
||||
import MTaskSheet from './MTaskSheet'
|
||||
import MarkdownText from '../../../../components/shared/MarkdownText'
|
||||
|
||||
const BUILTIN_FILTERS: TodoSmartFilter[] = ['all', 'my', 'overdue', 'done']
|
||||
|
||||
@@ -219,7 +220,7 @@ function TaskCard({ item, members, today, onToggle, onOpen }: {
|
||||
{item.name}
|
||||
</div>
|
||||
{item.description && (
|
||||
<div className="mt-[1px] truncate font-geist text-[0.625rem] text-m-faint">{item.description}</div>
|
||||
<MarkdownText clamp className="mt-[1px] font-geist text-[0.625rem] text-m-faint">{item.description}</MarkdownText>
|
||||
)}
|
||||
{(item.priority > 0 || item.due_date || assignee) && (
|
||||
<div className="mt-[5px] flex flex-wrap items-center gap-[5px]">
|
||||
|
||||
@@ -108,6 +108,8 @@ export interface CostsSettlement {
|
||||
// The day the transfer actually happened; editable, unlike created_at (when it
|
||||
// was recorded). Null/absent on rows predating this field.
|
||||
settled_at?: string | null
|
||||
/** A free-text note on the payment (#2340). */
|
||||
note?: string | null
|
||||
}
|
||||
|
||||
export interface CostsSettlementResponse {
|
||||
|
||||
@@ -18,6 +18,7 @@ export const TRANSPORT_TYPE_COLOR: Record<string, string> = {
|
||||
bicycle: '#84cc16',
|
||||
cruise: '#0ea5e9',
|
||||
ferry: '#0d9488',
|
||||
cable_car: '#dc2626',
|
||||
transit: '#7c3aed',
|
||||
transport_other: '#6b7280',
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { isWeekend } from '../../../components/Vacay/holidays'
|
||||
import { currentPeriodYear, inGridWindow, windowMonths } from '../../../vacay/yearWindow'
|
||||
import { FALLBACK_PERSON_COLOR, localDateStr, type DayVisualContext } from './vacayDayModel'
|
||||
import { getApiErrorMessage, type Trip } from '../../../types'
|
||||
import { companyHolidaySets, leaveFractionFor } from '../../../components/Vacay/companyHolidays'
|
||||
|
||||
export type MVacayView = 'grid' | 'edit'
|
||||
export type MVacayMode = 'vacation' | 'company'
|
||||
@@ -94,7 +95,8 @@ export function useMVacay() {
|
||||
[plan?.weekend_days],
|
||||
)
|
||||
|
||||
const companyHolidaySet = useMemo(() => new Set(companyHolidays.map(h => h.date)), [companyHolidays])
|
||||
// Whole company holidays close a day to leave, half ones leave half of it (#2439).
|
||||
const { full: companyHolidaySet, half: companyHalfSet } = useMemo(() => companyHolidaySets(companyHolidays), [companyHolidays])
|
||||
|
||||
const entryMap = useMemo(() => {
|
||||
const map: DayVisualContext['entryMap'] = {}
|
||||
@@ -125,8 +127,8 @@ export function useMVacay() {
|
||||
}, [sharedCalendars])
|
||||
|
||||
const dayCtx = useMemo<DayVisualContext>(() => ({
|
||||
todayStr, entryMap, companyHolidaySet, companyHolidaysEnabled, holidays, weekendDays, sharedMap,
|
||||
}), [todayStr, entryMap, companyHolidaySet, companyHolidaysEnabled, holidays, weekendDays, sharedMap])
|
||||
todayStr, entryMap, companyHolidaySet, companyHalfSet, companyHolidaysEnabled, holidays, weekendDays, sharedMap,
|
||||
}), [todayStr, entryMap, companyHolidaySet, companyHalfSet, companyHolidaysEnabled, holidays, weekendDays, sharedMap])
|
||||
|
||||
// The twelve months the window spans, in display order — Jan–Dec for a calendar
|
||||
// year, Jul–Jun for a fiscal one starting in July (#737).
|
||||
@@ -193,7 +195,7 @@ export function useMVacay() {
|
||||
}
|
||||
if (mode === 'company') {
|
||||
if (!companyHolidaysEnabled) return
|
||||
await toggleCompanyHoliday(dateStr)
|
||||
await toggleCompanyHoliday(dateStr, halfDay ? 0.5 : 1)
|
||||
return
|
||||
}
|
||||
if (blockWeekends && isWeekend(dateStr, weekendDays)) {
|
||||
@@ -207,8 +209,9 @@ export function useMVacay() {
|
||||
return
|
||||
}
|
||||
if (companyHolidaysEnabled && companyHolidaySet.has(dateStr)) return
|
||||
await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1, compDay ? 'comp' : 'vacation')
|
||||
}, [view, months, openMonthSlot, mode, halfDay, compDay, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, toggleEntry, toggleCompanyHoliday, selectedUserId, currentUser?.id, entryMap])
|
||||
const fraction = companyHolidaysEnabled ? leaveFractionFor(dateStr, companyHalfSet, halfDay ? 0.5 : 1) : (halfDay ? 0.5 : 1)
|
||||
await toggleEntry(dateStr, selectedUserId || undefined, fraction, compDay ? 'comp' : 'vacation')
|
||||
}, [view, months, openMonthSlot, mode, halfDay, compDay, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, companyHalfSet, toggleEntry, toggleCompanyHoliday, selectedUserId, currentUser?.id, entryMap])
|
||||
|
||||
// Entitlement stepper: never below what is already used this year
|
||||
// (carried-over days cover the difference when used > entitlement).
|
||||
|
||||
@@ -27,6 +27,8 @@ export interface DayVisualContext {
|
||||
todayStr: string
|
||||
entryMap: Record<string, VacayEntry[]>
|
||||
companyHolidaySet: Set<string>
|
||||
/** Half company holidays (#2439): half-filled, still open for half a day of leave. */
|
||||
companyHalfSet?: Set<string>
|
||||
companyHolidaysEnabled: boolean
|
||||
holidays: HolidaysMap
|
||||
weekendDays: number[]
|
||||
@@ -125,6 +127,9 @@ function baseDayVisual(dateStr: string, dayOfWeek: number, ctx: DayVisualContext
|
||||
if (entries.some(e => (e.fraction ?? 1) === 0.5)) visual.half = true
|
||||
return withSchool(visual)
|
||||
}
|
||||
if (ctx.companyHolidaysEnabled && ctx.companyHalfSet?.has(dateStr)) {
|
||||
return withSchool({ background: 'linear-gradient(135deg, #F5D9A6 50%, transparent 50%)', numColor: '#8A5A00' })
|
||||
}
|
||||
if (publicHoliday) {
|
||||
return withSchool({ background: publicHoliday.color, numColor: holidayInk(publicHoliday.color) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user