aboutsummaryrefslogtreecommitdiff
path: root/src/views/EditInvoice.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/EditInvoice.vue')
-rw-r--r--src/views/EditInvoice.vue47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/views/EditInvoice.vue b/src/views/EditInvoice.vue
new file mode 100644
index 0000000..983e9ef
--- /dev/null
+++ b/src/views/EditInvoice.vue
@@ -0,0 +1,47 @@
+<script setup lang="ts">
+import { ref, toRaw, onMounted } from 'vue'
+import { useRoute } from "vue-router"
+import { useToast } from 'vue-toast-notification'
+import axios from 'axios'
+
+import Invoice from "./../classes/invoice"
+
+import invoiceHeader from './../components/invoice_header.vue'
+import itemSelector from './../components/item_selector.vue'
+
+const toast = useToast({
+ position: 'top-right'
+})
+
+const route = useRoute()
+
+const invoice = ref(new Invoice())
+const isLoading = ref(true)
+
+const getInvoice = async () => {
+ isLoading.value = true
+
+ try {
+ const r = await axios.get(`/invoice/${route.params.id}`)
+ invoice.value = r.data.data
+ } catch (err) {
+ toast.error('An unhandled exception occoured. Please check logs')
+ console.error(err)
+ }
+
+ isLoading.value = false
+}
+
+const refreshItems = () => {
+ toast.success("Item was added but what happens after that hasn't been implemented yet!")
+}
+
+onMounted(() => {
+ getInvoice()
+})
+</script>
+
+<template>
+ <invoiceHeader :invoice="invoice" />
+ <itemSelector :invoiceId="invoice.ID" @added="refreshItems()"/>
+</template>