import {
  createColumnLoader,
  ColumnMetadata,
} from '../DataGrid/configBuilderFactory';

const ACCESS_LOGS_COLUMNS: ColumnMetadata[] = [
  {
    field: 'project',
    headerName: 'Project',
    type: 'singleSelectRelation',
    entityRef: 'projects',
    editable: true,
  },
  {
    field: 'environment',
    headerName: 'Environment',
    type: 'text',
    editable: true,
  },
  {
    field: 'user',
    headerName: 'User',
    type: 'singleSelectRelation',
    entityRef: 'users',
    editable: true,
  },
  { field: 'path', headerName: 'Path', type: 'text', editable: true },
  {
    field: 'ip_address',
    headerName: 'IPaddress',
    type: 'text',
    editable: true,
  },
  {
    field: 'user_agent',
    headerName: 'Useragent',
    type: 'text',
    editable: true,
  },
  {
    field: 'accessed_at',
    headerName: 'Accessedat',
    type: 'datetime',
    editable: true,
  },
  { field: 'actions', headerName: '', type: 'actions' },
];

export const loadColumns = createColumnLoader({
  entityName: 'access_logs',
  columns: ACCESS_LOGS_COLUMNS,
});
