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,
    lang: 'pl',
  }),
  actions: {
    async setCategory(category: string) {
      this.category = category;
    },
    async setEnd(end: boolean) {
      this.end = end;
    },
    async setLang(lang: string) {
      this.lang = lang;
    },
    async mildReset() {
      this.end = false;
      useBasicStore().set([]);
      useAdvancedStore().set([]);
    },
    async resetExam() {
      this.category = '';
      this.mildReset();
    },
  },
  persist: {
    storage: piniaPluginPersistedstate.cookies(),
  },
});
