'use client'; import React, { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import './OrderConfirmation.scss'; interface OrderDetails { orderNumber: string; totalAmount: number; email: string; date: string; paymentMethod?: string; } export default function OrderConfirmationPage() { const router = useRouter(); const [orderDetails, setOrderDetails] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { const hasOrderConfirmation = sessionStorage.getItem('orderConfirmation'); const orderDetailsStr = sessionStorage.getItem('orderDetails'); if (hasOrderConfirmation === 'true' && orderDetailsStr) { try { const parsedDetails = JSON.parse(orderDetailsStr); setOrderDetails(parsedDetails); } catch (e) { console.error('Failed to parse order details:', e); } } else { console.error('No order confirmation found in session storage'); } setIsLoading(false); return () => { sessionStorage.removeItem('orderConfirmation'); sessionStorage.removeItem('orderDetails'); }; }, [router]); if (isLoading) { return (
); } if (!orderDetails) { return (

No Order Information Found

We couldn't find any order details. Redirecting you to homepage...

Go to Homepage
); } return (

Order Confirmed!

Thank you for your purchase!

Your order has been received and is being processed. We've sent a confirmation email to {orderDetails.email}.

Order Summary

Order Number: {orderDetails.orderNumber}
Date: {new Date(orderDetails.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}
Total Amount: ${typeof orderDetails.totalAmount === 'number' ? orderDetails.totalAmount.toFixed(2) : parseFloat(String(orderDetails.totalAmount)).toFixed(2)}
Payment Method: {orderDetails.paymentMethod || 'Credit Card'}
Status:
Processing

What happens next?

  1. 1
    Order Processing

    Your order is being prepared for shipping.

  2. 2
    Shipping Notification

    You'll receive an email once your order has been shipped.

  3. 3
    Order Tracking

    Track your order status in the "My Orders" section of your account.

  4. 4
    Delivery

    Your package will be delivered to your shipping address.

View My Orders Continue Shopping
); }