Skip to content

Commit efbd667

Browse files
committed
feat: Implemented auction bid placement controls
1 parent cae9209 commit efbd667

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

frontend/src/pages/ProductDetail.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useParams, useNavigate } from "react-router-dom";
33
import { Button } from "../components/ui/button";
44
import { ArrowLeft } from "lucide-react";
55

6+
// Dummy product data
67
const allProducts = [
78
{
89
id: 1,
@@ -11,9 +12,8 @@ const allProducts = [
1112
description: "A comprehensive calculus guide ideal for engineering and science students. Covers differential, integral, and multivariable calculus with step-by-step examples and university-level exercises. Perfect for semester preparation and concept building.",
1213
images: ["/book1.jpg"],
1314
seller: { name: "Shubham", Used:"1.2 year", email: "[email protected]" },
14-
auction: { isAuction: false }
15+
auction: { isAuction: true, highestBid: 50, minIncrement: 5, timeLeft: "10h 45m" }
1516
},
16-
1717
{
1818
id: 2,
1919
title: "Laptop Stand",
@@ -61,7 +61,7 @@ const allProducts = [
6161
description: "Adjustable LED desk lamp with 3 brightness levels. Energy-efficient, flexible design suitable for night study sessions. USB rechargeable and portable — perfect for hostel or dorm desk setups.",
6262
images: ["/lamp1.jpg"],
6363
seller: { name: "Tony Stark", Used:"2 year", email: "[email protected]" },
64-
auction: { isAuction: false }
64+
auction: { isAuction: true, highestBid: 18, minIncrement: 2, timeLeft: "5h 20m" }
6565
},
6666

6767
{
@@ -88,26 +88,30 @@ const allProducts = [
8888
export default function ProductDetailsPage() {
8989
const { id } = useParams();
9090
const navigate = useNavigate();
91-
const product = allProducts.find((p) => p.id === parseInt(id));
9291

92+
// Find product by ID
93+
const product = allProducts.find((p) => p.id === parseInt(id));
9394
if (!product) return <div className="p-12 text-center">Product not found.</div>;
9495

9596
const [mainImage, setMainImage] = useState(product.images[0]);
97+
98+
// Local bid state
9699
const [bid, setBid] = useState(
97100
product.auction.isAuction ? product.auction.highestBid + product.auction.minIncrement : 0
98101
);
99102

100103
const placeBid = () => {
101-
if (bid > product.auction.highestBid) {
104+
if (bid >= product.auction.highestBid + product.auction.minIncrement) {
102105
alert(`Bid of ₹${bid} placed successfully!`);
106+
product.auction.highestBid = bid;
107+
setBid(bid + product.auction.minIncrement);
103108
} else {
104-
alert("Bid must be higher than current highest bid!");
109+
alert(`Bid must be at least ₹${product.auction.highestBid + product.auction.minIncrement}`);
105110
}
106111
};
107112

108113
return (
109114
<div className="relative min-h-screen bg-gradient-to-br from-blue-50 via-white to-blue-50 px-4 py-10">
110-
{/* Background Blobs */}
111115
<div className="absolute inset-0 -z-10">
112116
<div className="absolute -top-32 -left-32 w-96 h-96 bg-blue-400 rounded-full opacity-20 blur-3xl animate-blob"></div>
113117
<div className="absolute top-0 -right-32 w-96 h-96 bg-blue-400 rounded-full opacity-20 blur-3xl animate-blob animation-delay-2000"></div>

0 commit comments

Comments
 (0)