From 3c6ed6088cbaf58d37bf1da589cd8f95ffc4bc8e Mon Sep 17 00:00:00 2001 From: bender Date: Mon, 23 Mar 2026 21:50:28 +0000 Subject: [PATCH] Update src/app/checkout/page.tsx --- src/app/checkout/page.tsx | 292 +++++++++++++++++++++++--------------- 1 file changed, 174 insertions(+), 118 deletions(-) diff --git a/src/app/checkout/page.tsx b/src/app/checkout/page.tsx index 938e0bb..f78de94 100644 --- a/src/app/checkout/page.tsx +++ b/src/app/checkout/page.tsx @@ -1,154 +1,210 @@ 'use client'; -import React, { useState } from 'react'; -import { ThemeProvider } from '@/components/theme/ThemeProvider'; +import { ThemeProvider } from '@/providers/themeProvider/ThemeProvider'; import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay'; -import { CartProvider, useCart } from '@/components/cart/CartProvider'; -import { useRouter } from 'next/navigation'; -import { Package, CreditCard } from 'lucide-react'; -import Link from 'next/link'; +import FooterCard from '@/components/sections/footer/FooterCard'; +import { useCart } from '@/components/cart/CartProvider'; +import { CreditCard, Truck, Receipt, Facebook, Twitter, Instagram } from 'lucide-react'; +import React, { useState } from 'react'; const CheckoutPageContent = () => { - const { cartItems, getCartTotal, clearCart } = useCart(); - const router = useRouter(); - const cartTotal = getCartTotal(); - - const [shippingInfo, setShippingInfo] = useState({ - fullName: '', + const { cartItems, getTotalPrice, clearCart } = useCart(); + const [formData, setFormData] = useState({ + name: '', + email: '', address: '', city: '', zip: '', - country: '', + cardNumber: '', + cardExpiry: '', + cardCVC: '', }); + const [orderConfirmed, setOrderConfirmed] = useState(false); - const handleInputChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setShippingInfo((prev) => ({ ...prev, [name]: value })); + const handleChange = (e) => { + setFormData({ ...formData, [e.target.name]: e.target.value }); }; - const handlePlaceOrder = (paymentMethod: string) => { - if (cartItems.length === 0) { - alert('Your cart is empty. Please add items before checking out.'); - router.push('/products'); - return; - } - - if (!shippingInfo.fullName || !shippingInfo.address || !shippingInfo.city || !shippingInfo.zip || !shippingInfo.country) { - alert('Please fill in all shipping information.'); - return; - } - - alert(`Order placed successfully with ${paymentMethod}! Total: $${cartTotal.toFixed(2)}`); - clearCart(); - router.push('/products'); // Redirect to products after checkout + const handleSubmit = (e) => { + e.preventDefault(); + // Simulate order processing + console.log('Order submitted:', formData, 'Items:', cartItems); + setOrderConfirmed(true); + clearCart(); // Clear cart after successful order }; - if (cartItems.length === 0) { + const navItems = [ + { name: 'Products', id: '/products' }, + { name: 'Cart', id: '/cart' }, + { name: 'Checkout', id: '/checkout' }, + ]; + + if (orderConfirmed) { return ( -
-

- - Checkout -

-
-

Your cart is empty. Nothing to checkout.

- - Go to Products - + <> + +
+ +

Order Confirmed!

+

Thank you for your purchase. Your order will be shipped soon.

+ Continue Shopping +
+ -
+ ); } return ( -
-

- - Checkout -

+ <> + +
+

+ Checkout +

-
-
-

- - Shipping Information -

-
+ {cartItems.length === 0 ? ( +

Your cart is empty. Please add items before checking out.

+ ) : ( +
- - -
-
- - -
-
-
- - -
-
- - -
-
-
- - -
- -
+

Shipping Information

+
+ + + +
+ + +
-
-

- - Order Summary -

-
- {cartItems.map((item) => ( -
- {item.name} x {item.quantity} - ${(item.price * item.quantity).toFixed(2)} +

Payment Information

+ +
+ + +
+ + + +
+ +
+

Order Summary

+
+ {cartItems.map((item) => ( +
+ {item.name} (x{item.quantity}) + ${(parseFloat(item.price) * item.quantity).toFixed(2)} +
+ ))} +
+ Total: + ${getTotalPrice().toFixed(2)} +
- ))} -
- Total: - ${cartTotal.toFixed(2)}
-
- - -
-
+ )} +
+ -
+ ); }; export default function CheckoutPage() { return ( - - - - + ); }