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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Build the company address book on the shared address dialog
Damian Legawiec6a945fb90a6a
diff --git a/packages/dashboard-core/src/components/address-form-dialog.tsx b/packages/dashboard-core/src/components/address-form-dialog.tsxindex 4b0efc3433..a79a5c1957 100644--- a/packages/dashboard-core/src/components/address-form-dialog.tsx+++ b/packages/dashboard-core/src/components/address-form-dialog.tsx@@ -3,6 +3,7 @@ import {Button,Checkbox,Field,+ FieldDescription,FieldError,FieldGroup,FieldLabel,@@ -152,6 +153,8 @@ export function AddressFormDialog({showLabel = false,showDefaultFlags = false,business = false,+ companyReadOnly = false,+ description,}: {address: EditableAddress | null | undefinedopen: boolean@@ -163,6 +166,14 @@ export function AddressFormDialog({showDefaultFlags?: boolean/** Addressed to a company rather than a person — see the schemas above. */business?: boolean+ /**+ * Show the company line but do not let it be edited. For an address whose+ * owner already answers the question — a company node names itself, so+ * there is nothing for the merchant to type.+ */+ companyReadOnly?: boolean+ /** Overrides the standard "update the address details" blurb. */+ description?: string}) {const { t } = useTranslation()const resolvedTitle = title ?? t('admin.components.address_form_dialog.edit_title')@@ -232,7 +243,7 @@ export function AddressFormDialog({<SheetHeader><SheetTitle>{resolvedTitle}</SheetTitle><SheetDescription>- {t('admin.components.address_form_dialog.description')}+ {description ?? t('admin.components.address_form_dialog.description')}</SheetDescription></SheetHeader><form@@ -260,8 +271,13 @@ export function AddressFormDialog({<Inputid="addr-co"aria-invalid={!!errors.company || undefined}+ disabled={companyReadOnly}+ readOnly={companyReadOnly}{...form.register('company')}/>+ {companyReadOnly && (+ <FieldDescription>{t('admin.fields.company.help')}</FieldDescription>+ )}<FieldError errors={[errors.company]} /></Field>) : (diff --git a/packages/dashboard/src/components/spree/address-fieldset.tsx b/packages/dashboard/src/components/spree/address-fieldset.tsxdeleted file mode 100644index 98329df5ee..0000000000--- a/packages/dashboard/src/components/spree/address-fieldset.tsx+++ /dev/null@@ -1,229 +0,0 @@-import { CountryCombobox, StateCombobox, useCountryStates } from '@spree/dashboard-core'-import { Field, FieldDescription, FieldError, FieldLabel, Input } from '@spree/dashboard-ui'-import {- Controller,- type FieldValues,- type Path,- type FieldError as RhfFieldError,- type UseFormReturn,-} from 'react-hook-form'-import { useTranslation } from 'react-i18next'--/**- * The address block every form that captures one shares — name, street, city,- * postal code, country/state pickers and phone.- *- * Generic over the form values so a page carrying an address under any key can- * use it; `prefix` names that key. Omit it when the address fields sit at the- * top level of the form, as they do for a company's address book entry.- *- * **Reach for `AddressFormDialog` (dashboard-core) first** — it owns one- * address end to end, with its own sheet, Zod validation and 422 mapping, and- * is what orders, customers and sellers use. This fieldset is for the case it- * cannot serve: a form editing *several* addresses at once, where the fields- * have to live inside a form the page already owns (a company location edits- * billing and shipping together behind one "same as billing" toggle).- *- * Stock locations deliberately use neither: they are not addresses but a model- * with its own flat columns and vocabulary (`zipcode`, `state_text`), so- * sharing would mean a field-name mapping layer between form and API.- */-export function AddressFieldset<TValues extends FieldValues>({- form,- prefix,- legend,- companyName,- withLabel = false,-}: {- form: UseFormReturn<TValues>- /**- * The form key holding the address block, e.g. `billing_address`. Omit when- * the fields live at the top level of the form.- */- prefix?: Path<TValues>- legend?: string- /**- * The business this address belongs to, shown read-only above the contact- * name. Pass it where the owner already answers the question — a company- * node names itself, so there is nothing for the merchant to type.- */- companyName?: string- /**- * Renders the address-book label field. Only a form whose address is a book- * entry wants it; an order's or a seller's address has nothing to file.- */- withLabel?: boolean-}) {- const { t } = useTranslation()- // Paths are composed as strings and cast once here: RHF cannot infer that- // `${prefix}.city` is a key of TValues, and spelling every field out as a- // generic parameter would make every caller declare its address shape twice.- const path = (field: string) => (prefix ? `${prefix}.${field}` : field) as Path<TValues>- const countryCode = form.watch(path('country_code')) as string | undefined- const { states } = useCountryStates(countryCode)-- // Server-side validation errors land under the same nested path the fields- // are registered at, so each one renders beside the input it belongs to- // rather than as one banner the merchant has to map back themselves.- const errorFor = (field: string): RhfFieldError | undefined => {- const errors = form.formState.errors as Record<string, unknown>- const block = (prefix ? errors[prefix] : errors) as Record<string, RhfFieldError> | undefined-- return block?.[field]- }-- // A form that is *only* an address needs no grouping chrome — the sheet- // heading already says what these fields are. The border and legend are for- // a form carrying several addresses at once.- const Wrapper = legend ? 'fieldset' : 'div'-- return (- <Wrapper- className={legend ? 'flex flex-col gap-4 rounded-md border p-4' : 'flex flex-col gap-4'}- >- {legend && <legend className="px-1 font-medium text-sm">{legend}</legend>}-- {withLabel && (- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-label`}>- {t('admin.fields.company_address.label.label')}- </FieldLabel>- <Input- id={`${prefix ?? 'address'}-label`}- placeholder={t('admin.fields.company_address.label.placeholder')}- {...form.register(path('label'))}- />- <FieldDescription>{t('admin.fields.company_address.label.help')}</FieldDescription>- <FieldError errors={[errorFor('label')]} />- </Field>- )}-- {companyName && (- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-company`}>- {t('admin.fields.company.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-company`} value={companyName} disabled readOnly />- <FieldDescription>{t('admin.fields.company.help')}</FieldDescription>- </Field>- )}-- <div className="grid gap-4 sm:grid-cols-2">- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-first-name`}>- {t('admin.fields.first_name.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-first-name`} {...form.register(path('first_name'))} />- <FieldError errors={[errorFor('first_name')]} />- </Field>- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-last-name`}>- {t('admin.fields.last_name.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-last-name`} {...form.register(path('last_name'))} />- <FieldError errors={[errorFor('last_name')]} />- </Field>- </div>-- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-address1`}>- {t('admin.fields.address1.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-address1`} {...form.register(path('address1'))} />- <FieldError errors={[errorFor('address1')]} />- </Field>-- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-address2`}>- {t('admin.fields.address2.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-address2`} {...form.register(path('address2'))} />- <FieldError errors={[errorFor('address2')]} />- </Field>-- <div className="grid gap-4 sm:grid-cols-2">- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-city`}>- {t('admin.fields.city.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-city`} {...form.register(path('city'))} />- <FieldError errors={[errorFor('city')]} />- </Field>- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-postal-code`}>- {t('admin.fields.postal_code.label')}- </FieldLabel>- <Input- id={`${prefix ?? 'address'}-postal-code`}- {...form.register(path('postal_code'))}- />- <FieldError errors={[errorFor('postal_code')]} />- </Field>- </div>-- <div className="grid gap-4 sm:grid-cols-2">- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-country`}>- {t('admin.fields.country.label')}- </FieldLabel>- <Controller- name={path('country_code')}- control={form.control}- render={({ field }) => (- <CountryCombobox- value={field.value}- onValueChange={(iso) => {- field.onChange(iso)- form.setValue(path('state_code'), '' as never, { shouldDirty: true })- }}- />- )}- />- <FieldError errors={[errorFor('country_code')]} />- </Field>- {/* A country Spree has no subdivision list for still needs somewhere- to put a region, so the picker falls back to a plain field rather- than vanishing — otherwise the address simply cannot be completed. */}- {countryCode && states.length > 0 ? (- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-state`}>- {t('admin.fields.state.label')}- </FieldLabel>- <Controller- name={path('state_code')}- control={form.control}- render={({ field }) => (- <StateCombobox- countryCode={countryCode}- states={states}- value={field.value}- onValueChange={field.onChange}- />- )}- />- <FieldError errors={[errorFor('state_code')]} />- </Field>- ) : (- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-state-name`}>- {t('admin.fields.state_name.label')}- </FieldLabel>- <Input- id={`${prefix ?? 'address'}-state-name`}- {...form.register(path('state_name'))}- />- <FieldError errors={[errorFor('state_name')]} />- </Field>- )}- </div>-- <Field>- <FieldLabel htmlFor={`${prefix ?? 'address'}-phone`}>- {t('admin.fields.phone.label')}- </FieldLabel>- <Input id={`${prefix ?? 'address'}-phone`} {...form.register(path('phone'))} />- <FieldError errors={[errorFor('phone')]} />- </Field>- </Wrapper>- )-}diff --git a/packages/dashboard/src/components/spree/company-address-sheet.tsx b/packages/dashboard/src/components/spree/company-address-sheet.tsxindex 11a092cdc0..d7964e1126 100644--- a/packages/dashboard/src/components/spree/company-address-sheet.tsx+++ b/packages/dashboard/src/components/spree/company-address-sheet.tsx@@ -1,32 +1,14 @@-import { zodResolver } from '@hookform/resolvers/zod'import type { Address } from '@spree/admin-sdk'-import { mapSpreeErrorsToForm } from '@spree/dashboard-core'-import {- Button,- Checkbox,- FieldGroup,- Sheet,- SheetContent,- SheetDescription,- SheetFooter,- SheetHeader,- SheetTitle,-} from '@spree/dashboard-ui'-import { useEffect } from 'react'-import { Controller, useForm } from 'react-hook-form'+import { AddressFormDialog } from '@spree/dashboard-core'import { useTranslation } from 'react-i18next'import { useCreateCompanyAddress, useUpdateCompanyAddress } from '../../hooks/use-companies'-import {- COMPANY_ADDRESS_DEFAULTS,- type CompanyAddressFormValues,- companyAddressFormSchema,- companyAddressValuesToParams,-} from '../../schemas/company'-import { AddressFieldset } from './address-fieldset'/*** Creates an entry in a company node's address book, or edits one. The node* owns the address outright, and points at one entry per kind as its default.+ *+ * A thin wrapper over the shared dialog: a book entry is an ordinary address+ * addressed to the company, which is exactly what `business` mode asks for.*/export function CompanyAddressSheet({companyId,@@ -45,125 +27,51 @@ export function CompanyAddressSheet({const createMutation = useCreateCompanyAddress(companyId)const updateMutation = useUpdateCompanyAddress(companyId)- const form = useForm<CompanyAddressFormValues>({- // eslint-disable-next-line @typescript-eslint/no-explicit-any- resolver: zodResolver(companyAddressFormSchema) as any,- defaultValues: COMPANY_ADDRESS_DEFAULTS,- })-- useEffect(() => {- if (!open) return- if (!entry) {- form.reset(COMPANY_ADDRESS_DEFAULTS)- return- }-- form.reset({- label: entry.label ?? '',- default_billing: entry.is_default_billing,- default_shipping: entry.is_default_shipping,- first_name: entry.first_name ?? '',- last_name: entry.last_name ?? '',- company: entry.company ?? '',- address1: entry.address1 ?? '',- address2: entry.address2 ?? '',- city: entry.city ?? '',- postal_code: entry.postal_code ?? '',- phone: entry.phone ?? '',- country_code: entry.country_code ?? '',- state_code: entry.state_code ?? '',- })- }, [open, entry, form])-- async function onSubmit(values: CompanyAddressFormValues) {- try {- const params = companyAddressValuesToParams(values)- if (entry) {- await updateMutation.mutateAsync({ id: entry.id, params })- } else {- await createMutation.mutateAsync(params)- }- onOpenChange(false)- } catch (err) {- if (!mapSpreeErrorsToForm(err, form.setError)) throw err- }+ // A new entry is offered as both defaults: the node points at one address per+ // kind, so the first site it gets is the answer to both, and there is no+ // previous default for it to displace. The company line comes from the node,+ // so a new entry is born carrying it.+ const address = entry ?? {+ company: companyName,+ is_default_billing: true,+ is_default_shipping: true,}- const { errors } = form.formState-return (- <Sheet open={open} onOpenChange={onOpenChange}>- <SheetContent className="sm:max-w-xl">- <SheetHeader>- <SheetTitle>- {entry- ? t('admin.company_addresses.edit_sheet_title')- : t('admin.company_addresses.add_sheet_title')}- </SheetTitle>- <SheetDescription>{t('admin.company_addresses.sheet_description')}</SheetDescription>- </SheetHeader>- <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">- <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">- <FieldGroup>- {errors.root?.message && (- <p className="text-destructive text-sm" role="alert">- {errors.root.message}- </p>- )}-- <AddressFieldset form={form} companyName={companyName} withLabel />+ <AddressFormDialog+ title={+ entry+ ? t('admin.company_addresses.edit_sheet_title')+ : t('admin.company_addresses.add_sheet_title')+ }+ description={t('admin.company_addresses.sheet_description')}+ address={address}+ open={open}+ onOpenChange={onOpenChange}+ // Addressed to the company, so no contact name is asked for and the+ // company line is what cannot be left out.+ business+ companyReadOnly+ showLabel+ showDefaultFlags+ onSave={async (values) => {+ // The dialog speaks the customer address book's names for these; the+ // company endpoints take them without the prefix.+ const { is_default_billing, is_default_shipping, ...address } = values+ const params = {+ ...address,+ default_billing: is_default_billing,+ default_shipping: is_default_shipping,+ }- <Controller- control={form.control}- name="default_billing"- render={({ field }) => (- <label- htmlFor="company-address-default-billing"- className="flex items-center gap-2 text-sm"- >- <Checkbox- id="company-address-default-billing"- checked={field.value}- onCheckedChange={field.onChange}- />- {t('admin.company_addresses.default_billing_label')}- </label>- )}- />- <Controller- control={form.control}- name="default_shipping"- render={({ field }) => (- <label- htmlFor="company-address-default-shipping"- className="flex items-center gap-2 text-sm"- >- <Checkbox- id="company-address-default-shipping"- checked={field.value}- onCheckedChange={field.onChange}- />- {t('admin.company_addresses.default_shipping_label')}- </label>- )}- />- </FieldGroup>- </div>- <SheetFooter>- <Button- type="button"- variant="outline"- onClick={() => onOpenChange(false)}- disabled={form.formState.isSubmitting}- >- {t('admin.actions.cancel')}- </Button>- <Button type="submit" disabled={form.formState.isSubmitting}>- {form.formState.isSubmitting ? t('admin.actions.saving') : t('admin.actions.save')}- </Button>- </SheetFooter>- </form>- </SheetContent>- </Sheet>+ if (entry) {+ await updateMutation.mutateAsync({ id: entry.id, params })+ } else {+ await createMutation.mutateAsync(params)+ }+ onOpenChange(false)+ }}+ isPending={createMutation.isPending || updateMutation.isPending}+ />)}diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 934160464c..67556d6985 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -431,11 +431,8 @@"company_addresses": {"add_cta": "إضافة عنوان","add_sheet_title": "عنوان جديد",- "address_legend": "العنوان","default_billing": "الفوترة الافتراضية",- "default_billing_label": "استخدام كعنوان الفوترة الافتراضي","default_shipping": "الشحن الافتراضي",- "default_shipping_label": "استخدام كعنوان الشحن الافتراضي","edit_sheet_title": "تعديل العنوان","empty": "لا توجد عناوين بعد","messages": {@@ -1028,13 +1025,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "كيف يُشار إلى هذا الموقع — \"المقر الرئيسي\"، \"رصيف المصنع 2\".",- "label": "التسمية",- "placeholder": "المقر الرئيسي"- }- },"company_location": {"external_id": {"help": "مرجعك الخاص لهذا الفرع."diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 3c58a435ff..fe17a5cbc7 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -425,11 +425,8 @@"company_addresses": {"add_cta": "Adresse hinzufügen","add_sheet_title": "Neue Adresse",- "address_legend": "Adresse","default_billing": "Standard-Rechnung",- "default_billing_label": "Als Standard-Rechnungsadresse verwenden","default_shipping": "Standard-Lieferung",- "default_shipping_label": "Als Standard-Lieferadresse verwenden","edit_sheet_title": "Adresse bearbeiten","empty": "Noch keine Adressen","messages": {@@ -1011,13 +1008,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "Wie dieser Standort genannt wird — „Hauptsitz\", „Werk 2 Rampe\".",- "label": "Bezeichnung",- "placeholder": "Hauptsitz"- }- },"company_location": {"external_id": {"help": "Ihre eigene Referenz für diese Niederlassung."diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 54c2be1d51..8d6d0a2452 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -425,11 +425,8 @@"company_addresses": {"add_cta": "Add address","add_sheet_title": "New address",- "address_legend": "Address","default_billing": "Default billing",- "default_billing_label": "Use as default billing address","default_shipping": "Default shipping",- "default_shipping_label": "Use as default shipping address","edit_sheet_title": "Edit address","empty": "No addresses yet","messages": {@@ -1011,13 +1008,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "How this site is referred to — \"Headquarters\", \"Plant 2 dock\".",- "label": "Label",- "placeholder": "Headquarters"- }- },"company_location": {"external_id": {"help": "Your own reference for this branch."diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 6825daa574..b64fee5bf3 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -425,11 +425,8 @@"company_addresses": {"add_cta": "Ajouter une adresse","add_sheet_title": "Nouvelle adresse",- "address_legend": "Adresse","default_billing": "Facturation par défaut",- "default_billing_label": "Utiliser comme adresse de facturation par défaut","default_shipping": "Livraison par défaut",- "default_shipping_label": "Utiliser comme adresse de livraison par défaut","edit_sheet_title": "Modifier l’adresse","empty": "Aucune adresse pour le moment","messages": {@@ -1011,13 +1008,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "Comment ce site est désigné — « Siège social », « Quai usine 2 ».",- "label": "Libellé",- "placeholder": "Siège social"- }- },"company_location": {"external_id": {"help": "Votre propre référence pour cet établissement."diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex 058ff1d7ef..72c6b5bfeb 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -435,11 +435,8 @@"company_addresses": {"add_cta": "Dodaj adres","add_sheet_title": "Nowy adres",- "address_legend": "Adres","default_billing": "Domyślny rozliczeniowy",- "default_billing_label": "Ustaw jako domyślny adres rozliczeniowy","default_shipping": "Domyślny dostawy",- "default_shipping_label": "Ustaw jako domyślny adres dostawy","edit_sheet_title": "Edytuj adres","empty": "Brak adresów","messages": {@@ -1029,13 +1026,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "Jak nazywany jest ten adres — „Siedziba główna\", „Rampa zakładu 2\".",- "label": "Etykieta",- "placeholder": "Siedziba główna"- }- },"company_location": {"external_id": {"help": "Twój własny identyfikator tego oddziału."diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex 00684a1ea9..931a43ad18 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -423,11 +423,8 @@"company_addresses": {"add_cta": "添加地址","add_sheet_title": "新建地址",- "address_legend": "地址","default_billing": "默认账单",- "default_billing_label": "设为默认账单地址","default_shipping": "默认收货",- "default_shipping_label": "设为默认收货地址","edit_sheet_title": "编辑地址","empty": "暂无地址","messages": {@@ -1006,13 +1003,6 @@"placeholder": "Acme Industries"}},- "company_address": {- "label": {- "help": "该地点的称呼——“总部”、“2 号厂区装卸口”。",- "label": "标签",- "placeholder": "总部"- }- },"company_location": {"external_id": {"help": "您为该分支机构设定的编号。"diff --git a/packages/dashboard/src/schemas/company.ts b/packages/dashboard/src/schemas/company.tsindex 433763d97e..912c2c6199 100644--- a/packages/dashboard/src/schemas/company.ts+++ b/packages/dashboard/src/schemas/company.ts@@ -1,5 +1,4 @@import type {- CompanyAddressParams,CompanyParams,TaxExemptionCertificateParams,TaxIdentifierParams,@@ -35,63 +34,6 @@ export type CompanyChildFormValues = z.infer<typeof companyChildFormSchema>export const COMPANY_CHILD_DEFAULTS: CompanyChildFormValues = { name: '', kind: 'division' }-const addressFieldsSchema = z.object({- first_name: z.string().optional(),- last_name: z.string().optional(),- company: z.string().optional(),- address1: z.string().optional(),- address2: z.string().optional(),- city: z.string().optional(),- postal_code: z.string().optional(),- phone: z.string().optional(),- country_code: z.string().optional(),- state_code: z.string().optional(),- state_name: z.string().optional(),-})--// The entry is the address itself, so the address fields sit alongside the-// label and the two default flags rather than under an `address` key.-export const companyAddressFormSchema = addressFieldsSchema.extend({- label: z.string().optional(),- default_billing: z.boolean(),- default_shipping: z.boolean(),-})--export type CompanyAddressFormValues = z.infer<typeof companyAddressFormSchema>--// A new entry is offered as both defaults: the node points at one address per-// kind, so the common case — the first site a node gets — is the answer to-// both, and there is no previous default for it to displace.-export const COMPANY_ADDRESS_DEFAULTS: CompanyAddressFormValues = {- label: '',- default_billing: true,- default_shipping: true,- first_name: '',- last_name: '',- company: '',- address1: '',- address2: '',- city: '',- postal_code: '',- phone: '',- country_code: '',- state_code: '',- state_name: '',-}--export function companyAddressValuesToParams(- values: CompanyAddressFormValues,-): CompanyAddressParams {- const { label, default_billing, default_shipping, ...address } = values-- return {- label: blankToNull(label),- default_billing,- default_shipping,- ...Object.fromEntries(Object.entries(address).filter(([, value]) => value !== undefined)),- }-}-export const taxIdentifierFormSchema = z.object({kind: z.string().min(1, { error: requiredMessage('tax_identifier.kind') }),value: z.string().min(1, { error: requiredMessage('tax_identifier.value') }),