From 9a8ca25cd4929e91377d4daa565f84f23b3f9e76 Mon Sep 17 00:00:00 2001 From: Samy Ouyahia Date: Tue, 16 Jul 2024 12:10:18 +0200 Subject: [PATCH] Fixed crash when car coverage is disabled in upload center --- .../components/UploadCenter/hooks/useComplianceIds.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js b/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js index 31516cc80..1fbb3354a 100644 --- a/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js +++ b/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js @@ -28,8 +28,12 @@ export default function useComplianceIds({ const iqa = result.data.compliances.image_quality_assessment; // Filter unwanted reasons - carCov.reasons = filterUnwantedComplianceReasons(carCov.reasons); - iqa.reasons = filterUnwantedComplianceReasons(iqa.reasons); + if (carCov) { + carCov.reasons = filterUnwantedComplianceReasons(carCov.reasons); + } + if (iqa) { + iqa.reasons = filterUnwantedComplianceReasons(iqa.reasons); + } // `handleChangeReasons` returns the full result object with the given compliances const handleChangeReasons = (compliances) => ({ @@ -61,7 +65,7 @@ export default function useComplianceIds({ if (!carCov?.reasons) { return { ...item, requestCount, result }; } // remove the UNKNOWN_SIGHT from the carCov reasons array - const newCarCovReasons = carCov.reasons?.filter((reason) => reason !== UNKNOWN_SIGHT_REASON); + const newCarCovReasons = carCov?.reasons?.filter((reason) => reason !== UNKNOWN_SIGHT_REASON); return handleChangeReasons({ coverage_360: { reasons: newCarCovReasons, is_compliant: !newCarCovReasons.length }, });