'use client'

import type { ColumnDef } from '@tanstack/react-table'

export interface FormSettingsRow {
  settingsKey: string
  label: string
  notificationEmails: string | null
}

export function createFormSettingsColumns(isPending: boolean): ColumnDef<FormSettingsRow>[] {
  return [
    {
      id: 'form',
      header: 'Form',
      cell: ({ row }) => <span className="truncate font-medium">{row.original.label}</span>
    },
    {
      id: 'notificationEmails',
      header: 'Notification emails',
      cell: ({ row }) =>
        isPending ? (
          <span className="text-muted-foreground">Loading…</span>
        ) : row.original.notificationEmails ? (
          <span className="truncate font-mono text-xs">{row.original.notificationEmails}</span>
        ) : (
          <span className="text-muted-foreground">No emails configured</span>
        )
    }
  ]
}
