diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-03 22:16:22 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-03 22:16:22 +0530 |
commit | 37ef1ab2f544a05b5878c5bdaafd37155a054289 (patch) | |
tree | bd2ca480a33b16dd795d7f2a9047d12734f5c61e /src/views | |
parent | 511e5f3badb871a4407a1cfef2d17a8c99660d30 (diff) |
added invoice edit page0.1.0
Diffstat (limited to 'src/views')
-rw-r--r-- | src/views/EditInvoice.vue | 47 | ||||
-rw-r--r-- | src/views/NewInvoice.vue | 4 |
2 files changed, 49 insertions, 2 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> diff --git a/src/views/NewInvoice.vue b/src/views/NewInvoice.vue index b2f32e2..06d3ec7 100644 --- a/src/views/NewInvoice.vue +++ b/src/views/NewInvoice.vue @@ -1,7 +1,7 @@ <script setup lang="ts"> -import invoiceHeader from './../components/invoice_header.vue' +import invoiceHeaderEditor from './../components/invoice_header_editor.vue' </script> <template> - <invoiceHeader /> + <invoiceHeaderEditor /> </template> |