<script setup lang="ts">
import { apiBase, makeColumns } from '~/helpers';
import type { ApiTypeList } from '~/helpers';

const headers = new Headers();
headers.append("Content-Type", "application/json");

const { data } = await useFetch<ApiTypeList>(`${apiBase}/partner/`, { headers })
</script>
<template>
    <div class="mb-4">
        <UButton icon="i-heroicons-plus" to="/organization/new">Новая инвентаризация</UButton>
    </div>
    <div class="mb-4">
        <UTable :rows="data?.results" :columns="makeColumns(['id', 'name', 'external_id', 'total_inventory'])">
            <template #name-data="{ row }">
                <NuxtLink :to="`/organization/p_${row.id}`">{{ row.name }}</NuxtLink>
            </template>
        </UTable>
    </div>
</template>