feat: add company list for admins

This commit is contained in:
Veronika Fehérvíziová
2025-10-31 19:37:08 +01:00
parent 6c40e63edb
commit d583a4fcb0

View File

@@ -0,0 +1,85 @@
<script setup lang="ts">
import type { CompanyData } from '~/types/company_data';
definePageMeta({
middleware: ['sanctum:auth', 'admin-only'],
});
useSeoMeta({
title: "Partnerské firmy | ISOP",
ogTitle: "Partnerské firmy",
description: "Partnerské firmy ISOP",
ogDescription: "Partnerské firmy",
});
const headers = [
{ title: 'Názov', key: 'name', align: 'left' },
{ title: 'IČO', key: 'ico', align: 'left' },
{ title: 'Kontaktná osoba', key: 'contact_name', align: 'left' },
{ title: 'Telefón', key: 'phone', align: 'middle' },
{ title: 'E-mail', key: 'email', align: 'middle' },
{ title: 'Prijímajú študentov', key: 'hiring', align: 'middle' },
{ title: 'Operácie', key: 'ops', align: 'middle' },
];
const { data, error } = await useSanctumFetch<CompanyData[]>('/api/companies/simple');
</script>
<template>
<v-container fluid>
<v-card id="page-container-card">
<h1>Partnerské firmy</h1>
<hr />
<!-- spacer -->
<div style="height: 40px;"></div>
<!-- Chybová hláška -->
<v-alert v-if="error" density="compact" :text="error?.message" title="Chyba" type="error"
id="login-error-alert" class="mx-auto alert"></v-alert>
<div v-else>
<p>Aktuálne spolupracujeme s {{ data?.length }} firmami.</p>
<br />
<v-table>
<thead>
<tr>
<th v-for="header in headers" :class="'text-' + header.align">
<strong>{{ header.title }}</strong>
</th>
</tr>
</thead>
<tbody>
<tr v-for="item in data">
<td>{{ item.name }}</td>
<td>{{ item.ico }}</td>
<td>{{ item.contact.name }}</td>
<td>{{ item.contact.phone }}</td>
<td>{{ item.contact.email }}</td>
<td>{{ item.hiring ? "Áno" : "Nie" }}</td>
<td class="text-left">
<v-btn class="m-1 op-btn" density="compact" append-icon="mdi-pencil" base-color="orange"
:to="'/dashboard/admin/companies/edit/' + item.id">Editovať</v-btn>
<v-btn class="m-1 op-btn" density="compact" append-icon="mdi-trash-can-outline"
base-color="red" @click="async () => { }">Zmazať</v-btn>
</td>
</tr>
</tbody>
</v-table>
</div>
</v-card>
</v-container>
</template>
<style scoped>
#page-container-card {
padding-left: 10px;
padding-right: 10px;
}
.op-btn {
margin: 10px;
}
</style>