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.

781 B
Raw Blame
import { z } from 'zod/v4'

/**
 * One origin group of a delivery profile. An empty name is the nameless
 * default group, which the UI renders as "All locations"; an empty
 * `stock_location_ids` means the group ships from every store location.
 */
export const deliveryOriginGroupFormSchema = z.object({
  name: z.string(),
  stock_location_ids: z.array(z.string()),
})

export type DeliveryOriginGroupFormValues = z.infer<typeof deliveryOriginGroupFormSchema>

export const DELIVERY_ORIGIN_GROUP_DEFAULTS: DeliveryOriginGroupFormValues = {
  name: '',
  stock_location_ids: [],
}

export function deliveryOriginGroupValuesToParams(values: DeliveryOriginGroupFormValues) {
  return {
    name: values.name.trim() || null,
    stock_location_ids: values.stock_location_ids,
  }
}