web / lib/utils/event-detail
lib/utils/event-detail
Utility functions for extracting and formatting event detail data.
Pure helper functions used by the EventDetailContent component and its child components for data extraction, type coercion, and display formatting.
Interfaces
EventData
Type for event data object
Indexable
[key: string]: unknown
Properties
title?
optionaltitle:string
name?
optionalname:string
description?
optionaldescription:string
startDate?
optionalstartDate:string
endDate?
optionalendDate:string
city?
optionalcity:string
country?
optionalcountry:string
Functions
safeToString()
safeToString(
value):string
Safely convert an unknown value to a string, returning empty string for unsupported types
Parameters
value
unknown
Returns
string
getEventData()
getEventData(
event):EventData
Extract the data object from an event, handling non-object or array cases
Parameters
event
data
unknown
Returns
getEventTitle()
getEventTitle(
eventData):string
Get event title from data, falling back to name then “Untitled Event”
Parameters
eventData
Returns
string
getDatasetInfo()
getDatasetInfo(
dataset):{ name: string; id: number; }|null
Extract dataset name and ID from a dataset relation value
Parameters
dataset
unknown
Returns
{ name: string; id: number; } | null
formatDateRange()
formatDateRange(
startDate,endDate):string|null
Format start/end dates into a human-readable range string
Parameters
startDate
unknown
endDate
unknown
Returns
string | null
getLocationDisplay()
getLocationDisplay(
event,eventData):string|null
Build a location display string from event and data fields
Parameters
event
object | Record<string, unknown>
eventData
Returns
string | null
hasValidCoordinates()
hasValidCoordinates(
location):boolean
Check whether an event has valid (non-zero) coordinates
Parameters
location
{ latitude?: number \| null; longitude?: number \| null; } | null | undefined
Returns
boolean