fix: handle null timestamps in scenario details page
- Add optional chaining for run.timestamps?.createdAt - Make timestamps.createdAt optional in interface - Add null check for evaluator.reason - Prevents TypeError when accessing undefined properties
This commit is contained in:
parent
c1af7a2bde
commit
474e11fc13
1 changed files with 5 additions and 4 deletions
|
|
@ -28,7 +28,7 @@ interface ScenarioRun {
|
|||
timestamps: {
|
||||
startedAt: string | null;
|
||||
completedAt: string | null;
|
||||
createdAt: string;
|
||||
createdAt: string | null;
|
||||
};
|
||||
output?: string;
|
||||
errorLog?: string;
|
||||
|
|
@ -131,7 +131,8 @@ function formatDuration(ms: number | null): string {
|
|||
return `${(ms / 1000).toFixed(1)}s`;
|
||||
}
|
||||
|
||||
function formatDate(dateString: string): string {
|
||||
function formatDate(dateString: string | null): string {
|
||||
if (!dateString) return '—';
|
||||
return new Date(dateString).toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
|
|
@ -358,7 +359,7 @@ export default function CollectionScenarioDetailPage(): React.ReactElement {
|
|||
<div className="flex items-center gap-4">
|
||||
<StatusBadge status={run.status} />
|
||||
<span className="text-sm text-foreground-secondary">
|
||||
{formatDate(run.timestamps.createdAt)}
|
||||
{formatDate(run.timestamps?.createdAt || null)}
|
||||
</span>
|
||||
{run.usage.executionTimeMs && (
|
||||
<span className="text-sm text-foreground-tertiary">
|
||||
|
|
@ -395,7 +396,7 @@ export default function CollectionScenarioDetailPage(): React.ReactElement {
|
|||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
{run.evaluator.reason && (
|
||||
{run.evaluator?.reason && (
|
||||
<p className="text-sm text-foreground-secondary">
|
||||
{run.evaluator.reason}
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue