Skip to content

Commit 5045478

Browse files
committed
added improved input validation on admin single product page
1 parent 95785c1 commit 5045478

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • app/(dashboard)/admin/products/[id]

app/(dashboard)/admin/products/[id]/page.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ const DashboardProductDetails = ({
4949

5050
// functionality for updating product
5151
const updateProduct = async () => {
52-
console.log(product);
52+
if (
53+
product?.title === "" ||
54+
product?.slug === "" ||
55+
product?.price.toString() === "" ||
56+
product?.manufacturer === "" ||
57+
product?.description === ""
58+
) {
59+
toast.error("You need to enter values in input fields");
60+
return;
61+
}
5362

5463
const requestOptions = {
5564
method: "PUT",

0 commit comments

Comments
 (0)