DDBS UI
commerce

Dates & Order IDs

Business-day delivery estimates, short date formatters and an order id generator for demo checkouts.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/commerce-dates.json
Fullscreen

Ordered Mon, 16 Nov

  • Express17 Nov
  • Standard19 Nov
  • Economy24 Nov
Order id DBS-56542

Usage

commerce-dates-example.tsx
"use client";

import { useState } from "react";
import { addBusinessDays, fmtDate, fmtShort, makeOrderId } from "@dbs/ui";

const START = new Date(2026, 10, 16);

export default function CommerceDatesExample() {
  const [orderId, setOrderId] = useState(() => makeOrderId("DBS", 48000));
  return (
    <div className="flex w-full max-w-md flex-col gap-3 text-sm">
      <p className="text-ink-muted">Ordered {fmtDate(START)}</p>
      <ul className="flex flex-col gap-2 rounded-xl border border-line bg-surface p-4">
        {[
          ["Express", 1],
          ["Standard", 3],
          ["Economy", 6],
        ].map(([label, days]) => (
          <li key={label} className="flex justify-between">
            <span>{label}</span>
            <span className="font-medium">
              {fmtShort(addBusinessDays(START, Number(days)))}
            </span>
          </li>
        ))}
      </ul>
      <div className="flex items-center justify-between rounded-xl border border-line p-4">
        <span>
          Order id <strong>{orderId}</strong>
        </span>
        <button
          type="button"
          onClick={() => setOrderId(makeOrderId("DBS", 48000))}
          className="rounded-full border border-line px-3 py-1 text-xs"
        >
          New
        </button>
      </div>
    </div>
  );
}