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.

799 B
Raw Blame
import type { CustomerGroupCreateParams, CustomerGroupUpdateParams } from '@spree/admin-sdk'
import { blankToNull } from '@spree/dashboard-core'
import { requiredMessage } from '@spree/dashboard-ui'
import { z } from 'zod/v4'

export const customerGroupFormSchema = z.object({
  name: z
    .string()
    .trim()
    .min(1, { error: requiredMessage('name') }),
  description: z.string().trim().optional(),
})

export type CustomerGroupFormValues = z.infer<typeof customerGroupFormSchema>

export const CUSTOMER_GROUP_DEFAULTS: CustomerGroupFormValues = { name: '', description: '' }

export function customerGroupValuesToParams(
  v: CustomerGroupFormValues,
): CustomerGroupCreateParams & CustomerGroupUpdateParams {
  return {
    name: v.name,
    description: blankToNull(v.description),
  }
}