npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@haus-storefront-react/order

v0.0.50

Published

A headless component for displaying order details after an order has been placed.

Readme

Order

A headless component for displaying order details after an order has been placed.

Usage

import { Order } from '@haus-storefront-react/order'
import { Price } from '@haus-storefront-react/common-ui'
;<Order.Root orderCode="ABC123">
  {({ order, isLoading, error, isError, isSuccess }) => (
    <div>
      {isLoading && <div>Loading...</div>}
      {isError && error && <div>Error: {error.message}</div>}
      {isSuccess && order && (
        <div>
          <h2>Thank you for your order!</h2>
          <div>Order #{order.code}</div>
          <div>
            Order Placed:{' '}
            {order.orderPlacedAt ? new Date(order.orderPlacedAt).toLocaleDateString() : 'Unknown'}
          </div>
          <div>Status: {order.state}</div>

          {/* Order Items */}
          <Order.Items.Root>
            {order.lines.map((line) => (
              <Order.Items.Item key={line.id} orderLine={line}>
                <Order.Items.Image />
                <Order.Items.Price />
                {line.quantity} st
              </Order.Items.Item>
            ))}
          </Order.Items.Root>

          {/* Shipping Lines */}
          <Order.ShippingLines>
            {order.shippingLines?.map((shippingLine) => (
              <Order.ShippingLine
                key={shippingLine.id || shippingLine.shippingMethod.id}
                shippingLine={shippingLine}
              >
                <Order.ShippingLine.Name />
                <Order.ShippingLine.Price />
              </Order.ShippingLine>
            ))}
          </Order.ShippingLines>

          {/* Order Summary */}
          <Order.Summary>
            {({ subTotal, shipping, totalPrice, currencyCode }) => (
              <div>
                <div>
                  <span>Subtotal:</span>
                  <Price.Root price={subTotal} priceWithTax={subTotal} currencyCode={currencyCode}>
                    <Price.Amount withCurrency />
                    <Price.Currency />
                  </Price.Root>
                </div>
                <div>
                  <span>Shipping:</span>
                  <Price.Root price={shipping} priceWithTax={shipping} currencyCode={currencyCode}>
                    <Price.Amount withCurrency />
                    <Price.Currency />
                  </Price.Root>
                </div>
                <div>
                  <span>Total:</span>
                  <Price.Root
                    price={totalPrice}
                    priceWithTax={totalPrice}
                    currencyCode={currencyCode}
                  >
                    <Price.Amount withCurrency />
                    <Price.Currency />
                  </Price.Root>
                </div>
              </div>
            )}
          </Order.Summary>

          {/* Addresses */}
          <Order.Addresses.Root>
            <Order.Addresses.Shipping>
              {(shippingAddress) => (
                <>
                  <p>{shippingAddress?.fullName}</p>
                  <p>{shippingAddress?.streetLine1}</p>
                  {shippingAddress?.streetLine2 && <p>{shippingAddress.streetLine2}</p>}
                  <p>
                    {shippingAddress?.city}, {shippingAddress?.province}{' '}
                    {shippingAddress?.postalCode}
                  </p>
                  <p>{shippingAddress?.countryCode}</p>
                </>
              )}
            </Order.Addresses.Shipping>
            <Order.Addresses.Billing>
              {(billingAddress) => (
                <>
                  <p>{billingAddress?.fullName}</p>
                  <p>{billingAddress?.streetLine1}</p>
                  {billingAddress?.streetLine2 && <p>{billingAddress.streetLine2}</p>}
                  <p>
                    {billingAddress?.city}, {billingAddress?.province} {billingAddress?.postalCode}
                  </p>
                  <p>{billingAddress?.countryCode}</p>
                </>
              )}
            </Order.Addresses.Billing>
          </Order.Addresses.Root>
        </div>
      )}
    </div>
  )}
</Order.Root>

Components

Order.Root

Main component that fetches order data and provides context to child components. Accepts an orderCode prop and provides order data through a render prop function.

Props:

  • orderCode: string - The order code to fetch
  • children: (props: OrderContextValue) => React.ReactNode - Render prop function

Returns:

  • order: Order | null - The order data
  • isLoading: boolean - Loading state
  • error: Error | null - Error state
  • isError: boolean - Whether there's an error
  • isSuccess: boolean - Whether the request was successful

Order.Items

Container for order items and subcomponents.

<Order.Items.Root>
  {order.lines.map((line) => (
    <Order.Items.Item key={line.id} orderLine={line}>
      <Order.Items.Image />
      <Order.Items.Price />
      {line.quantity} st
    </Order.Items.Item>
  ))}
</Order.Items.Root>

Order.Items.Item

  • orderLine: The order line data to display

Order.Items.Image

  • Displays the product image for the order line

Order.Items.Price

  • Displays the price for the order line

Order.ShippingLines

Container for shipping lines.

<Order.ShippingLines>
  {order.shippingLines?.map((shippingLine) => (
    <Order.ShippingLine
      key={shippingLine.id || shippingLine.shippingMethod.id}
      shippingLine={shippingLine}
    >
      <Order.ShippingLine.Name />
      <Order.ShippingLine.Price />
    </Order.ShippingLine>
  ))}
</Order.ShippingLines>

Order.ShippingLine

Individual shipping line component with subcomponents:

  • Order.ShippingLine.Name: Displays the shipping method name
  • Order.ShippingLine.Price: Displays the shipping price

Order.Summary

Order summary with totals and checkout.

<Order.Summary>
  {({ subTotal, shipping, totalPrice, currencyCode }) => (
    <div>
      <div>Subtotal: {subTotal}</div>
      <div>Shipping: {shipping}</div>
      <div>Total: {totalPrice}</div>
    </div>
  )}
</Order.Summary>

Order.Addresses

Container for addresses and subcomponents.

<Order.Addresses.Root>
  <Order.Addresses.Shipping>{/* ... */}</Order.Addresses.Shipping>
  <Order.Addresses.Billing>{/* ... */}</Order.Addresses.Billing>
</Order.Addresses.Root>

Order.Addresses.Shipping

  • Render prop for shipping address

Order.Addresses.Billing

  • Render prop for billing address