configsSubstore
Manages the lifecycle of user configurations in the current session. A configuration (TConfig) pairs a form with a name, a quantity, and a derived completion status. All form state and selected values are stored separately (in formSubstore and valuesSubstore) and automatically kept in sync when a config is added, removed, or copied.
Table of contents
Properties
Methods
- setCurrentConfigId
- addConfig
- removeConfig
- updateConfig
- updateConfigPosition
- copyConfig
- setupFromPreConfig
Properties
currentConfigId
currentConfigId: number | undefinedID of the currently active configuration, or undefined when none is selected.
Use this to scope reads from formSubstore.fromConfigs and valuesSubstore.valuesConfigs to the active config.
Related
configs— the full list;currentConfigIdis always one of itsidvaluessetCurrentConfigId— setterformSubstore.fromConfigs— keyed bycurrentConfigIdvaluesSubstore.valuesConfigs— keyed bycurrentConfigId
configsCounter
configsCounter: numberAuto-incrementing counter used to assign unique IDs to new configurations.
Each call to addConfig increments this counter and uses the resulting value as the new config’s id. You do not need to manage this directly.
Related
addConfig— consumes and increments this counter
configs
configs: TConfig[]Ordered list of all configurations in the current session.
type TConfig = { id: number; name: string; formId: number; formName: string; status: "in-progress" | "completed" | "incomplete"; configQuantity: number; missingRequiredElements: TMissingRequiredElement[];};
type TMissingRequiredElement = { id: number; groupId: number | undefined; label: string;};status is derived automatically from the values in valuesSubstore:
"completed"— all required elements have a selection"incomplete"— at least one required element is missing a selection"in-progress"— the config has not been interacted with yet
Related
currentConfigId— points at one entry in this listaddConfig/removeConfig/copyConfig— mutate this listfinishedConfigsSubstore.getFinishedConfigs— filters this list to completed configssubmitSubstore.submit— iterates over this list to build the submission payloadnumberFormatterSubstore.calculateConfigPrice— usesconfigQuantityfrom each entry
Methods
setCurrentConfigId
setCurrentConfigId: (configId: number) => voidSets the currently active configuration by ID.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | ID of an existing config in configs |
Related
currentConfigId— the value this method writes
addConfig
addConfig: ( config: Omit<TConfig, "id" | "status" | "missingRequiredElements">, preConfig?: TPreConfigConfig,) => numberAdds a new configuration entry and returns its generated ID.
Internally the SDK:
- Increments
configsCounterto produce the newid - Initialises a
FormStoreIteminformSubstore.fromConfigsfor this config - Initialises a
ValuesStoreIteminvaluesSubstore.valuesConfigsfor this config - If
preConfigis provided, pre-fills values and quantities accordingly
Parameters
| Name | Type | Description |
|---|---|---|
config | Omit<TConfig, "id" | "status" | "missingRequiredElements"> | Config metadata (name, formId, formName, configQuantity) |
preConfig | TPreConfigConfig (optional) | Pre-filled values/quantities to apply on creation |
Returns number — the newly assigned config ID.
Related
configsCounter— incremented on each callformSubstore.fromConfigs— a new entry is created herevaluesSubstore.valuesConfigs— a new entry is created hereremoveConfig— inverse operation
removeConfig
removeConfig: (configId: number) => voidRemoves a configuration and all associated form and value data.
The SDK also removes the corresponding entries from formSubstore.fromConfigs and valuesSubstore.valuesConfigs. If the removed config was the active one, currentConfigId is cleared.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | ID of the config to remove |
Related
formSubstore.fromConfigs— entry is deletedvaluesSubstore.valuesConfigs— entry is deletedaddConfig— inverse operation
updateConfig
updateConfig: ( configId: number, config: Partial<Omit<TConfig, "id" | "formName" | "status">>,) => voidPartially updates a configuration’s metadata fields.
Only name, formId, and configQuantity can be changed. id, formName, and status are immutable through this method.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | ID of the config to update |
config | Partial<Omit<TConfig, "id" | "formName" | "status">> | Fields to update |
Related
configs— the list is updated in place
updateConfigPosition
updateConfigPosition: (configId: number, newPosition: number) => voidReorders a configuration to a new index in the list.
newPosition is zero-based. The config is removed from its current position and inserted at newPosition.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | ID of the config to move |
newPosition | number | Target zero-based index |
Related
configs— the ordering of this array is changed
copyConfig
copyConfig: (configId: number) => voidDuplicates an existing configuration, including its form and value data.
The SDK:
- Creates a new config entry with incremented ID (via
addConfiginternally) - Deep-copies the form state from
formSubstore.fromConfigs[configId] - Deep-copies values and quantities from
valuesSubstore.valuesConfigs[configId]
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | ID of the config to duplicate |
Related
formSubstore.fromConfigs— source and destination of the copyvaluesSubstore.valuesConfigs— source and destination of the copy
setupFromPreConfig
setupFromPreConfig: ( preConfig: TPreConfig, args: { defaultConfigName: string; skipCleanConfigs?: boolean; },) => voidInitialises the store from a pre-configuration object, replacing existing configs.
A TPreConfig encodes one or more configurations with their pre-filled values, quantities, and optional contact-field overrides. After this call the store’s configs list is replaced with the configs described in preConfig.
Set skipCleanConfigs: true to append to the existing list instead of replacing it.
Parameters
| Name | Type | Description |
|---|---|---|
preConfig | TPreConfig | Pre-configuration payload |
args.defaultConfigName | string | Fallback name for configs that don’t specify one |
args.skipCleanConfigs | boolean (optional) | When true, existing configs are kept and new ones are appended |
Related
contactDetailsSubstore.tempPreConfigRequestFields— request-field overrides frompreConfigare written heresubmitSubstore.openFromDraft— uses this method internally to restore state from a draft