Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

1.1 KB
Raw Blame
import { Column } from 'react-data-grid'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'

import type { LogData } from '../Logs.types'
import { extractEdgeFunctionName } from '../Logs.utils'
import { ResponseCodeFormatter, RowLayout, TextFormatter } from '../LogsFormatters'
import { defaultRenderCell } from './DefaultPreviewColumnRenderer'

const columns: Column<LogData>[] = [
  {
    name: 'functions-edge-first-column',
    key: 'functions-edge-first-column',
    renderHeaderCell: () => null,
    renderCell: (props) => {
      if (!props.row.status_code && !props.row.method) {
        return defaultRenderCell(props)
      }
      const functionName = extractEdgeFunctionName(props.row.pathname)
      return (
        <RowLayout>
          <TimestampInfo utcTimestamp={props.row.timestamp!} />
          <ResponseCodeFormatter value={String(props.row.status_code)} />
          <TextFormatter value={String(props.row.method)} />
          {functionName && <TextFormatter value={functionName} />}
          <TextFormatter value={String(props.row.id)} />
        </RowLayout>
      )
    },
  },
]

export default columns