From da01c5a2dc450c94b00d5bc41847b5bcfcd78ba1 Mon Sep 17 00:00:00 2001
From: Thomas Bernard
Date: Wed, 5 Jun 2024 11:53:35 +0200
Subject: [PATCH] Merge resultStore and stepsStore
---
frontend/.eslintrc-auto-import.json | 1 -
frontend/src/auto-imports.d.ts | 8 ++--
frontend/src/components/AskingExpert.vue | 28 +++++++-------
frontend/src/components/PopupVideo.vue | 6 +--
frontend/src/components/ResultPage.vue | 26 ++++++-------
frontend/src/stores/result.ts | 23 ++++++++---
frontend/src/stores/steps.ts | 38 -------------------
frontend/src/utils/storage-utils.ts | 13 +++----
.../GuideIdentificationFirearm.vue | 20 +++++-----
.../IdentificationBlankGun.vue | 16 +++-----
.../IdentificationSelectAmmo.vue | 16 ++++----
.../SecuringAchievement.vue | 10 ++---
.../SecuringSelectOptionContent.vue | 18 ++++-----
.../SecuringTutorialContent.vue | 10 ++---
frontend/src/views/InstructionsPage.vue | 18 ++++-----
frontend/src/views/MissingCardPage.vue | 6 +--
frontend/src/views/StartPage.vue | 8 ++--
17 files changed, 108 insertions(+), 157 deletions(-)
delete mode 100644 frontend/src/stores/steps.ts
diff --git a/frontend/.eslintrc-auto-import.json b/frontend/.eslintrc-auto-import.json
index 378e58a2..85f45d94 100644
--- a/frontend/.eslintrc-auto-import.json
+++ b/frontend/.eslintrc-auto-import.json
@@ -238,7 +238,6 @@
"useSpeechRecognition": true,
"useSpeechSynthesis": true,
"useStepper": true,
- "useStepsStore": true,
"useStorage": true,
"useStorageAsync": true,
"useStyleTag": true,
diff --git a/frontend/src/auto-imports.d.ts b/frontend/src/auto-imports.d.ts
index 85e2547e..d78c821a 100644
--- a/frontend/src/auto-imports.d.ts
+++ b/frontend/src/auto-imports.d.ts
@@ -238,9 +238,9 @@ declare global {
const useSpeechRecognition: typeof import('@vueuse/core')['useSpeechRecognition']
const useSpeechSynthesis: typeof import('@vueuse/core')['useSpeechSynthesis']
const useStepper: typeof import('@vueuse/core')['useStepper']
- const useStepsStore: typeof import('./stores/steps')['useStepsStore']
const useStorage: typeof import('@vueuse/core')['useStorage']
const useStorageAsync: typeof import('@vueuse/core')['useStorageAsync']
+ const useStore: typeof import('./stores/result')['useStore']
const useStyleTag: typeof import('@vueuse/core')['useStyleTag']
const useSupported: typeof import('@vueuse/core')['useSupported']
const useSwipe: typeof import('@vueuse/core')['useSwipe']
@@ -519,7 +519,6 @@ declare module 'vue' {
readonly useRafFn: UnwrapRef
readonly useRefHistory: UnwrapRef
readonly useResizeObserver: UnwrapRef
- readonly useResultStore: UnwrapRef
readonly useRoute: UnwrapRef
readonly useRouter: UnwrapRef
readonly useScheme: UnwrapRef
@@ -537,9 +536,9 @@ declare module 'vue' {
readonly useSpeechRecognition: UnwrapRef
readonly useSpeechSynthesis: UnwrapRef
readonly useStepper: UnwrapRef
- readonly useStepsStore: UnwrapRef
readonly useStorage: UnwrapRef
readonly useStorageAsync: UnwrapRef
+ readonly useStore: UnwrapRef
readonly useStyleTag: UnwrapRef
readonly useSupported: UnwrapRef
readonly useSwipe: UnwrapRef
@@ -811,7 +810,6 @@ declare module '@vue/runtime-core' {
readonly useRafFn: UnwrapRef
readonly useRefHistory: UnwrapRef
readonly useResizeObserver: UnwrapRef
- readonly useResultStore: UnwrapRef
readonly useRoute: UnwrapRef
readonly useRouter: UnwrapRef
readonly useScheme: UnwrapRef
@@ -829,9 +827,9 @@ declare module '@vue/runtime-core' {
readonly useSpeechRecognition: UnwrapRef
readonly useSpeechSynthesis: UnwrapRef
readonly useStepper: UnwrapRef
- readonly useStepsStore: UnwrapRef
readonly useStorage: UnwrapRef
readonly useStorageAsync: UnwrapRef
+ readonly useStore: UnwrapRef
readonly useStyleTag: UnwrapRef
readonly useSupported: UnwrapRef
readonly useSwipe: UnwrapRef
diff --git a/frontend/src/components/AskingExpert.vue b/frontend/src/components/AskingExpert.vue
index 9e317d8f..ce993be5 100644
--- a/frontend/src/components/AskingExpert.vue
+++ b/frontend/src/components/AskingExpert.vue
@@ -4,41 +4,39 @@ import axios from 'axios'
import { useRoute, useRouter } from 'vue-router'
import { useSnackbarStore } from '@/stores/snackbar'
-import { useStepsStore } from '@/stores/steps'
-import { useResultStore } from '@/stores/result'
+import { useStore } from '@/stores/result'
import SnackbarAlert from '@/components/SnackbarAlert.vue'
const { setMessage } = useSnackbarStore()
-const stepsStore = useStepsStore()
-const resultStore = useResultStore()
+const store = useStore()
const router = useRouter()
const route = useRoute()
-const typology = computed(() => resultStore.typology)
-const confidence = computed(() => resultStore.confidence)
-const confidenceLevel = computed(() => resultStore.confidenceLevel)
-const imgUrl = computed(() => resultStore.imgUrl)
+const typology = computed(() => store.typology)
+const confidence = computed(() => store.confidence)
+const confidenceLevel = computed(() => store.confidenceLevel)
+const imgUrl = computed(() => store.imgUrl)
const showModal = ref(false)
function onClose () {
- stepsStore.tutorialFeedback = ''
+ store.tutorialFeedback = ''
showModal.value = false
}
async function sendTutorialFeedback () {
const feedback = {
image_url: imgUrl.value,
- tutorial_feedback: stepsStore.tutorialFeedback,
+ tutorial_feedback: store.tutorialFeedback,
label: typology.value,
- tutorial_option: stepsStore.currentOptionStep[stepsStore.currentStep] || null,
+ tutorial_option: store.currentOptionStep[store.currentStep] || null,
route_name: route.name,
confidence: confidence.value,
confidence_level: confidenceLevel.value,
}
await axios.post('/tutorial-feedback', feedback)
.then(async () => {
- stepsStore.tutorialFeedback = feedback.tutorial_feedback
+ store.tutorialFeedback = feedback.tutorial_feedback
setMessage({ type: 'success', message: 'Votre message a été pris en compte' })
})
.catch(async (err) => {
@@ -46,7 +44,7 @@ async function sendTutorialFeedback () {
setMessage({ type: 'error', message: 'Une erreur a eu lieu en enregistrant de votre message.' })
})
.finally(() => setTimeout(() => {
- stepsStore.tutorialFeedback = ''
+ store.tutorialFeedback = ''
router.push({ name: 'ResultPage' })
}, 3000))
}
@@ -84,7 +82,7 @@ async function sendTutorialFeedback () {
En attendant, vous pouvez nous permettre d'améliorer le contenu de ce tutoriel en nous décrivant votre problème ci-dessous.