This commit is contained in:
Jake Kasper
2025-08-27 10:14:42 -04:00
parent af6403cec3
commit e5ef98043f

View File

@@ -85,6 +85,14 @@ const Applications = () => {
};
const fetchPropertyDetails = async (propertyId) => {
// Validate propertyId
if (!propertyId || isNaN(parseInt(propertyId))) {
console.error('Invalid property ID:', propertyId);
toast.error('Invalid property ID');
setSelectedPropertyDetails(null);
return null;
}
// Check cache first
if (propertyCache[propertyId]) {
setSelectedPropertyDetails(propertyCache[propertyId]);
@@ -140,9 +148,17 @@ const Applications = () => {
// Set the executing application and show the modal
setExecutingApplication(application);
// Also fetch the property details if we don't have them
if (!selectedPropertyDetails || selectedPropertyDetails.id !== application.property?.id) {
await fetchPropertyDetails(application.property?.id || application.section?.propertyId);
// Get the property ID from the application
const propertyId = application.property?.id || application.section?.propertyId;
// Also fetch the property details if we don't have them and we have a valid property ID
if (!selectedPropertyDetails || (propertyId && selectedPropertyDetails.id !== propertyId)) {
if (propertyId) {
await fetchPropertyDetails(propertyId);
} else {
console.warn('No property ID found for application:', application);
toast.warning('No property associated with this application');
}
}
setShowExecutionModal(true);