import * as React from 'react' import { Stack, Group, Title, Text, Paper, Table, Button, ActionIcon, Center } from '@mantine/core' import { IconPlus, IconPencil, IconTrash } from '@tabler/icons-react' interface CrudField { key: string label: string type: 'text' | 'number' | 'email' | 'select' | 'textarea' required?: boolean options?: Array<{ label: string; value: string }> placeholder?: string } interface CrudPageProps> { title: string subtitle?: string data: T[] fields: CrudField[] columns: Array<{ key: keyof T label: string render?: (value: unknown, row: T) => React.ReactNode }> onAdd?: (item: Partial) => void onEdit?: (item: T) => void onDelete?: (item: T) => void actions?: React.ReactNode className?: string } export function crudPage>({ title, subtitle, data, fields, columns, onAdd, onEdit, onDelete, actions, }: CrudPageProps): React.ReactElement { return ( {/* Header */} {title} {subtitle && {subtitle}} {actions} {onAdd && ( )} {/* Table */} {columns.map((col) => ( {col.label} ))} {(onEdit || onDelete) && ( Actions )} {data.length === 0 ? (
No items yet.
) : ( data.map((row, i) => ( {columns.map((col) => ( {col.render ? col.render(row[col.key], row) : String(row[col.key] ?? '')} ))} {(onEdit || onDelete) && ( {onEdit && ( onEdit(row)}> )} {onDelete && ( onDelete(row)}> )} )} )) )}
{/* Form fields definition (for agent use) */}
) } export type { CrudPageProps, CrudField }