mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-26 06:31:15 -05:00
Fix critical 'any' types in components
This commit is contained in:
@@ -27,20 +27,31 @@ export function ValidationSummary({ item, onValidationChange, compact = false, v
|
||||
const [manualTriggerCount, setManualTriggerCount] = useState(0);
|
||||
|
||||
// Helper to extract the correct entity ID based on entity type
|
||||
const getEntityId = (itemType: string, itemData: any, fallbackId?: string): string | undefined => {
|
||||
const getEntityId = (
|
||||
itemType: string,
|
||||
itemData: SubmissionItemData,
|
||||
fallbackId?: string
|
||||
): string | undefined => {
|
||||
// Try entity-specific ID fields first
|
||||
const entityIdField = `${itemType}_id`;
|
||||
if (itemData[entityIdField]) {
|
||||
return itemData[entityIdField];
|
||||
const typedData = itemData as unknown as Record<string, unknown>;
|
||||
|
||||
if (typeof typedData[entityIdField] === 'string') {
|
||||
return typedData[entityIdField] as string;
|
||||
}
|
||||
|
||||
// For companies, check company_id
|
||||
if (['manufacturer', 'designer', 'operator', 'property_owner'].includes(itemType) && itemData.company_id) {
|
||||
return itemData.company_id;
|
||||
if (['manufacturer', 'designer', 'operator', 'property_owner'].includes(itemType) &&
|
||||
typeof typedData.company_id === 'string') {
|
||||
return typedData.company_id;
|
||||
}
|
||||
|
||||
// Fall back to generic id field or provided fallback
|
||||
return itemData.id || fallbackId;
|
||||
if (typeof typedData.id === 'string') {
|
||||
return typedData.id;
|
||||
}
|
||||
|
||||
return fallbackId;
|
||||
};
|
||||
|
||||
// Create stable reference for item_data to prevent unnecessary re-validations
|
||||
|
||||
Reference in New Issue
Block a user