Tally UI

CustomerEditor

CustomerEditor adds or edits a customer with CustomerForm and its AddressEditor, an explicit Save and Cancel, and the store call.

Import

import { CustomerEditor } from '@tallyui/components';

Usage

<CustomerEditor
  customer={customer}
  update={(id, patch) => connector.updateCustomer(id, patch)}
  onSaved={(saved) => close(saved)}
  onCancel={() => close()}
  online={online}
/>

Without customer the editor adds a new customer and its Save reads Add Customer; with customer it edits that one and Save reads Save. Save trims the fields, checks the email, and sends create the form as a create input, or update only what changed; an edit that changed nothing calls onSaved with the same customer and makes no call. Save is disabled while offline, while a save runs, or while the email is empty. A failed save shows the store's error under the form and Save can be pressed again. Shipping starts as Same as billing when the customer's shipping matches its billing.

Props

PropTypeDefaultDescription
customerCustomer---Edit this customer; absent means add a new one
create(input: CustomerInput) => Promise<Customer>---Add mode's store call
update(id: string, patch: CustomerPatch) => Promise<Customer>---Edit mode's store call
onSaved(customer: Customer) => voidrequiredCalled with the store's customer after a save, or with customer when an edit changed nothing
onCancel() => voidrequiredCalled when Cancel is pressed
onlinebooleanrequiredSave is disabled while offline
countriesAddressEditorProps['countries']---Passed through to AddressEditor
statesForAddressEditorProps['statesFor']---Passed through to AddressEditor
defaultCountrystring---Passed through to AddressEditor; a new address starts in this country
classNamestring---Override container styles
testIDstring'customer-editor'Prefix for the form, Save, Cancel and error testIDs

On this page