<script setup lang="ts">
import { useFetch } from '#app';
import { ref } from 'vue';
const tableContent = ref(await useFetch("/api/dbtest").data);
</script>

<template>
  <v-card width="min-content">
    <v-table>
      <thead>
        <tr>
          <th>id</th>
          <th>nazwa</th>
          <th>adres</th>
          <th>kontakt</th>
          <th />
        </tr>
      </thead>
      <tbody>
        <tr v-for="row in tableContent" :key="row.id">
          <td>{{ row.id }}</td>
          <td>{{ row.nazwa }}</td>
          <td>{{ row.adres }}</td>
          <td>{{ row.kontakt }}</td>
          <td>
            <v-btn-group variant="plain">
              <v-btn icon="mdi-pencil" color="main" />
              <v-btn icon="mdi-delete" color="red" />
            </v-btn-group>
          </td>
        </tr>
        <tr class="last">
          <td>*</td>
          <td><v-text-field label="nazwa" density="compact" /></td>
          <td><v-text-field label="adres" density="compact" /></td>
          <td><v-text-field label="kontakt" density="compact" /></td>
          <td><v-btn icon="mdi-plus" variant="plain" class="rounded" /></td>
        </tr>
      </tbody>
    </v-table>
  </v-card>
</template>

<style scoped>
  .last td:not(:last-child):not(:first-child) {
    padding-left: 0;
    padding-right: 0;
  }

</style>
