All files / plainweb/src/admin/database/routes/[table]/components table-row.tsx

0% Statements 0/29
0% Branches 0/1
0% Functions 0/1
0% Lines 0/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import { type Column, columnType, renderValue } from "admin/column";
import { config } from "admin/config";
 
interface TableRowProps {
  tableName: string;
  columns: Column[];
  row: Record<string, unknown>;
  editing?: boolean;
}
 
export function TableRow({ editing, tableName, columns, row }: TableRowProps) {
  return (
    <tr>
      <td class="px-1 py-0 text-sm invisible w-16">
        <button
          class="btn btn-xs mr-2"
          type="submit"
          hx-target="closest tr"
          hx-swap="outerHTML"
          hx-get={`${config.adminBasePath}/database/${tableName}/edit?row=${encodeURIComponent(JSON.stringify(row))}`}
          hx-trigger="click from:closest tr"
        />
      </td>
      {columns.map((column) => {
        const tsType = columnType(column.type);
        const value = row[column.name];
        const formattedValue = renderValue(value, tsType);
        return (
          <td
            safe
            data-type={tsType}
            class="border border-neutral px-2 py-1 max-w-64 min-w-32 truncate"
          >
            {formattedValue}
          </td>
        );
      })}{" "}
    </tr>
  );
}