From d5fab4fefaa3e63c1cda945cf556a0ecfdfa0170 Mon Sep 17 00:00:00 2001
From: Vidhu Kant Sharma <vidhukant@vidhukant.com>
Date: Mon, 4 Dec 2023 01:52:46 +0530
Subject: showing drafts on homepage

---
 src/views/HomeView.vue | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

(limited to 'src/views/HomeView.vue')

diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 6b087a7..0a5bf4d 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -1,5 +1,39 @@
-<script setup lang="ts"></script>
+<script setup lang="ts">
+import { ref, onMounted } from 'vue'
+import { RouterLink } from 'vue-router'
+import axios from 'axios'
+
+const isLoading = ref(false)
+const allDrafts = ref([])
+
+const getAllDrafts = async () => {
+  allDrafts.value = []
+  isLoading.value = true
+
+  try {
+    const res = await axios.get('/invoice/draft')
+    if (res.status === 200) {
+      allDrafts.value = res.data.data
+    }
+  } catch (err) {
+    toast.error('An unhandled exception occoured. Please check logs')
+    console.error(err)
+  }
+
+  isLoading.value = false
+}
+
+onMounted(() => {
+  getAllDrafts()
+})
+</script>
 
 <template>
   <h1>OpenBills Home Page</h1>
+  <h2>Draft Invoices:</h2>
+  <ul>
+    <li v-for="draft in allDrafts" :key="draft['ID']">
+      <RouterLink :to="{path: `/invoice/edit-draft/${draft['ID']}`}">Invoice Number {{ draft["InvoiceNumber"] }}</RouterLink>
+    </li>
+  </ul>
 </template>
-- 
cgit v1.2.3

