Improve TypeScript type safety in DataValidationDashboard and ObjectDetailModal
- Use proper type references instead of typeof in DataValidationDashboard - Improve date value type handling in ObjectDetailModal with explicit type checks
This commit is contained in:
@@ -146,10 +146,10 @@ export default function DataValidationDashboard() {
|
|||||||
|
|
||||||
// Group typeComparisons by schema
|
// Group typeComparisons by schema
|
||||||
const groupedBySchema = (() => {
|
const groupedBySchema = (() => {
|
||||||
if (!stats) return new Map<string, typeof stats.comparison.typeComparisons>();
|
if (!stats) return new Map<string, DataValidationStats['comparison']['typeComparisons']>();
|
||||||
|
|
||||||
const grouped = new Map<string, typeof stats.comparison.typeComparisons>();
|
const grouped = new Map<string, DataValidationStats['comparison']['typeComparisons']>();
|
||||||
const noSchemaGroup: typeof stats.comparison.typeComparisons = [];
|
const noSchemaGroup: DataValidationStats['comparison']['typeComparisons'] = [];
|
||||||
|
|
||||||
for (const comp of stats!.comparison.typeComparisons) {
|
for (const comp of stats!.comparison.typeComparisons) {
|
||||||
const schemaKey = comp.schemaId && comp.schemaName
|
const schemaKey = comp.schemaId && comp.schemaName
|
||||||
|
|||||||
@@ -300,26 +300,32 @@ export default function ObjectDetailModal({ objectId, onClose, onObjectClick, on
|
|||||||
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;
|
||||||
const hasUpdatedAt = updatedAt && (typeof updatedAt === 'string' || typeof updatedAt === 'number' || updatedAt instanceof Date);
|
const updatedAtValue: string | number | Date | null =
|
||||||
const hasCreatedAt = createdAt && (typeof createdAt === 'string' || typeof createdAt === 'number' || createdAt instanceof Date);
|
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 (!hasUpdatedAt && !hasCreatedAt) return null;
|
if (!updatedAtValue && !createdAtValue) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-2 gap-6">
|
<div className="grid grid-cols-2 gap-6">
|
||||||
{hasUpdatedAt && (
|
{updatedAtValue && (
|
||||||
<div>
|
<div>
|
||||||
<div className="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">Laatst bijgewerkt (Jira)</div>
|
<div className="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">Laatst bijgewerkt (Jira)</div>
|
||||||
<div className="text-sm font-medium text-gray-900 bg-gray-50 px-3 py-2 rounded-lg border border-gray-200">
|
<div className="text-sm font-medium text-gray-900 bg-gray-50 px-3 py-2 rounded-lg border border-gray-200">
|
||||||
{new Date(updatedAt as string | number | Date).toLocaleString('nl-NL')}
|
{new Date(updatedAtValue).toLocaleString('nl-NL')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{hasCreatedAt && (
|
{createdAtValue && (
|
||||||
<div>
|
<div>
|
||||||
<div className="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">Aangemaakt (Jira)</div>
|
<div className="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">Aangemaakt (Jira)</div>
|
||||||
<div className="text-sm font-medium text-gray-900 bg-gray-50 px-3 py-2 rounded-lg border border-gray-200">
|
<div className="text-sm font-medium text-gray-900 bg-gray-50 px-3 py-2 rounded-lg border border-gray-200">
|
||||||
{new Date(createdAt as string | number | Date).toLocaleString('nl-NL')}
|
{new Date(createdAtValue).toLocaleString('nl-NL')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user