Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

1.1 KB
Raw Blame
import { z } from 'zod/v4'

/**
 * What the seller chose to send out of one parcel: per-line quantities plus
 * the tracking number and whether the customer hears about it.
 *
 * Every line the parcel holds gets a row, so an unselected row means "leave
 * this one behind" rather than being absent — the payload drops the
 * unselected rows on submit.
 *
 * The upper bound is per row (how many units that parcel holds), so it lives
 * on the field rather than in the schema; the schema only enforces that a
 * quantity is a whole number that is not negative. Sending nothing at all is
 * prevented by disabling the submit, since it is a no-op rather than a
 * validation failure.
 */
export const fulfillItemsFormSchema = z.object({
  items: z.array(
    z.object({
      item_id: z.string(),
      selected: z.boolean(),
      quantity: z.number().int().min(0),
    }),
  ),
  tracking: z.string(),
  // '' = detect from the number; slugs come from trackingCarriers.list().
  tracking_carrier: z.string(),
  notify_customer: z.boolean(),
})

export type FulfillItemsFormValues = z.infer<typeof fulfillItemsFormSchema>