'use client'; import { useMemo } from 'react'; import type { ColumnDef } from '@tanstack/react-table'; import { Badge } from '@/components/ui/badge'; import type { Tenant } from '@/types'; function formatDate(value?: string | null) { if (!value) return '-'; return new Intl.DateTimeFormat('en-IN', { day: '2-digit', month: 'short', year: 'numeric', }).format(new Date(value)); } export function useTenantColumns(): ColumnDef[] { return useMemo(() => { return [ { accessorKey: 'name', header: 'Tenant', cell: ({ row }) => (

{row.original.name}

{row.original.slug}

), }, { accessorKey: 'domain', header: 'Domain', cell: ({ row }) => row.original.domain || '-', }, { accessorKey: 'admin_email', header: 'Admin Email', cell: ({ row }) => row.original.admin_email || '-', }, { accessorKey: 'plan_id', header: 'Plan', cell: ({ row }) => row.original.plan_id || '-', }, { accessorKey: 'created_at', header: 'Created', cell: ({ row }) => formatDate(row.original.created_at), }, { accessorKey: 'is_active', header: 'Status', cell: ({ row }) => ( {row.original.is_active ? 'Active' : 'Inactive'} ), }, ]; }, []); }