<script setup lang="ts">
import type { Product } from "~/types/interfaces";
const { data: products } = await useFetch<Product[]>("/api/products");
const page = ref(1);
const pageCount = ref(7);
const pageTotal = ref(products.value?.length);
const rows = computed(() => {
products.value?.slice(
(page.value - 1) * pageCount.value,
page.value * pageCount.value,
);
});
const columns = [
{
key: "image",
label: "Image",
},
{
key: "name",
label: "Produit",
sortable: true,
},
{
key: "price",
label: "Prix de vente",
sortable: true,
},
{
key: "",
label: "Statut",
},
{
key: "",
label: "Action",
},
];
<script setup lang="ts">
import type { Product } from "~/types/interfaces";
const { data: products } = await useFetch<Product[]>("/api/products");
const page = ref(1);
const pageCount = ref(7);
const pageTotal = ref(products.value?.length);
const rows = computed(() => {
products.value?.slice(
(page.value - 1) * pageCount.value,
page.value * pageCount.value,
);
});
const columns = [
{
key: "image",
label: "Image",
},
{
key: "name",
label: "Produit",
sortable: true,
},
{
key: "price",
label: "Prix de vente",
sortable: true,
},
{
key: "",
label: "Statut",
},
{
key: "",
label: "Action",
},
];