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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 10x 10x 3x 7x 17x 7x 7x 7x 7x | import React from "react";
import OurTable from "main/components/OurTable";
function JobLogTable({ job }) {
const testid = "JobLogTable";
// Ensure job and log data are present
if (!job) {
return <p data-testid={`${testid}-not-found`}>Job not found.</p>;
}
const logLines = job.log ? job.log.split("\n") : [];
const logData = logLines.map((line, index) => ({
index: index + 1,
logLine: line,
}));
const logColumns = [
{
Header: "#",
accessor: "index", // accessor is the "key" in the data
},
{
Header: "Log Line",
accessor: "logLine",
},
];
const jobData = [
{ field: "ID", value: job.id },
{ field: "Created", value: new Date(job.createdAt).toLocaleString() },
{ field: "Updated", value: new Date(job.updatedAt).toLocaleString() },
{ field: "Status", value: job.status },
];
const jobColumns = [
{
Header: "Field",
accessor: "field",
},
{
Header: "Value",
accessor: "value",
},
];
return (
<div>
<h3>Job Information</h3>
<OurTable data={jobData} columns={jobColumns} testid={testid} />
<h3>Job Log</h3>
<OurTable data={logData} columns={logColumns} testid={testid} />
</div>
);
}
export default JobLogTable;
|