main
vue 68 lines 1.76 KB
Raw
1 <template>
2 <div>
3 <div class="mb-4 flex items-center justify-between gap-5">
4 <div>
5 Total:
6 <strong class="font-mono">{{ totalCustomers }}</strong>
7 </div>
8 <div class="text-secondary text-right">Configure connections to your toolset</div>
9 </div>
10 <n-spin :show="loadingConnectors">
11 <div class="min-h-52">
12 <template v-if="connectorsList.length">
13 <ConnectorItem
14 v-for="connector of connectorsList"
15 :key="connector.id"
16 :connector
17 class="item-appear item-appear-bottom item-appear-005 mb-2"
18 @verified="getConnectors()"
19 @updated="getConnectors()"
20 />
21 </template>
22 <template v-else>
23 <n-empty v-if="!loadingConnectors" description="No items found" class="h-48 justify-center" />
24 </template>
25 </div>
26 </n-spin>
27 </div>
28 </template>
29
30 <script setup lang="ts">
31 import type { Connector } from "@/types/connectors.d"
32 import { NEmpty, NSpin, useMessage } from "naive-ui"
33 import { computed, onBeforeMount, ref } from "vue"
34 import Api from "@/api"
35 import ConnectorItem from "./ConnectorItem.vue"
36
37 const message = useMessage()
38 const loadingConnectors = ref(false)
39 const connectorsList = ref<Connector[]>([])
40
41 const totalCustomers = computed<number>(() => {
42 return connectorsList.value.length || 0
43 })
44
45 function getConnectors() {
46 loadingConnectors.value = true
47
48 Api.connectors
49 .getAll()
50 .then(res => {
51 if (res.data.success) {
52 connectorsList.value = res.data?.connectors || []
53 } else {
54 message.warning(res.data?.message || "An error occurred. Please try again later.")
55 }
56 })
57 .catch(err => {
58 message.error(err.response?.data?.message || "An error occurred. Please try again later.")
59 })
60 .finally(() => {
61 loadingConnectors.value = false
62 })
63 }
64
65 onBeforeMount(() => {
66 getConnectors()
67 })
68 </script>