ecommerce / components / order-history
Invoice List
06-invoice-list.jsx
import { CheckIcon } from '@heroicons/react/24/outline'
const orders = [
{
number: 'WU88191111',
date: 'January 22, 2021',
datetime: '2021-01-22',
href: '#',
invoiceHref: '#',
total: '$302.00',
products: [
{
id: 1,
name: 'Nomad Tumbler',
description:
"This durable double-walled insulated tumbler keeps your beverages at the perfect temperature all day long. Hot, cold, or even lukewarm if you're weird like that, this bottle is ready for your next adventure.",
href: '#',
price: '$35.00',
status: 'out-for-delivery',
date: 'January 5, 2021',
datetime: '2021-01-05',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/order-history-page-06-product-01.jpg',
imageAlt: 'Olive drab green insulated bottle with flared screw lid and flat top.',
},
{
id: 2,
name: 'Leather Long Wallet',
description:
"We're not sure who carries cash anymore, but this leather long wallet will keep those bills nice and fold-free. The cashier hasn't seen print money in years, but you'll make a damn fine impression with your pristine cash monies.",
href: '#',
price: '$118.00',
status: 'delivered',
date: 'January 25, 2021',
datetime: '2021-01-25',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/order-history-page-06-product-02.jpg',
imageAlt:
'Leather long wallet held open with hand-stitched card dividers, full-length bill pocket, and simple tab closure.',
},
{
id: 3,
name: 'Minimalist Wristwatch',
description:
"This contemporary wristwatch has a clean, minimalist look and high quality components. Everyone knows you'll never use it to check the time, but wow, does that wrist look good with this timepiece on it.",
href: '#',
price: '$149.00',
status: 'delivered',
date: 'January 25, 2021',
datetime: '2021-01-25',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/order-history-page-06-product-03.jpg',
imageAlt:
'Wristwatch with black leather band, brass ring-3, white watch face, thin watch hands, and fine time markings.',
},
],
},
{
number: 'WU88191009',
date: 'January 5, 2021',
datetime: '2021-01-05',
href: '#',
invoiceHref: '#',
total: '$27.00',
products: [
{
id: 1,
name: 'Mini Sketchbook Set',
description:
'These pocket-sized sketchbooks feature recycled paper covers and screen printed designs from our top-selling poster collection. You have ideas, doodles, and notes, but nowhere to write them down. We have paper, wrapped in sturdier paper.',
href: '#',
price: '$27.00',
status: 'cancelled',
date: 'January 7, 2021',
datetime: '2021-01-07',
imageSrc: 'https://tailwindcss.com/plus-assets/img/ecommerce-images/order-history-page-06-product-04.jpg',
imageAlt: 'Set of three light and dark brown mini sketch books.',
},
],
},
]
export default function Example() {
return (
<div className="bg-white">
<div className="mx-auto max-w-4xl py-16 sm:px-6 sm:py-24">
<div className="px-4 sm:px-0">
<h1 className="text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl">Order history</h1>
<p className="mt-2 text-sm text-gray-500">
Check the status of recent orders, manage returns, and download invoices.
</p>
</div>
<div className="mt-16">
<h2 className="sr-only">Recent orders</h2>
<div className="space-y-16 sm:space-y-24">
{orders.map((order) => (
<div key={order.number}>
<h3 className="sr-only">
Order placed on <time dateTime={order.datetime}>{order.date}</time>
</h3>
<div className="bg-gray-50 px-4 py-6 sm:rounded-lg sm:p-6 md:flex md:items-center md:justify-between md:space-x-6 lg:space-x-8">
<dl className="flex-auto divide-y divide-gray-200 text-sm text-gray-600 md:grid md:grid-cols-3 md:gap-x-6 md:divide-y-0 lg:w-1/2 lg:flex-none lg:gap-x-8">
<div className="max-md:flex max-md:justify-between max-md:py-4 max-md:first:pt-0 max-md:last:pb-0">
<dt className="font-medium text-gray-900">Order number</dt>
<dd className="md:mt-1">{order.number}</dd>
</div>
<div className="max-md:flex max-md:justify-between max-md:py-4 max-md:first:pt-0 max-md:last:pb-0">
<dt className="font-medium text-gray-900">Date placed</dt>
<dd className="md:mt-1">
<time dateTime={order.datetime}>{order.date}</time>
</dd>
</div>
<div className="max-md:flex max-md:justify-between max-md:py-4 max-md:first:pt-0 max-md:last:pb-0">
<dt className="font-medium text-gray-900">Total amount</dt>
<dd className="font-medium text-gray-900 md:mt-1">{order.total}</dd>
</div>
</dl>
<div className="mt-6 space-y-4 sm:flex sm:space-y-0 sm:space-x-4 md:mt-0">
<a
href={order.href}
className="flex w-full items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-xs hover:bg-gray-50 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-hidden md:w-auto"
>
View Order
<span className="sr-only">{order.number}</span>
</a>
<a
href={order.invoiceHref}
className="flex w-full items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-xs hover:bg-gray-50 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-hidden md:w-auto"
>
View Invoice
<span className="sr-only">for order {order.number}</span>
</a>
</div>
</div>
<div className="mt-6 flow-root px-4 sm:mt-10 sm:px-0">
<div className="-my-6 divide-y divide-gray-200 sm:-my-10">
{order.products.map((product) => (
<div key={product.id} className="flex py-6 sm:py-10">
<div className="min-w-0 flex-1 lg:flex lg:flex-col">
<div className="lg:flex-1">
<div className="sm:flex">
<div>
<h4 className="font-medium text-gray-900">{product.name}</h4>
<p className="mt-2 hidden text-sm text-gray-500 sm:block">{product.description}</p>
</div>
<p className="mt-1 font-medium text-gray-900 sm:mt-0 sm:ml-6">{product.price}</p>
</div>
<div className="mt-2 flex text-sm font-medium sm:mt-4">
<a href={product.href} className="text-indigo-600 hover:text-indigo-500">
View Product
</a>
<div className="ml-4 border-l border-gray-200 pl-4 sm:ml-6 sm:pl-6">
<a href="#" className="text-indigo-600 hover:text-indigo-500">
Buy Again
</a>
</div>
</div>
</div>
<div className="mt-6 font-medium">
{product.status === 'delivered' ? (
<div className="flex space-x-2">
<CheckIcon aria-hidden="true" className="size-6 flex-none text-green-500" />
<p>
Delivered
<span className="hidden sm:inline">
{' '}
on <time dateTime={product.datetime}>{product.date}</time>
</span>
</p>
</div>
) : product.status === 'out-for-delivery' ? (
<p>Out for delivery</p>
) : product.status === 'cancelled' ? (
<p className="text-gray-500">Cancelled</p>
) : null}
</div>
</div>
<div className="ml-4 shrink-0 sm:order-first sm:m-0 sm:mr-6">
<img
alt={product.imageAlt}
src={product.imageSrc}
className="col-start-2 col-end-3 size-20 rounded-lg object-cover sm:col-start-1 sm:row-span-2 sm:row-start-1 sm:size-40 lg:size-52"
/>
</div>
</div>
))}
</div>
</div>
</div>
))}
</div>
</div>
</div>
</div>
)
}