38 lines
1.3 KiB
Vue
38 lines
1.3 KiB
Vue
<script setup>
|
|
definePageMeta({
|
|
layout:"custom",
|
|
middleware: ["auth"]
|
|
});
|
|
|
|
//const {listings} = useCars();
|
|
var user = useSupabaseUser();
|
|
// const {data:listings} = await useFetch(`/api/car/listings/user/${user.id}`);
|
|
const {data:listings, refresh} = await useFetch(`/api/car/listings/user/ff2191d3-414d-4d7a-b6a6-1086456ec74a`); // dummy - test mit directus
|
|
|
|
const handleDelete = async (id) => {
|
|
console.log("handleDelete");
|
|
await $fetch(`/api/car/listings/${id}`,{
|
|
method:"delete"
|
|
});
|
|
|
|
listings.value = listings.value.filter(_ => _.id != id);
|
|
refresh();
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<div class="flex justify-between mt-24 items-center">
|
|
<h1 class="text-6xl">My Listings</h1>
|
|
<NuxtLink to="/profile/listings/create"
|
|
class="w-9 h-9 bg-blue-400 flex justify-center items-center rounded-full text-white font-bold cursor-pointer">
|
|
+
|
|
</NuxtLink>
|
|
</div>
|
|
<div class="shadow rounded p-3 mt-5">
|
|
|
|
<CarListingCard v-for="listing in listings" :key="listing.id" :listing="listing"
|
|
@deleteClick="handleDelete"/>
|
|
</div>
|
|
</div>
|
|
</template> |