nuxt-prawo-jazdy/store/examStore.ts
NetMan 63121da4b7 postgres -> sqlite, pinia/middleware fix?
other smaller: little type fixes, little changes to ui - more readable category chooser
- result screen with correct, incorrect and chosen answers
little changes to readme
2025-12-13 16:07:23 +01:00

60 lines
1.3 KiB
TypeScript

export const useBasicStore = defineStore('basicStore', {
state: () => ({
basic: [] as ResultType[],
}),
actions: {
async set(basic: ResultType[]) {
this.basic = basic;
},
},
persist: {
storage: piniaPluginPersistedstate.localStorage(),
},
});
export const useAdvancedStore = defineStore('advancedStore', {
state: () => ({
advanced: [] as ResultType[],
}),
actions: {
async set(advanced: ResultType[]) {
this.advanced = advanced;
},
},
persist: {
storage: piniaPluginPersistedstate.localStorage(),
},
});
export const useExamStore = defineStore('examStore', {
state: () => ({
category: '',
end: false,
}),
actions: {
async setCategory(category: string) {
this.category = category;
},
async setEnd(end: boolean) {
this.end = end;
},
async setBasic(basic: ResultType[]) {
useBasicStore().set(basic);
},
async setAdvanced(advanced: ResultType[]) {
useAdvancedStore().set(advanced);
},
async mildReset() {
this.end = false;
this.setBasic([]);
this.setAdvanced([]);
},
async resetExam() {
this.category = '';
this.mildReset();
},
},
persist: {
storage: piniaPluginPersistedstate.cookies(),
},
});