diff --git a/src/stores/stat.ts b/src/stores/stat.ts new file mode 100644 index 0000000..4f1785a --- /dev/null +++ b/src/stores/stat.ts @@ -0,0 +1,22 @@ +import api from '@/lib/api' +import { defineStore } from 'pinia' + +export const useStatStore = defineStore('stat', { + state: () => { + return { + allWords: 0, + knownWords: 0, + } + }, + getters: { + getAllWords: (state) => state.allWords, + getKnownWords: (state) => state.knownWords, + }, + actions: { + async fetchStats() { + const stats = await api.get('stats') + this.allWords = stats.all + this.knownWords = stats.known + } + } +}) \ No newline at end of file diff --git a/src/views/Stats.vue b/src/views/Stats.vue index b96fd2b..d24e332 100755 --- a/src/views/Stats.vue +++ b/src/views/Stats.vue @@ -1,8 +1,35 @@ - Stats + + + + + + Statistics + + + + + You have {{ getAllWords }} words in your library + + You have learned {{ getKnownWords }} words + +