contactDetailsSubstore
Manages the contact information the user fills in before submitting a request. This includes two fixed fields (name and email) and a set of dynamic request fields loaded from the API. All fields perform inline validation on change.
Table of contents
Properties
- tempPreConfigRequestFields
- requestFieldsData
- requestFieldsValues
- requestFieldsErrors
- fixedContactDetails
Methods
Properties
tempPreConfigRequestFields
tempPreConfigRequestFields: TPreConfigRequestFields | undefinedTemporary pre-config request field overrides, automatically cleared after they are applied.
When configsSubstore.setupFromPreConfig is called with a preConfig that contains request-field values, those values are written here first. The substore then consumes them to pre-fill requestFieldsValues and immediately sets this property back to undefined.
Related
configsSubstore.setupFromPreConfig— populates this propertyrequestFieldsValues— receives the values from this property
requestFieldsData
requestFieldsData: ApiResource<TRequestField[]>API resource containing the dynamic request-field definitions, including loading and error state.
Each TRequestField describes a field group with one or more sub-fields (e.g., a company address field with street, city, and postal-code sub-fields). The UI should render each field according to its type and the sub-fields it contains.
See ApiResource for the shape of loading/error state.
Related
requestFieldsValues— stores user-entered values keyed by the field/sub-field IDs from this datarequestFieldsErrors— validation errors keyed by the same IDssetSubFieldValue— updates a value and re-runs validation
requestFieldsValues
requestFieldsValues: { [requestFieldId: number]: { [requestSubFieldId: number]: string }}Current user-entered values for all request fields, keyed by field ID and sub-field ID.
Initialised to empty strings. Updated by setSubFieldValue. The entire structure is sent to the API when submitting (see submitSubstore.submit).
Related
requestFieldsData— source of the field/sub-field ID structuresetSubFieldValue— updates individual valuesrequestFieldsErrors— validation state for these valuestempPreConfigRequestFields— can bulk-initialise these values
requestFieldsErrors
requestFieldsErrors: { [requestFieldId: number]: { [requestSubFieldId: number]: | false | "missing" | "invalid-number" | "unchecked-checkbox" }}Validation error state for all request fields, keyed by field ID and sub-field ID.
false means the field is valid. String values indicate the type of error. Errors are recomputed each time setSubFieldValue is called and also when submitSubstore.submit is triggered to catch unfilled fields.
Related
requestFieldsValues— the values being validatedsetSubFieldValue— triggers revalidation on change
fixedContactDetails
fixedContactDetails: { id: "name" | "email"; value: string; error: false | "missing" | "invalid-email";}[]The fixed name and email contact fields with their current values and validation error states.
Always contains exactly two entries (one for "name", one for "email"). Updated by setFixedContactDetailsValue.
Related
setFixedContactDetailsValue— settersubmitSubstore.submit— readsnameandemailfrom here to build the submission payload
Methods
setSubFieldValue
setSubFieldValue: (args: { requestFieldId: number; requestSubFieldId: number; value: string;}) => voidUpdates a specific sub-field value and revalidates it immediately.
After writing the new value to requestFieldsValues, the SDK synchronously recomputes the error entry in requestFieldsErrors for this sub-field.
Parameters
| Name | Type | Description |
|---|---|---|
args.requestFieldId | number | ID of the parent request field |
args.requestSubFieldId | number | ID of the sub-field to update |
args.value | string | New string value |
Related
requestFieldsValues— updated by this callrequestFieldsErrors— revalidated by this call
setFixedContactDetailsValue
setFixedContactDetailsValue: (args: { id: "name" | "email"; value: string;}) => voidUpdates a fixed contact field (name or email) and runs validation on the new value.
After writing the value, the SDK synchronously validates it:
"name"— checks the field is not empty"email"— checks the field is not empty and matches a valid email pattern
Parameters
| Name | Type | Description |
|---|---|---|
args.id | "name" | "email" | Which fixed field to update |
args.value | string | New string value |
Related
fixedContactDetails— updated and revalidated by this call