ÜRÜN İLANINI KALDIR
```javascript
export async function deleteProduct(id) {
try {
const session = await auth();
if (!session) {
return { message: "User not authenticated!" };
}
const foundProduct = await prisma.product.findUnique({
where: {
id,
},
});
if (!foundProduct) {
return { message: "Product not found!" };
}
if (foundProduct.sellerId !== session.user.id) {
return { message: "You are not the seller of this product!" };
}
await prisma.product.delete({
where: {
id,
},
});
} catch (error) {
console.error("Error deleting product:", error);
return { message: "Something went wrong!" };
}
redirect("/myproducts")
}
```
Last updated