export function formatEmpty(value?: string | number | null) {
  if (value === null || value === undefined || value === '') return '-'
  return String(value)
}

export function formatEnumLabel(value?: string | number | null) {
  if (value === null || value === undefined || value === '') return '-'

  return String(value)
    .trim()
    .split(/[_\s.-]+/)
    .filter(Boolean)
    .map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
    .join(' ')
}

export function formatBoolean(value?: boolean | null) {
  if (value === null || value === undefined) return '-'
  return value ? 'Yes' : 'No'
}

export function formatDateTime(
  value?: string | number | Date | null,
  locale = 'en-US'
) {
  if (value === null || value === undefined || value === '') return '-'

  const date = value instanceof Date ? value : new Date(value)
  if (Number.isNaN(date.getTime())) return String(value)

  return new Intl.DateTimeFormat(locale, {
    year: 'numeric',
    month: 'short',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
  }).format(date)
}
