|
|
|
|
@ -1,41 +1,34 @@
|
|
|
|
|
<script setup>
|
|
|
|
|
import { formatSeconds } from '../libs/time.js'
|
|
|
|
|
import CategoryChooser from './category_chooser.vue'
|
|
|
|
|
import { onMounted, ref, watch, defineProps, toRefs} from 'vue'
|
|
|
|
|
import { onMounted, ref, watch, defineProps } from 'vue'
|
|
|
|
|
|
|
|
|
|
const props = defineProps(['categories', 'instruments', 'currentWorkingCategory'])
|
|
|
|
|
const props = defineProps(['categories', 'instruments'])
|
|
|
|
|
const currentWorkingCategory = defineModel('currentWorkingCategory')
|
|
|
|
|
const currentWorkingInstrument = defineModel('currentWorkingInstrument')
|
|
|
|
|
|
|
|
|
|
const categorySessions = ref([])
|
|
|
|
|
|
|
|
|
|
const change = async (event) => {
|
|
|
|
|
const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'show-category/'+event.target.value)
|
|
|
|
|
categorySessions.value = await response.json()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const copy = (event) => {
|
|
|
|
|
navigator.clipboard.writeText(event.target.innerText)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const loadCategory = async (chosenCategoryID) => {
|
|
|
|
|
const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'show-category/'+chosenCategoryID)
|
|
|
|
|
const loadCategory = async () => {
|
|
|
|
|
const response = await fetch(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'show-category/'+currentWorkingCategory.value.id)
|
|
|
|
|
categorySessions.value = await response.json()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
loadCategory(props.currentWorkingCategory.id)
|
|
|
|
|
})
|
|
|
|
|
onMounted(loadCategory)
|
|
|
|
|
|
|
|
|
|
watch(() => props.currentWorkingCategory, (chosenCategory)=>{
|
|
|
|
|
loadCategory(chosenCategory.id)
|
|
|
|
|
})
|
|
|
|
|
watch(currentWorkingCategory, loadCategory)
|
|
|
|
|
defineExpose({loadCategory})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<h2>Show Category</h2>
|
|
|
|
|
<CategoryChooser
|
|
|
|
|
@update="loadCategory"
|
|
|
|
|
:currentWorkingCategory="props.currentWorkingCategory"
|
|
|
|
|
v-model:currentWorkingCategory="currentWorkingCategory"
|
|
|
|
|
v-model:currentWorkingInstrument="currentWorkingInstrument"
|
|
|
|
|
:instruments="props.instruments"
|
|
|
|
|
:categories="props.categories" />
|
|
|
|
|
<table>
|
|
|
|
|
|