diff --git a/src/App.vue b/src/App.vue index 1c8b488..8c22fa4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,6 +12,7 @@ const statusRef = ref(null) const showCategoryRef = ref(null) const instruments = ref([]) + const categories = ref([]) const updateCurrentWorkingCategoryID = (id) =>{ currentWorkingCategoryID.value = id @@ -24,8 +25,10 @@ } const loadData = async () => { - const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'instruments') + let response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'instruments') instruments.value = await response.json() + response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'categories') + categories.value = await response.json() } onMounted(loadData) @@ -34,13 +37,21 @@
- +
- +
diff --git a/src/components/show_category.vue b/src/components/show_category.vue index c2e4bfb..d4d6f4b 100644 --- a/src/components/show_category.vue +++ b/src/components/show_category.vue @@ -2,9 +2,8 @@ import CategoryChooser from './category_chooser.vue' import { onMounted, ref, watch, defineProps, toRefs} from 'vue' - const props = defineProps(['instruments', 'currentWorkingCategoryID']) + const props = defineProps(['categories', 'instruments', 'currentWorkingCategoryID']) - const categories = ref([]) const categorySessions = ref([]) const practiceCategoryId = ref(0) @@ -28,8 +27,6 @@ onMounted(async () => { practiceCategoryId.value = currentWorkingCategoryID loadCategory(currentWorkingCategoryID.value) - const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'categories') - categories.value = await response.json() }) watch(currentWorkingCategoryID, loadCategory) diff --git a/src/components/timer.vue b/src/components/timer.vue index 40d41c4..6f98232 100644 --- a/src/components/timer.vue +++ b/src/components/timer.vue @@ -4,10 +4,9 @@ import { getHours, getMinutes, createTimeObj, getAccumulatedSeconds, formatSeconds } from '../libs/time.js' export default { - props: ['currentWorkingCategoryID', 'instruments'], + props: ['categories', 'currentWorkingCategoryID', 'instruments'], data() { return { - categories:[], running: false, startTime:0, savedPreviousSeconds:0, @@ -153,9 +152,6 @@ }, mounted() { this.practice_category_id = this.currentWorkingCategoryID - axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'categories').then((response)=>{ - this.categories = response.data - }) this.totalSeconds = parseInt(window.localStorage.getItem('lastTotalSeconds')) this.setManualTime(this.totalSeconds) this.savedPreviousSeconds = this.totalSeconds @@ -195,14 +191,6 @@ :currentWorkingCategoryID="practice_category_id" :instruments="instruments" :categories="categories" /> - -