From 99573b1bde01a057d56818a21476f7d3e83e5a79 Mon Sep 17 00:00:00 2001 From: Laurens Weijs Date: Tue, 12 Nov 2024 15:23:14 +0100 Subject: [PATCH] Correctly initialize starting category trace + removing --- frontend/src/components/BeslisboomForm.vue | 2 +- frontend/src/stores/CategoryStore.ts | 24 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/BeslisboomForm.vue b/frontend/src/components/BeslisboomForm.vue index d80550c..e08445e 100644 --- a/frontend/src/components/BeslisboomForm.vue +++ b/frontend/src/components/BeslisboomForm.vue @@ -161,8 +161,8 @@ function reset() { } function back() { - questionStore.revertAnswer(previousSubCategory.value) categoryStore.revertCurrentCategory() + questionStore.revertAnswer(previousSubCategory.value) } function backButtonConclusion() { diff --git a/frontend/src/stores/CategoryStore.ts b/frontend/src/stores/CategoryStore.ts index 19c2562..f6420d0 100644 --- a/frontend/src/stores/CategoryStore.ts +++ b/frontend/src/stores/CategoryStore.ts @@ -8,8 +8,8 @@ export const useCategoryStore = defineStore('category', () => { const initialPreviousSubCategory = localStorage.getItem('previousSubCategory') ?? startSubCategory const initialCurrentCategory = localStorage.getItem('currentCategory') ?? startCategory const initialCurrentSubCategory = localStorage.getItem('currentSubCategory') ?? startSubCategory - const initialCategoryTrace = JSON.parse(localStorage.getItem('categoryTrace') ?? '[]') - const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '[]') + const initialCategoryTrace = JSON.parse(localStorage.getItem('categoryTrace') ?? '["AI verordening van toepassing?"]') + const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '["Soort toepassing"]') const initialCategoryStateString = `{ "ai_act_applicable_state": "doing", "risk_group_state": "incomplete" @@ -99,28 +99,28 @@ export const useCategoryStore = defineStore('category', () => { */ // Categories section revertCategoryState() - if(categoryTrace.value.length - 2 > 0){ - currentCategory.value = categoryTrace.value[categoryTrace.value.length - 2] + if(categoryTrace.value.length - 1 > 0){ + currentCategory.value = categoryTrace.value[categoryTrace.value.length - 1] }else{ currentCategory.value = startCategory } categoryTrace.value.pop() - if(categoryTrace.value.length - 2 > 0) { - previousCategory.value = categoryTrace.value[categoryTrace.value.length - 2] + if(categoryTrace.value.length - 1 > 0) { + previousCategory.value = categoryTrace.value[categoryTrace.value.length - 1] } else { previousCategory.value = startCategory } // Subcategories section - if(subCategoryTrace.value.length - 2 > 0){ - currentSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2] + if(subCategoryTrace.value.length - 1 > 0){ + currentSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 1] }else{ currentSubCategory.value = startSubCategory } subCategoryTrace.value.pop() - if(subCategoryTrace.value.length - 2 > 0) { - previousSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2] + if(subCategoryTrace.value.length - 1 > 0) { + previousSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 1] } else { previousSubCategory.value = startSubCategory } @@ -139,8 +139,8 @@ export const useCategoryStore = defineStore('category', () => { previousCategory.value = startCategory previousSubCategory.value = startSubCategory categoryState.value = JSON.parse(initialCategoryStateString) - categoryTrace.value = [] - subCategoryTrace.value = [] + categoryTrace.value = [startCategory] + subCategoryTrace.value = [startSubCategory] localStorage.removeItem('currentCategory') localStorage.removeItem('currentSubCategory') localStorage.removeItem('previousCategory')