import { mockProperties } from '../../mock-data/properties'

const propertyMap: Record<string, string> = Object.fromEntries(
  mockProperties.map(p => [p.id, p.title]),
)

export function propertyLabelFromId(id: string): string {
  return propertyMap[id] ?? id
}

export function formatInquiryDate(iso: string): string {
  const d = new Date(iso)
  const date = d.toLocaleDateString('de-CH', { day: '2-digit', month: '2-digit', year: 'numeric' })
  const time = d.toLocaleTimeString('de-CH', { hour: '2-digit', minute: '2-digit' })
  return `${date} · ${time}`
}

export function formatFileSize(bytes?: number): string {
  if (!bytes) return ''
  if (bytes < 1024) return `${bytes} B`
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
  return `${(bytes / 1024 / 1024).toFixed(1)} MB`
}
