<template>
  <div id="main">
    <!-- TODO: Kontakte erstellen und dem Kunden zuweisen    -->

    <UButton @click="router.push(`/customers/create/`)">+ Kunde</UButton>

    <UTable
        :rows="customers"
        :columns="customerColumns"
        @select="selectCustomer"

    />

  </div>
</template>

<script setup>

definePageMeta({
  middleware: "auth"
})

const router = useRouter()
const {customers } = storeToRefs(useDataStore())
const mode = ref("show")

const customerColumns = [
  {
    key: 'customerNumber',
    label: "Kundennr.",
    sortable: true
  },
  {
    key: "name",
    label: "Name",
    sortable: true
  }
]


const selectCustomer = (customer) => {
  console.log(customer)
  router.push(`/customers/show/${customer.id} `)
}
</script>

<style scoped>

</style>