show category works

mic_level
Matthew Huntington 3 years ago
parent ae6286852f
commit 7261ad706f

@ -1,10 +1,17 @@
<script lang="ts"> <script lang="ts">
import axios from 'axios'; import axios from 'axios';
export default { export default {
data() { data() {
return { return {
categories:[] categories:[],
categorySessions:[]
}
},
methods: {
change(event){
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'show-category/'+event.target.value).then((response)=>{
this.categorySessions = response.data;
})
} }
}, },
mounted() { mounted() {
@ -17,13 +24,39 @@
<template> <template>
<h2>Show Category</h2> <h2>Show Category</h2>
<select> <select @change="change">
<option v-for="category in categories" v-bind:value="category.id"> <option v-for="category in categories" v-bind:value="category.id">
{{category.instrument}} {{category.instrument}}
: :
{{category.category}} {{category.category}}
</option> </option>
</select> </select>
<table>
<thead>
<tr>
<th>id</th>
<th>description</th>
<th>seconds</th>
<th>comments</th>
<th>created at</th>
<th>category id</th>
<th>category</th>
<th>instrument</th>
</tr>
</thead>
<tbody>
<tr v-for="session in categorySessions">
<td>{{session.id}}</td>
<td>{{session.description}}</td>
<td>{{session.seconds}}</td>
<td>{{session.comments}}</td>
<td>{{session.created_at}}</td>
<td>{{session.category_id}}</td>
<td>{{session.category}}</td>
<td>{{session.instrument}}</td>
</tr>
</tbody>
</table>
</template> </template>
<style scoped> <style scoped>

Loading…
Cancel
Save