Fix TypeScript error: Type 'unknown' not assignable to ReactNode in ObjectDetailModal
- Added explicit React import - Converted complex conditional rendering to IIFE for proper type inference - Fixed type safety issues in metadata conditional rendering - Resolves build failure in Azure DevOps pipeline
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { getDataValidationObject, type DataValidationObjectResponse } from '../services/api';
|
import { getDataValidationObject, type DataValidationObjectResponse } from '../services/api';
|
||||||
import { useAuthStore } from '../stores/authStore';
|
import { useAuthStore } from '../stores/authStore';
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</svg>
|
</svg>
|
||||||
<p className="text-red-600 font-semibold">{error}</p>
|
<p className="text-red-600 font-semibold">{error}</p>
|
||||||
</div>
|
</div>
|
||||||
) : objectData ? (
|
) : objectData !== null ? (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
{/* Basic Info */}
|
{/* Basic Info */}
|
||||||
<div>
|
<div>
|
||||||
@@ -235,7 +235,6 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Attributes */}
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-sm font-bold text-gray-700 uppercase tracking-wider mb-4 flex items-center gap-2">
|
<h3 className="text-sm font-bold text-gray-700 uppercase tracking-wider mb-4 flex items-center gap-2">
|
||||||
<div className="w-1 h-5 bg-gradient-to-b from-blue-500 to-blue-600 rounded-full"></div>
|
<div className="w-1 h-5 bg-gradient-to-b from-blue-500 to-blue-600 rounded-full"></div>
|
||||||
@@ -254,10 +253,14 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="bg-white divide-y divide-gray-100">
|
<tbody className="bg-white divide-y divide-gray-100">
|
||||||
{Object.entries(objectData.object as Record<string, any>)
|
{(() => {
|
||||||
|
const obj = objectData.object as Record<string, any>;
|
||||||
|
const entries = Object.entries(obj)
|
||||||
.filter(([key]) => !key.startsWith('_'))
|
.filter(([key]) => !key.startsWith('_'))
|
||||||
.sort(([a], [b]) => a.localeCompare(b))
|
.sort(([a], [b]) => a.localeCompare(b));
|
||||||
.map(([key, value]) => {
|
|
||||||
|
const rows: React.ReactElement[] = entries
|
||||||
|
.map(([key, value]: [string, any]) => {
|
||||||
const renderedValue = renderAttributeValue(key, value);
|
const renderedValue = renderAttributeValue(key, value);
|
||||||
if (renderedValue === null) return null;
|
if (renderedValue === null) return null;
|
||||||
|
|
||||||
@@ -271,7 +274,11 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
.filter((node): node is React.ReactElement => node !== null);
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
})()}
|
||||||
{Object.entries(objectData.object as Record<string, any>)
|
{Object.entries(objectData.object as Record<string, any>)
|
||||||
.filter(([key]) => !key.startsWith('_')).length === 0 && (
|
.filter(([key]) => !key.startsWith('_')).length === 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
@@ -289,14 +296,10 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Metadata */}
|
{/* Metadata */}
|
||||||
{objectData.object && typeof objectData.object === 'object' && '_jiraUpdatedAt' in objectData.object && (
|
|
||||||
<div>
|
|
||||||
<h3 className="text-sm font-bold text-gray-700 uppercase tracking-wider mb-4 flex items-center gap-2">
|
|
||||||
<div className="w-1 h-5 bg-gradient-to-b from-blue-500 to-blue-600 rounded-full"></div>
|
|
||||||
Metadata
|
|
||||||
</h3>
|
|
||||||
<div className="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
|
|
||||||
{(() => {
|
{(() => {
|
||||||
|
if (!objectData.object || typeof objectData.object !== 'object' || objectData.object === null || !('_jiraUpdatedAt' in objectData.object)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const obj = objectData.object as Record<string, unknown>;
|
const obj = objectData.object as Record<string, unknown>;
|
||||||
const updatedAt = obj._jiraUpdatedAt;
|
const updatedAt = obj._jiraUpdatedAt;
|
||||||
const createdAt = obj._jiraCreatedAt;
|
const createdAt = obj._jiraCreatedAt;
|
||||||
@@ -312,6 +315,12 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
if (!updatedAtValue && !createdAtValue) return null;
|
if (!updatedAtValue && !createdAtValue) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div>
|
||||||
|
<h3 className="text-sm font-bold text-gray-700 uppercase tracking-wider mb-4 flex items-center gap-2">
|
||||||
|
<div className="w-1 h-5 bg-gradient-to-b from-blue-500 to-blue-600 rounded-full"></div>
|
||||||
|
Metadata
|
||||||
|
</h3>
|
||||||
|
<div className="bg-white rounded-xl border border-gray-200 p-6 shadow-sm">
|
||||||
<div className="grid grid-cols-2 gap-6">
|
<div className="grid grid-cols-2 gap-6">
|
||||||
{updatedAtValue && (
|
{updatedAtValue && (
|
||||||
<div>
|
<div>
|
||||||
@@ -330,12 +339,11 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="text-center py-16 text-gray-500">
|
<div className="text-center py-16 text-gray-500">
|
||||||
<div className="w-12 h-12 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4" />
|
<div className="w-12 h-12 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user