aboutsummaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/EditInvoice.vue43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/views/EditInvoice.vue b/src/views/EditInvoice.vue
index 7a508f8..958846e 100644
--- a/src/views/EditInvoice.vue
+++ b/src/views/EditInvoice.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { ref, toRaw, onMounted } from 'vue'
+import { ref, onMounted, toRaw } from 'vue'
import { useRoute } from "vue-router"
import { useToast } from 'vue-toast-notification'
import axios from 'axios'
@@ -18,24 +18,43 @@ const route = useRoute()
const invoiceId = route.params.id
const invoice = ref(new Invoice())
-const isLoading = ref(true)
+const items = ref([])
+
+const invoiceIsLoading = ref(true)
+const itemsTableIsLoading = ref(true)
const getInvoice = async () => {
- isLoading.value = true
+ invoiceIsLoading.value = true
+ itemsTableIsLoading.value = true
try {
const r = await axios.get(`/invoice/${invoiceId}`)
invoice.value = r.data.data
+ items.value = r.data.data.Items
} catch (err) {
toast.error('An unhandled exception occoured. Please check logs')
console.error(err)
}
- isLoading.value = false
+ invoiceIsLoading.value = false
+ itemsTableIsLoading.value = false
}
-const refreshItems = () => {
- toast.success("Item was added but what happens after that hasn't been implemented yet!")
+const refreshItems = async () => {
+ items.value = []
+ itemsTableIsLoading.value = true
+
+ try {
+ const res = await axios.get(`/invoice/${invoiceId}/item`)
+ if (res.status === 200) {
+ items.value = res.data.data
+ }
+ } catch (err) {
+ toast.error('An unhandled exception occoured. Please check logs')
+ console.error(err)
+ }
+
+ itemsTableIsLoading.value = false
}
onMounted(() => {
@@ -44,7 +63,13 @@ onMounted(() => {
</script>
<template>
- <invoiceHeader :invoice="invoice" />
- <itemSelector :invoiceId="invoiceId" @added="refreshItems()"/>
- <invoiceItemsTable :invoiceId="invoiceId" />
+ <invoiceHeader
+ :invoice="invoice" />
+ <itemSelector
+ :invoiceId="invoiceId"
+ @added="refreshItems()"/>
+ <invoiceItemsTable
+ :items="items"
+ :isLoading="itemsTableIsLoading"
+ @refresh="refreshItems()" />
</template>