From ed4a78f37332966bcdd4c113f56e78984eee120f Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Sun, 1 Sep 2024 12:20:04 -0400 Subject: [PATCH] using v-model on summary --- src/App.vue | 9 ++++----- src/components/summary.vue | 13 ++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index fb3bb7d..56b11d5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,10 +14,6 @@ const instruments = ref([]) const categories = ref([]) - const updateCurrentWorkingCategory = (summarizedCategory) =>{ - currentWorkingCategory.value = categories.value.find(category => category.id === summarizedCategory.category_id) - } - const refreshPage = (session) => { summaryRef.value.loadData() statusRef.value.loadData() @@ -46,7 +42,10 @@ :currentWorkingCategory="currentWorkingCategory"/>
- +
import { onMounted, ref, defineExpose } from 'vue' + const props = defineProps(['categories']) + const currentWorkingCategory = defineModel() + const emit = defineEmits(['update']) - const categories = ref([]) + const summary = ref([]) const loadData = async () => { const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'summary') - categories.value = await response.json() + summary.value = await response.json() } onMounted(loadData) - const setWorkingCategory = (category) => { - emit('update', category) + const setWorkingCategory = (choice) => { + currentWorkingCategory.value = props.categories.find(category => category.id === choice.category_id) } defineExpose({loadData}) @@ -31,7 +34,7 @@ - + {{category.category_id}} {{category.category}} {{category.chunks_practiced}}