diff --git a/frontend/src/components/ObjectDetailModal.tsx b/frontend/src/components/ObjectDetailModal.tsx index 6763bb8..e996cec 100644 --- a/frontend/src/components/ObjectDetailModal.tsx +++ b/frontend/src/components/ObjectDetailModal.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { getDataValidationObject, type DataValidationObjectResponse } from '../services/api'; import { useAuthStore } from '../stores/authStore'; @@ -213,7 +213,7 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on

{error}

- ) : objectData ? ( + ) : objectData !== null ? (
{/* Basic Info */}
@@ -235,7 +235,6 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
- {/* Attributes */}

@@ -254,24 +253,32 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on - {Object.entries(objectData.object as Record) - .filter(([key]) => !key.startsWith('_')) - .sort(([a], [b]) => a.localeCompare(b)) - .map(([key, value]) => { - const renderedValue = renderAttributeValue(key, value); - if (renderedValue === null) return null; - - return ( - - - {key} - - - {renderedValue} - - - ); - })} + {(() => { + const obj = objectData.object as Record; + const entries = Object.entries(obj) + .filter(([key]) => !key.startsWith('_')) + .sort(([a], [b]) => a.localeCompare(b)); + + const rows: React.ReactElement[] = entries + .map(([key, value]: [string, any]) => { + const renderedValue = renderAttributeValue(key, value); + if (renderedValue === null) return null; + + return ( + + + {key} + + + {renderedValue} + + + ); + }) + .filter((node): node is React.ReactElement => node !== null); + + return rows; + })()} {Object.entries(objectData.object as Record) .filter(([key]) => !key.startsWith('_')).length === 0 && ( @@ -289,52 +296,53 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on

{/* Metadata */} - {objectData.object && typeof objectData.object === 'object' && '_jiraUpdatedAt' in objectData.object && ( -
-

-
- Metadata -

-
- {(() => { - const obj = objectData.object as Record; - const updatedAt = obj._jiraUpdatedAt; - const createdAt = obj._jiraCreatedAt; - const updatedAtValue: string | number | Date | null = - updatedAt && (typeof updatedAt === 'string' || typeof updatedAt === 'number' || updatedAt instanceof Date) - ? (updatedAt as string | number | Date) - : null; - const createdAtValue: string | number | Date | null = - createdAt && (typeof createdAt === 'string' || typeof createdAt === 'number' || createdAt instanceof Date) - ? (createdAt as string | number | Date) - : null; - - if (!updatedAtValue && !createdAtValue) return null; - - return ( -
- {updatedAtValue && ( -
-
Laatst bijgewerkt (Jira)
-
- {new Date(updatedAtValue).toLocaleString('nl-NL')} -
+ {(() => { + if (!objectData.object || typeof objectData.object !== 'object' || objectData.object === null || !('_jiraUpdatedAt' in objectData.object)) { + return null; + } + const obj = objectData.object as Record; + const updatedAt = obj._jiraUpdatedAt; + const createdAt = obj._jiraCreatedAt; + const updatedAtValue: string | number | Date | null = + updatedAt && (typeof updatedAt === 'string' || typeof updatedAt === 'number' || updatedAt instanceof Date) + ? (updatedAt as string | number | Date) + : null; + const createdAtValue: string | number | Date | null = + createdAt && (typeof createdAt === 'string' || typeof createdAt === 'number' || createdAt instanceof Date) + ? (createdAt as string | number | Date) + : null; + + if (!updatedAtValue && !createdAtValue) return null; + + return ( +
+

+
+ Metadata +

+
+
+ {updatedAtValue && ( +
+
Laatst bijgewerkt (Jira)
+
+ {new Date(updatedAtValue).toLocaleString('nl-NL')}
- )} - {createdAtValue && ( -
-
Aangemaakt (Jira)
-
- {new Date(createdAtValue).toLocaleString('nl-NL')} -
+
+ )} + {createdAtValue && ( +
+
Aangemaakt (Jira)
+
+ {new Date(createdAtValue).toLocaleString('nl-NL')}
- )} -
- ); - })()} +
+ )} +
+
-
- )} + ); + })()}
) : (