Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (67 sloc) 2.17 KB
<template>
<div class="app-content">
<div class="app-block has-text-right">
<router-link :to="{name:'bills-new'}"
class="button is-success">New bill</router-link>
</div>
<table class="table is-fullwidth is-striped">
<thead>
<tr>
<td>Issued date</td>
<td>Due date</td>
<td>Total</td>
<td>Actions</td>
</tr>
</thead>
<tbody>
<tr v-for="bill in bills" :key="bill.billId">
<td>{{formatDate(bill.issuedDate)}}</td>
<td>{{formatDate(bill.dueDate)}}</td>
<td>EUR {{bill.total}}</td>
<td>
<b-button type="is-primary" v-on:click="openBill(bill.billId)">Open</b-button>
<b-button type="is-danger" v-on:click="removeBill(bill.billId)">Delete</b-button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import moment from 'moment'
import {getAuthConfig, getUserId} from '@/auth/AuthManager.js'
import {AxiosClient} from '@/http/AxiosClient.js'
export default {
data() {
return {
bills: []
}
},
methods: {
openBill(val){
this.$router.push({name: 'bill-one', params: {id: val}})
},
removeBill(id){
let url = 'bills/' + id
AxiosClient.delete(`${url}`, getAuthConfig()).then(response => {
this.$buefy.toast.open('Bill was removed')
this.bills = this.bills.filter(bill => {return bill.billId !== id})
}).catch(err => {console.log(err)})
},
getBills(){
let url = 'bills/all/' + getUserId()
AxiosClient.get(`${url}`, getAuthConfig()).then(response => {
this.bills = response.data
}).catch(err => {
console.log(err)
})
},
formatDate(date){
return moment.unix(date).format('DD.MM.YYYY')
}
},
created() {
this.getBills()
}
}
</script>
You can’t perform that action at this time.