diff --git a/frontend/src/stores/CategoryStore.ts b/frontend/src/stores/CategoryStore.ts index f6420d0..f2446c0 100644 --- a/frontend/src/stores/CategoryStore.ts +++ b/frontend/src/stores/CategoryStore.ts @@ -4,12 +4,12 @@ import { defineStore } from 'pinia' export const useCategoryStore = defineStore('category', () => { const startCategory = 'AI verordening van toepassing?' const startSubCategory = 'Soort toepassing' - const initialPreviousCategory = localStorage.getItem('previousCategory') ?? startCategory - 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') ?? '["AI verordening van toepassing?"]') - const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '["Soort toepassing"]') + const initialPreviousCategory = sessionStorage.getItem('previousCategory') ?? startCategory + const initialPreviousSubCategory = sessionStorage.getItem('previousSubCategory') ?? startSubCategory + const initialCurrentCategory = sessionStorage.getItem('currentCategory') ?? startCategory + const initialCurrentSubCategory = sessionStorage.getItem('currentSubCategory') ?? startSubCategory + const initialCategoryTrace = JSON.parse(sessionStorage.getItem('categoryTrace') ?? '["AI verordening van toepassing?"]') + const initialSubCategoryTrace = JSON.parse(sessionStorage.getItem('subCategoryTrace') ?? '["Soort toepassing"]') const initialCategoryStateString = `{ "ai_act_applicable_state": "doing", "risk_group_state": "incomplete" @@ -19,27 +19,7 @@ export const useCategoryStore = defineStore('category', () => { 'Welke risicogroep?': 'risk_group_state' } - const subCategoryCategoryMapper = { - 'Rol': 'ai_act_applicable_state', - 'Operationeel': 'ai_act_applicable_state', - 'Soort toepassing': 'ai_act_applicable_state', - 'Risicogroep': 'risk_group_state', - 'Conformiteitsbeoordeling': 'risk_group_state', - 'Systeemrisico': 'risk_group_state', - 'Transparantieverplichting': 'risk_group_state' - } - - const subCategoryCategoryMapperString = { - 'Rol': 'AI verordening van toepassing?', - 'Operationeel': 'AI verordening van toepassing?', - 'Soort toepassing': 'AI verordening van toepassing?', - 'Risicogroep': 'Welke risicogroep?', - 'Conformiteitsbeoordeling': 'Welke risicogroep?', - 'Systeemrisico': 'Welke risicogroep?', - 'Transparantieverplichting': 'Welke risicogroep?' - } - - const initialCategoryState = JSON.parse(localStorage.getItem('categoryState') ?? initialCategoryStateString) + const initialCategoryState = JSON.parse(sessionStorage.getItem('categoryState') ?? initialCategoryStateString) const previousCategory = ref(String(initialPreviousCategory)) const previousSubCategory = ref(String(initialPreviousSubCategory)) const currentCategory = ref(String(initialCurrentCategory)) @@ -57,12 +37,12 @@ export const useCategoryStore = defineStore('category', () => { currentSubCategory.value = subcategory categoryTrace.value.push(category) subCategoryTrace.value.push(subcategory) - localStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value)) - localStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value)) - localStorage.setItem('previousCategory', previousCategory.value) - localStorage.setItem('previousSubCategory', previousSubCategory.value) - localStorage.setItem('currentCategory', currentCategory.value) - localStorage.setItem('currentSubCategory', currentSubCategory.value) + sessionStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value)) + sessionStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value)) + sessionStorage.setItem('previousCategory', previousCategory.value) + sessionStorage.setItem('previousSubCategory', previousSubCategory.value) + sessionStorage.setItem('currentCategory', currentCategory.value) + sessionStorage.setItem('currentSubCategory', currentSubCategory.value) updateCategoryState() } } @@ -76,7 +56,7 @@ export const useCategoryStore = defineStore('category', () => { if (previousCategoryKey != currentCategoryKey) { categoryState.value[previousCategoryKey] = "completed" categoryState.value[currentCategoryKey] = "doing" - localStorage.setItem('categoryState', JSON.stringify(categoryState.value)) + sessionStorage.setItem('categoryState', JSON.stringify(categoryState.value)) } } @@ -89,7 +69,7 @@ export const useCategoryStore = defineStore('category', () => { if (previousCategoryKey != currentCategoryKey) { categoryState.value[currentCategoryKey] = "incomplete" categoryState.value[previousCategoryKey] = "doing" - localStorage.setItem('categoryState', JSON.stringify(categoryState.value)) + sessionStorage.setItem('categoryState', JSON.stringify(categoryState.value)) } } @@ -125,12 +105,12 @@ export const useCategoryStore = defineStore('category', () => { previousSubCategory.value = startSubCategory } - localStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value)) - localStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value)) - localStorage.setItem('previousCategory', previousCategory.value) - localStorage.setItem('previousSubCategory', previousSubCategory.value) - localStorage.setItem('currentCategory', currentCategory.value) - localStorage.setItem('currentSubCategory', currentSubCategory.value) + sessionStorage.setItem('categoryTrace', JSON.stringify(categoryTrace.value)) + sessionStorage.setItem('subCategoryTrace', JSON.stringify(subCategoryTrace.value)) + sessionStorage.setItem('previousCategory', previousCategory.value) + sessionStorage.setItem('previousSubCategory', previousSubCategory.value) + sessionStorage.setItem('currentCategory', currentCategory.value) + sessionStorage.setItem('currentSubCategory', currentSubCategory.value) } function reset() { @@ -141,14 +121,14 @@ export const useCategoryStore = defineStore('category', () => { categoryState.value = JSON.parse(initialCategoryStateString) categoryTrace.value = [startCategory] subCategoryTrace.value = [startSubCategory] - localStorage.removeItem('currentCategory') - localStorage.removeItem('currentSubCategory') - localStorage.removeItem('previousCategory') - localStorage.removeItem('previousSubCategory') - localStorage.removeItem('categoryState') - localStorage.removeItem('subCategoryState') - localStorage.removeItem('categoryTrace') - localStorage.removeItem('subCategoryTrace') + sessionStorage.removeItem('currentCategory') + sessionStorage.removeItem('currentSubCategory') + sessionStorage.removeItem('previousCategory') + sessionStorage.removeItem('previousSubCategory') + sessionStorage.removeItem('categoryState') + sessionStorage.removeItem('subCategoryState') + sessionStorage.removeItem('categoryTrace') + sessionStorage.removeItem('subCategoryTrace') } return { categoryState, previousSubCategory, revertCurrentCategory, updateCurrentCategory, reset } diff --git a/frontend/src/stores/QuestionStore.ts b/frontend/src/stores/QuestionStore.ts index 79d4c51..36655a8 100644 --- a/frontend/src/stores/QuestionStore.ts +++ b/frontend/src/stores/QuestionStore.ts @@ -13,11 +13,11 @@ export const useQuestionStore = defineStore('question', () => { }` const initialAcceptedDisclaimer = sessionStorage.getItem('acceptedDisclaimer') ?? '0' - const initialAnswers = JSON.parse(localStorage.getItem('answers') ?? '[]') - const initialLabels = JSON.parse(localStorage.getItem('labels') ?? '{}') - const initialLabelsBySubCategory = JSON.parse(localStorage.getItem('labelsbysubcategory') ?? initialLabelsBySubCategoryNTB) - const initialQuestionId = localStorage.getItem('currentquestion') ?? '1.2' - const initialConclusionId = localStorage.getItem('currentconclusion') ?? '' + const initialAnswers = JSON.parse(sessionStorage.getItem('answers') ?? '[]') + const initialLabels = JSON.parse(sessionStorage.getItem('labels') ?? '{}') + const initialLabelsBySubCategory = JSON.parse(sessionStorage.getItem('labelsbysubcategory') ?? initialLabelsBySubCategoryNTB) + const initialQuestionId = sessionStorage.getItem('currentquestion') ?? '1.2' + const initialConclusionId = sessionStorage.getItem('currentconclusion') ?? '' const AcceptedDisclaimer = ref(String(initialAcceptedDisclaimer)) const QuestionId = ref(initialQuestionId) @@ -28,12 +28,12 @@ export const useQuestionStore = defineStore('question', () => { function setQuestionId(id: string | null) { QuestionId.value = id - localStorage.setItem('currentquestion', QuestionId.value) + sessionStorage.setItem('currentquestion', QuestionId.value) } function setConclusionId(id: string) { ConclusionId.value = id - localStorage.setItem('currentconclusion', ConclusionId.value) + sessionStorage.setItem('currentconclusion', ConclusionId.value) } function getLabelsBySubCategory() { @@ -43,7 +43,7 @@ export const useQuestionStore = defineStore('question', () => { function getJsonLabels() { - const label_dict = JSON.parse(localStorage.getItem('labels') ?? '{}') + const label_dict = JSON.parse(sessionStorage.getItem('labels') ?? '{}') const label_list = Object.values(label_dict).map(String) return label_list } @@ -53,7 +53,7 @@ export const useQuestionStore = defineStore('question', () => { labels.value[question_id] = [] } labels.value[question_id].push(label) - localStorage.setItem('labels', JSON.stringify(labels.value)) + sessionStorage.setItem('labels', JSON.stringify(labels.value)) } function addLabelBySubCategory(label: string, subcategory: string | undefined) { @@ -62,7 +62,7 @@ export const useQuestionStore = defineStore('question', () => { LabelsBySubCategory.value[subcategory] = [] } LabelsBySubCategory.value[subcategory].push(label) - localStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) + sessionStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) } } @@ -76,7 +76,7 @@ export const useQuestionStore = defineStore('question', () => { LabelsBySubCategory.value[key] = ['niet van toepassing'] } } - localStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) + sessionStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) } function revertLabelsAtConclusion() { @@ -89,12 +89,12 @@ export const useQuestionStore = defineStore('question', () => { LabelsBySubCategory.value[key] = ['nader te bepalen'] } } - localStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) + sessionStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) } function addAnswer(id: string) { answers.value.push(id) - localStorage.setItem('answers', JSON.stringify(answers.value)) + sessionStorage.setItem('answers', JSON.stringify(answers.value)) } function revertAnswer(previousSubCategory: string) { @@ -108,10 +108,10 @@ export const useQuestionStore = defineStore('question', () => { } delete labels.value[QuestionId.value] } - localStorage.setItem('answers', JSON.stringify(answers.value)) - localStorage.setItem('currentquestion', QuestionId.value) - localStorage.setItem('labels', JSON.stringify(labels.value)) - localStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) + sessionStorage.setItem('answers', JSON.stringify(answers.value)) + sessionStorage.setItem('currentquestion', QuestionId.value) + sessionStorage.setItem('labels', JSON.stringify(labels.value)) + sessionStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) } function reset() { @@ -120,11 +120,11 @@ export const useQuestionStore = defineStore('question', () => { labels.value = {} LabelsBySubCategory.value = JSON.parse(initialLabelsBySubCategoryNTB) ConclusionId.value = '' - localStorage.setItem('answers', JSON.stringify(answers.value)) - localStorage.setItem('currentquestion', QuestionId.value) - localStorage.setItem('currentconclusion', ConclusionId.value) - localStorage.setItem('labels', JSON.stringify(labels.value)) - localStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) + sessionStorage.setItem('answers', JSON.stringify(answers.value)) + sessionStorage.setItem('currentquestion', QuestionId.value) + sessionStorage.setItem('currentconclusion', ConclusionId.value) + sessionStorage.setItem('labels', JSON.stringify(labels.value)) + sessionStorage.setItem('labelsbysubcategory', JSON.stringify(LabelsBySubCategory.value)) } function acceptDisclaimer() {