From ed7e07b69a6055b3f603423f8f99a68f2166f874 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 5 Jun 2024 12:08:58 +0200 Subject: [PATCH] Refactor black powder revolver path --- .../e2e/typology-revolver-securing.cy.js | 2 +- frontend/src/components/ResultPage.vue | 18 +++++++----------- frontend/src/utils/firearms-utils/index.ts | 13 ++++++++++--- .../pistolet-semi-auto-moderne.ts | 4 +++- frontend/src/utils/firearms-utils/revolver.ts | 17 ++++++++--------- .../GuideIdentificationFirearm.vue | 11 ++++++----- .../SecuringAchievement.vue | 4 ++-- .../SecuringSelectOptionContent.vue | 17 +---------------- .../SecuringTutorialContent.vue | 2 +- 9 files changed, 39 insertions(+), 49 deletions(-) diff --git a/frontend/cypress/e2e/typology-revolver-securing.cy.js b/frontend/cypress/e2e/typology-revolver-securing.cy.js index 84528006..ec1ac189 100644 --- a/frontend/cypress/e2e/typology-revolver-securing.cy.js +++ b/frontend/cypress/e2e/typology-revolver-securing.cy.js @@ -16,7 +16,7 @@ describe('Typology Revolver Securing', () => { cy.contains('h1', 'mise en sécurité') cy.contains('p', 'les manipulations sont complexes') cy.getByDataTestid('go-to-identification').click() - cy.url().should('contain', '/guide-identification/resultat-typologie') + cy.url().should('contain', '/guide-identification/resultat-final') cy.getByDataTestid('arm-category').should('contain', 'Catégorie D') }) diff --git a/frontend/src/components/ResultPage.vue b/frontend/src/components/ResultPage.vue index e3225248..bc55d44b 100644 --- a/frontend/src/components/ResultPage.vue +++ b/frontend/src/components/ResultPage.vue @@ -27,17 +27,7 @@ const isFeedbackDone = ref(false) const label = computed(() => typology?.displayLabel) -const category = computed(() => { - if (store.selectedAlarmGun && store.selectedAlarmGun !== '') { - return 'D' - } else if (isDummy.value) { - return 'Non Classée' - } else if (typology.displayLabel === 'Revolver') { - return typology?.categoryWithoutSecuring - } else { - return typology?.getCategory(store.gunLength, store.gunBarrelLength) - } -}) +const category = computed(() => isDummy.value ? 'Non Classée' : typology?.getCategory(store.gunLength, store.gunBarrelLength)) const disclaimer = computed(() => typology && Object.hasOwn(typology, 'getDisclaimer') ? typology.getDisclaimer(category.value, isCardDetected.value) : null) @@ -135,6 +125,12 @@ function sendFeedback (isCorrect: boolean) { > Arme d'alarme de type {{ label }} +

+ Revolver à poudre noire +

'B', + getCategory: () => isAlarmGun() ? 'D' : 'B', pistolet_semi_auto_moderne_text_option: 'Sélectionner ce que vous voyez sur votre arme : bouton à proximité du pontet du côté gauche de la poignée, OU bouton sur le talon de la crosse.', textOptions: '', securingSteps: [ diff --git a/frontend/src/utils/firearms-utils/revolver.ts b/frontend/src/utils/firearms-utils/revolver.ts index b0da961e..b3bb5bfd 100644 --- a/frontend/src/utils/firearms-utils/revolver.ts +++ b/frontend/src/utils/firearms-utils/revolver.ts @@ -18,6 +18,11 @@ import revolver31892Img from '@/assets/guide-mise-en-securite/photos/revolver/re import revolver31892Video from '@/assets/guide-mise-en-securite/videos/revolver/revolver_1892.mp4' import revolverCartridges from '@/assets/guide-identification/photos/revolver/revolver_cartouche_pleine.jpg' import revolverBalls from '@/assets/guide-identification/photos/revolver/revolver_cartouche_bille.jpg' + +import { isAlarmGun } from '@/utils/firearms-utils/index' +import { useStore } from '@/stores/result' +const store = useStore() + /* Revolvers Revolver Enfield - Webley - brisure @@ -30,8 +35,7 @@ Revolvers */ export const revolver = { displayLabel: 'Revolver', - getCategory: () => 'B', - categoryWithoutSecuring: 'B ou D', + getCategory: () => isAlarmGun() || store.selectedOptions[0] === 'revolver_black_powder' ? 'D' : 'B ou D', securingSteps: [ { text: 'En maintenant l’arme dans une direction sécurisée , sélectionnez ce que vous voyez.', @@ -175,14 +179,9 @@ export const revolver = { img_ammo: revolverBalls, }, ], - getDisclaimer: (category: string) => { - if (category === 'D') { + getDisclaimer: () => { + if (isAlarmGun()) { return 'Les armes d’alarmes sont susceptibles d’être modifiées pour tirer des munitions létales. Pour des raisons de sécurité, faites si possible expertiser l’arme.' } }, } as const - -export const revolver_black_powder = { - displayLabel: 'Revolver à poudre noire', - getCategory: () => 'D', -} as const diff --git a/frontend/src/views/GuideIdentificationFirearm/GuideIdentificationFirearm.vue b/frontend/src/views/GuideIdentificationFirearm/GuideIdentificationFirearm.vue index 0f1e9ec2..a3b18236 100644 --- a/frontend/src/views/GuideIdentificationFirearm/GuideIdentificationFirearm.vue +++ b/frontend/src/views/GuideIdentificationFirearm/GuideIdentificationFirearm.vue @@ -6,7 +6,7 @@ import { identificationGuideSteps, identificationGuideStepsWithArmeAlarme, TYPOLOGIES, - ALARM_GUNS_TYPOLOGIES, + isAlarmGun, } from '@/utils/firearms-utils/index' import { useStore } from '@/stores/result' @@ -22,7 +22,7 @@ const isLowConfidence = confidenceLevel.value === 'low' const steps = computed(() => { if (TYPOLOGIES[typology]?.dummyOptions || !isLowConfidence) { - if (ALARM_GUNS_TYPOLOGIES.includes(store.typology) && store.selectedAmmo === 'cartouches') { + if (isAlarmGun() !== false) { return ['Typologie de l\'arme', 'Compléments', 'Typologie de munitions', 'Identification d\'une arme d\'alarme', 'Résultat final'] } else { return ['Typologie de l\'arme', 'Compléments', 'Typologie de munitions', 'Résultat final'] @@ -80,7 +80,7 @@ const nextStepButtonAction = () => { function handlePreviousButtonClick () { currentStep.value-- - if (ALARM_GUNS_TYPOLOGIES.includes(typology.value)) { + if (isAlarmGun() !== false) { goToNewRouteWithArmeAlarme() } else { goToNewRoute() @@ -95,7 +95,7 @@ const showDiv = ref(false)