Skip to content

Commit 2b345db

Browse files
committed
fix(admin): respect track timezone in map date label and align preview radius
- Render MapBlock date using the track's timezoneOffsetMinutes so cross-timezone viewers no longer see the previous day. - Drop the redundant rounded-sm wrapper around the InsertMapDialog preview so the figure's rounded-lg corners are no longer clipped.
1 parent 6d25ceb commit 2b345db

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

apps/admin/src/vendor/rich-editor/extensions/map/InsertMapDialog.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ function InsertMapDialog(props: InsertMapDialogProps) {
242242
</div>
243243
) : null}
244244
{previewUrl ? (
245-
<div className="rounded-sm border border-border bg-surface-inset">
246-
<MapBlockReadonly {...previewSlot} className="my-0" />
247-
</div>
245+
<MapBlockReadonly {...previewSlot} className="my-0" />
248246
) : null}
249247
</div>
250248
<div className="flex justify-end gap-2 border-t border-border px-5 py-4">

apps/admin/src/vendor/rich-editor/extensions/map/MapBlock.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,26 @@ export function MapBlock({
242242
if (!hasTrack && hasPois) return `${pois.length} places`
243243
return null
244244
}
245+
const tzOffsetMin = data.timezoneOffsetMinutes
246+
const useTrackTz = typeof tzOffsetMin === 'number'
247+
const target = useTrackTz
248+
? new Date(data.startTimeMs + tzOffsetMin * 60_000)
249+
: new Date(data.startTimeMs)
245250
try {
246251
return new Intl.DateTimeFormat(undefined, {
247252
dateStyle: 'long',
248-
}).format(new Date(data.startTimeMs))
253+
...(useTrackTz && { timeZone: 'UTC' }),
254+
}).format(target)
249255
} catch {
250-
return new Date(data.startTimeMs).toLocaleDateString()
256+
return target.toLocaleDateString()
251257
}
252-
}, [data?.startTimeMs, hasPois, hasTrack, pois.length])
258+
}, [
259+
data?.startTimeMs,
260+
data?.timezoneOffsetMinutes,
261+
hasPois,
262+
hasTrack,
263+
pois.length,
264+
])
253265

254266
const stopsCount = stops.length
255267
const hasSecondary = !!(

0 commit comments

Comments
 (0)