Skip to content

Commit

Permalink
Correctly initialize starting category trace + removing (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensWe authored Nov 12, 2024
2 parents 4b3f408 + 99573b1 commit 039a79c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/BeslisboomForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ function reset() {
}
function back() {
questionStore.revertAnswer(previousSubCategory.value)
categoryStore.revertCurrentCategory()
questionStore.revertAnswer(previousSubCategory.value)
}
function backButtonConclusion() {
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/stores/CategoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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')
Expand Down

0 comments on commit 039a79c

Please sign in to comment.