diff --git a/src/app/checkout/page.tsx b/src/app/checkout/page.tsx new file mode 100644 index 0000000..bdbe4e0 --- /dev/null +++ b/src/app/checkout/page.tsx @@ -0,0 +1,305 @@ +"use client"; + +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import ReactLenis from "lenis/react"; +import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered'; +import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal'; +import Input from '@/components/form/Input'; +import ButtonHoverBubble from '@/components/button/ButtonHoverBubble'; +import { useState } from "react"; + +export default function CheckoutPage() { + const [shippingInfo, setShippingInfo] = useState({ + fullName: "", address: "", city: "", state: "", zipCode: "", country: "" + }); + + const [paymentInfo, setPaymentInfo] = useState({ + cardNumber: "", cardName: "", expiryDate: "", cvv: "" + }); + + const [orderConfirmed, setOrderConfirmed] = useState(false); + + const handleShippingChange = (field: string, value: string) => { + setShippingInfo((prev) => ({ ...prev, [field]: value })); + }; + + const handlePaymentChange = (field: string, value: string) => { + setPaymentInfo((prev) => ({ ...prev, [field]: value })); + }; + + const handlePlaceOrder = async (e: React.FormEvent) => { + e.preventDefault(); + // Simulate API call for order placement + console.log("Placing order with:", shippingInfo, paymentInfo); + // In a real app, you'd send this to an API endpoint + const response = await fetch('/api/checkout', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ shippingInfo, paymentInfo, items: [] }) // Add actual cart items + }); + + if (response.ok) { + setOrderConfirmed(true); + console.log("Order placed successfully!"); + // Optionally clear cart or redirect + } else { + console.error("Order failed:", await response.json()); + alert("Order placement failed. Please try again."); + } + }; + + // Dummy order summary data + const orderItems = [ + { id: "prod-1", name: "Luxury Velocity Runner", price: 12500, quantity: 1 }, + { id: "prod-4", name: "Aura X Wireless Earbuds", price: 8999, quantity: 1 } + ]; + const subtotal = orderItems.reduce((sum, item) => sum + item.price * item.quantity, 0); + const shippingCost = 500; // Example + const total = subtotal + shippingCost; + + + if (orderConfirmed) { + return ( + + + + + + + + Order Confirmed! + Thank you for your purchase. Your order has been successfully placed. + + + + + + + ); + } + + + return ( + + + + + + + + + Checkout + + + {/* Shipping Information */} + + Shipping Information + + handleShippingChange("fullName", val)} + placeholder="Full Name" + required + ariaLabel="Full Name" + /> + handleShippingChange("address", val)} + placeholder="Address" + required + ariaLabel="Address" + /> + + handleShippingChange("city", val)} + placeholder="City" + required + ariaLabel="City" + /> + handleShippingChange("state", val)} + placeholder="State/Province" + required + ariaLabel="State/Province" + /> + + + handleShippingChange("zipCode", val)} + placeholder="Zip Code" + required + ariaLabel="Zip Code" + /> + handleShippingChange("country", val)} + placeholder="Country" + required + ariaLabel="Country" + /> + + + + + {/* Order Summary & Payment */} + + {/* Order Summary */} + + Order Summary + + {orderItems.map((item) => ( + + {item.name} (x{item.quantity}) + ₹{(item.price * item.quantity).toLocaleString()} + + ))} + + + Subtotal + ₹{subtotal.toLocaleString()} + + + Shipping + ₹{shippingCost.toLocaleString()} + + + Total + ₹{total.toLocaleString()} + + + + + + {/* Payment Information */} + + Payment Information + + handlePaymentChange("cardName", val)} + placeholder="Name on Card" + required + ariaLabel="Name on Card" + /> + handlePaymentChange("cardNumber", val)} + placeholder="Card Number" + type="text" + inputMode="numeric" + pattern="[0-9]{13,16}" // Basic card number pattern + required + ariaLabel="Card Number" + /> + + handlePaymentChange("expiryDate", val)} + placeholder="MM/YY" + type="text" + pattern="(0[1-9]|1[0-2])\/?([0-9]{2})" // MM/YY pattern + required + ariaLabel="Expiry Date" + /> + handlePaymentChange("cvv", val)} + placeholder="CVV" + type="text" + pattern="[0-9]{3,4}" // CVV pattern + required + ariaLabel="CVV" + /> + + + + + {/* Place Order Button */} + + + + + + + + + + + + ); +}
Thank you for your purchase. Your order has been successfully placed.