diff --git a/packages/camera/src/components/UploadCenter/UploadCard/hooks/useSubtitle.js b/packages/camera/src/components/UploadCenter/UploadCard/hooks/useSubtitle.js index b32e7da69..7fc88705d 100644 --- a/packages/camera/src/components/UploadCenter/UploadCard/hooks/useSubtitle.js +++ b/packages/camera/src/components/UploadCenter/UploadCard/hooks/useSubtitle.js @@ -1,17 +1,16 @@ import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -const validErrorCodes = [ - 'UNKNOWN_SIGHT', - 'INTERIOR_NOT_SUPPORTED', - 'NO_CAR_BODY', - 'UNKNOWN_VIEWPOINT', +const translatedErrorCodes = [ + 'TOO_ZOOMED', + 'NOT_ZOOMED_ENOUGH', 'WRONG_ANGLE', + 'UNKNOWN_VIEWPOINT', 'WRONG_CENTER_PART', 'MISSING_PARTS', 'HIDDEN_PARTS', - // 'TOO_ZOOMED', - // 'NOT_ZOOMED_ENOUGH', + 'UNKNOWN_SIGHT', + 'INTERIOR_NOT_SUPPORTED', ]; export default function useSubtitle({ @@ -42,7 +41,7 @@ export default function useSubtitle({ if (badQuality && iqa.reasons) { iqa.reasons.forEach((reason, index) => { - const errorCode = validErrorCodes.find((code) => reason.startsWith(code)); + const errorCode = translatedErrorCodes.find((code) => reason.startsWith(code)); if (errorCode && errorCode !== 'UNKNOWN_SIGHT') { const first = index === 0; reasons.push(first ? t(`uploadCenter.subtitle.reasons.${reason}`) @@ -54,7 +53,7 @@ export default function useSubtitle({ if (badCoverage && carCov.reasons) { carCov.reasons.forEach((reason, index) => { const first = index === 0 && !badQuality; - const errorCode = validErrorCodes.find((code) => reason.startsWith(code)); + const errorCode = translatedErrorCodes.find((code) => reason.startsWith(code)); // display all reasons expect `UNKNOWN_SIGHT` if (errorCode && errorCode !== 'UNKNOWN_SIGHT') { reasons.push(first ? t(`uploadCenter.subtitle.reasons.${errorCode}`) diff --git a/packages/camera/src/components/UploadCenter/hooks/allowedComplianceReasons.js b/packages/camera/src/components/UploadCenter/hooks/allowedComplianceReasons.js new file mode 100644 index 000000000..6ce95db43 --- /dev/null +++ b/packages/camera/src/components/UploadCenter/hooks/allowedComplianceReasons.js @@ -0,0 +1,48 @@ +const ALLOWED_COMPLIANCE_REASONS = [ + 'LOW_RESOLUTION', + 'BLURRINESS', + 'UNDEREXPOSURE', + 'OVEREXPOSURE', + 'LENS_FLARE', + 'DIRTINESS', + 'SNOWNESS', + 'WETNESS', + 'REFLECTIONS', +]; + +export default function filterUnwantedComplianceReasons(reasons) { + if (!Array.isArray(reasons)) { + return reasons; + } + return reasons.filter( + (reason) => ALLOWED_COMPLIANCE_REASONS + .findIndex((allowedReason) => reason.startsWith(allowedReason)) !== -1, + ); +} + +/* + * For reference, here is the complete list of compliances reasons known to this date. + * - Samy 22/11/23 + * OTHER + * LOW_RESOLUTION + * BLURRINESS + * UNDEREXPOSURE + * OVEREXPOSURE + * LENS_FLARE + * DIRTINESS + * SNOWNESS + * WETNESS + * REFLECTIONS + * UNKNOWN_SIGHT + * UNKNOWN_VIEWPOINT + * NO_VEHICLE + * WRONG_ANGLE + * WRONG_CENTER_PART + * MISSING_PARTS + * HIDDEN_PARTS + * TOO_ZOOMED + * NOT_ZOOMED_ENOUGH + * INTERIOR_NOT_SUPPORTED + * MISSING + * LOW_QUALITY + */ diff --git a/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js b/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js index d1e93c4b4..ebf857219 100644 --- a/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js +++ b/packages/camera/src/components/UploadCenter/hooks/useComplianceIds.js @@ -1,4 +1,5 @@ import { useCallback, useMemo } from 'react'; +import filterUnwantedComplianceReasons from './allowedComplianceReasons'; const getIndexById = (id, array) => array.findIndex((item) => item.id === id); const hasTodo = (c) => c?.is_compliant === null || c?.status === 'TODO'; @@ -26,6 +27,10 @@ export default function useComplianceIds({ const carCov = result.data.compliances.coverage_360; const iqa = result.data.compliances.image_quality_assessment; + // Filter unwanted reasons + carCov.reasons = filterUnwantedComplianceReasons(carCov.reasons); + iqa.reasons = filterUnwantedComplianceReasons(iqa.reasons); + // `handleChangeReasons` returns the full result object with the given compliances const handleChangeReasons = (compliances) => ({ ...item, diff --git a/packages/camera/src/i18n/resources/en.js b/packages/camera/src/i18n/resources/en.js index d4c55ec96..1edb415a3 100644 --- a/packages/camera/src/i18n/resources/en.js +++ b/packages/camera/src/i18n/resources/en.js @@ -41,25 +41,16 @@ const en = { blurriness: 'is blurry', underexposure: 'is underexposed (too dark)', overexposure: 'is overexposed (too bright)', - 'TOO_ZOOMED--too zoomed': 'is too zoomed', - 'NOT_ZOOMED_ENOUGH--not zoomed enough': 'is too far from vehicle', - 'WRONG_ANGLE--wrong angle': 'is taken from incorrect angle', - 'UNKNOWN_VIEWPOINT--unknown viewpoint': 'doesn\'t match photo guide', - 'WRONG_CENTER_PART--picture centered on the wrong parts': 'is not centered on the right part', - 'MISSING_PARTS--missing some parts': 'is missing important car parts', - 'HIDDEN_PARTS--some parts not visible enough': 'has some car parts not visible enough', - 'NO_CAR_BODY--no car body detected': 'doesn\'t have a clear vehicle', - 'NO_CAR_BODY--No car body was detected. Car parts prediction is `None`.': 'no car was detected', + TOO_ZOOMED: 'is too zoomed', + NOT_ZOOMED_ENOUGH: 'is too far from vehicle', + WRONG_ANGLE: 'is taken from incorrect angle', + UNKNOWN_VIEWPOINT: 'doesn\'t match photo guide', + WRONG_CENTER_PART: 'is not centered on the right part', + MISSING_PARTS: 'is missing important car parts', + HIDDEN_PARTS: 'has some car parts not visible enough', + NO_CAR_BODY: 'doesn\'t have a clear vehicle', UNKNOWN_SIGHT: 'can\'t be analysed for the car coverage', INTERIOR_NOT_SUPPORTED: 'can\'t be analysed for the car coverage', - NO_CAR_BODY: 'does not contain a car', - UNKNOWN_VIEWPOINT: 'is taken from an unknown point of vue', - WRONG_ANGLE: 'is taken from the wrong angle', - WRONG_CENTER_PART: 'is not centered on the proper car part', - MISSING_PARTS: 'is missing some car parts', - HIDDEN_PARTS: 'contains car parts not visible enough', - TOO_ZOOMED: 'is too zoomed', - NOT_ZOOMED_ENOUGH: 'is not zoomed enough', }, }, variant: { diff --git a/packages/camera/src/i18n/resources/fr.js b/packages/camera/src/i18n/resources/fr.js index f35739064..d89a6f79b 100644 --- a/packages/camera/src/i18n/resources/fr.js +++ b/packages/camera/src/i18n/resources/fr.js @@ -41,25 +41,16 @@ const fr = { blurriness: 'est floue', underexposure: 'est sous-exposée (trop sombre)', overexposure: 'est sur-exposée (trop lumineuse)', - 'TOO_ZOOMED--too zoomed': 'est trop zoomée', - 'NOT_ZOOMED_ENOUGH--not zoomed enough': 'est trop loin du véhicule', - 'WRONG_ANGLE--wrong angle': 'est prise depuis un angle incorrect', - 'UNKNOWN_VIEWPOINT--unknown viewpoint': 'ne s\'aligne pas avec le guide photo', - 'WRONG_CENTER_PART--picture centered on the wrong parts': 'n\'est pas centrée au bon endroit', - 'MISSING_PARTS--missing some parts': 'ne contient pas les bonnes parties de la voiture', - 'HIDDEN_PARTS--some parts not visible enough': 'contient certaines parties de voiture qui ne sont pas assez visibles', - 'NO_CAR_BODY--no car body detected': 'n\'a pas de véhicule clair', - 'NO_CAR_BODY--No car body was detected. Car parts prediction is `None`.': 'aucune voiture n\'a été détéctée', + TOO_ZOOMED: 'est trop zoomée', + NOT_ZOOMED_ENOUGH: 'est trop loin du véhicule', + WRONG_ANGLE: 'est prise depuis un angle incorrect', + UNKNOWN_VIEWPOINT: 'ne s\'aligne pas avec le guide photo', + WRONG_CENTER_PART: 'n\'est pas centrée au bon endroit', + MISSING_PARTS: 'ne contient pas les bonnes parties de la voiture', + HIDDEN_PARTS: 'contient certaines parties de voiture qui ne sont pas assez visibles', + NO_CAR_BODY: 'n\'a pas de véhicule clair', UNKNOWN_SIGHT: 'ne peut pas être analysée pour la couverture de voiture', INTERIOR_NOT_SUPPORTED: 'ne peut pas être analysée pour la couverture de voiture', - NO_CAR_BODY: 'ne contient pas de voiture', - UNKNOWN_VIEWPOINT: 'est prise depuis un point de vue non reconnu', - WRONG_ANGLE: 'est prise depuis un mauvais angle', - WRONG_CENTER_PART: 'n\'est pas centrée sur la bonne partie de voiture', - MISSING_PARTS: 'ne contient pas toutes les parties de voiture', - HIDDEN_PARTS: 'contient des parties de voiture pas assez visibles', - TOO_ZOOMED: 'est trop zoomée', - NOT_ZOOMED_ENOUGH: 'n\'est pas assez zoomée', }, }, variant: {