Dev Helpers
← Back

Pick route ordering

Place this file at app/warehouse/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/warehouse/page.tsx

export default async function PickRouteOrdering({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
  const bins = [
    { id: "A01", sku: "pen", qty: 12, limit: 20 },
    { id: "B04", sku: "pad", qty: 3, limit: 15 },
    { id: "A09", sku: "pen", qty: 5, limit: 10 },
  ];
  const { sku } = await searchParams;
  return (
    <ol>
      {bins
        .filter((b) => b.sku === sku)
        .sort((a, b) => a.id.localeCompare(b.id))
        .map((b) => (
          <li key={b.id}>Visit {b.id}</li>
        ))}
    </ol>
  );
}