Skip to content

Commit 02a9170

Browse files
committed
fix: update incident.js to handle new image url format and logic
1 parent 0fad4a6 commit 02a9170

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Fonctions/Incident_fonction.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,24 @@ export const IncidentData = () => {
480480
longitude
481481
);
482482

483+
// Handle different photo formats (Supabase vs old format)
484+
let imageUrl;
485+
if (typeof incident.photo === "object" && incident.photo !== null) {
486+
// Supabase storage format
487+
imageUrl =
488+
incident.photo.signedURL ||
489+
incident.photo.signedUrl ||
490+
incident.photo.url;
491+
} else if (typeof incident.photo === "string") {
492+
// Old format or direct URL
493+
imageUrl = incident.photo;
494+
} else {
495+
console.error("Invalid photo format:", incident.photo);
496+
return;
497+
}
498+
483499
const payload = {
484-
image_name: incident.photo,
500+
image_name: imageUrl,
485501
sensitive_structures: sensitiveStructures,
486502
incident_id: incidentId,
487503
user_id: userId,

0 commit comments

Comments
 (0)