aboutsummaryrefslogtreecommitdiff
path: root/src/views/HomeView.vue
blob: 2092e6b5742794d9d5149fd7e99dbf30b87fd518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<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['ID']}`}">Invoice Number {{ draft["InvoiceNumber"] }}</RouterLink>
    </li>
  </ul>
</template>