'use client'; import { useCart } from 'components/cart/cart-context'; import CartItemView from 'components/cart/cart-item'; import { OrderPayload } from 'lib/woocomerce/storeApi'; import { useState } from 'react'; export default function CheckoutPage() { const { cart } = useCart(); const initialState: OrderPayload = { shipping_address: { first_name: '', last_name: '', company: '', address_1: '', address_2: '', city: '', state: '', postcode: '', country: '' }, billing_address: { first_name: '', last_name: '', company: '', email: '', phone: '', address_1: '', address_2: '', city: '', state: '', postcode: '', country: '' }, payment_method: '', payment_data: [] }; const [formData, setFormData] = useState(initialState); const handleChangeShipping = (e: React.ChangeEvent) => { setFormData((prev) => ({ ...prev, shipping_address: { ...prev.shipping_address, [e.target.name]: e.target.value } })); }; const handleChangeBilling = (e: React.ChangeEvent) => { setFormData((prev) => ({ ...prev, billing_address: { ...prev.billing_address, [e.target.name]: e.target.value } })); }; return (

Checkout

    {cart && cart.items?.length && cart.items .sort((a, b) => a.name.localeCompare(b.name)) .map((item, i) => { return (
  • ); })}

Shipping info

Billing info

Payment

); }