2024-07-10 19:48:21 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<HeaderBar />
|
|
|
|
<div class="ma-8">
|
2024-07-10 20:38:10 +02:00
|
|
|
<div v-if="isPending">Loading...</div>
|
|
|
|
<div v-else-if="isError">Error: {{ error?.message }}</div>
|
|
|
|
<ul v-else-if="data">
|
|
|
|
<li v-for="group in data" :key="group.id">
|
|
|
|
<CategoryContainer :licenseGroupName="group.name" :licenses="group.licenses" />
|
|
|
|
</li>
|
|
|
|
</ul>
|
2024-07-10 19:48:21 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import HeaderBar from "./HeaderBar.vue";
|
|
|
|
import CategoryContainer from "./CategoryContainer.vue";
|
2024-07-10 20:38:10 +02:00
|
|
|
import { useQuery } from "@tanstack/vue-query";
|
|
|
|
import axios from "axios";
|
|
|
|
import { store } from "@/store";
|
|
|
|
|
|
|
|
interface LicenseGroup {
|
|
|
|
id: string,
|
|
|
|
name: string,
|
|
|
|
licenses: License[]
|
|
|
|
}
|
|
|
|
|
|
|
|
interface License {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
start?: Date,
|
|
|
|
end?: Date,
|
|
|
|
key: string,
|
|
|
|
amount?: number,
|
|
|
|
}
|
|
|
|
|
|
|
|
const {isPending, isError, data, error} = useQuery({
|
|
|
|
queryKey: ["licenses"],
|
|
|
|
queryFn: async () => {
|
|
|
|
const res = await axios.get<LicenseGroup[]>(import.meta.env.VITE_BACKEND_URL + "/licenses", {
|
|
|
|
headers: {
|
|
|
|
Authorization: `Bearer ${store.token}`
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return res.data
|
|
|
|
}
|
|
|
|
})
|
2024-07-10 19:48:21 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2024-07-10 20:38:10 +02:00
|
|
|
li, ul {
|
2024-07-10 19:48:21 +02:00
|
|
|
list-style-type: none;
|
|
|
|
}
|
|
|
|
</style>
|