submitSubstore
Manages all submission-related operations: draft save/update/load, submission to the API, and restoring state from a previously submitted request copy. All async operations expose their own loading and error state.
Table of contents
Draft state
Draft methods
Submission
Request copy
Draft state
isDraftEnabled
isDraftEnabled: booleanWhether draft saving is currently available (user is authenticated and no form is loading).
true when authSubstore.isAuth is true and none of the configs in formSubstore.fromConfigs have isLoading === true. Use this to show/hide or enable/disable the draft save UI.
Related
authSubstore.isAuth— required to betrueformSubstore.fromConfigs—isLoadingon any config disables draftssaveOrUpdateDraft— the action gated by this flag
isDraftSave
isDraftSave: booleanWhether the next draft action is a fresh save (true) versus an update to an existing draft (false).
true when draftId is undefined (no draft has been saved yet in this session). After a successful save, draftId is set and this flips to false for subsequent calls.
Related
draftId— determines the value of this flagsaveOrUpdateDraft— behaviour changes based on this flag
isLoadingDraft
isLoadingDraft: booleanWhether a draft save or update operation is currently in progress.
Set to true for the duration of the saveOrUpdateDraft API call.
Related
errorDraft
errorDraft: string | undefinedError message from the last failed draft operation, or undefined if none.
Set when saveOrUpdateDraft fails. Cleared on the next successful draft operation.
Related
draftId
draftId: number | undefinedID of the most recently saved draft, or undefined if no draft has been saved yet.
Set after a successful call to saveOrUpdateDraft (save mode). Used by subsequent calls as the target for the update API endpoint.
Related
isDraftSave— flips tofalseonce this is setsaveOrUpdateDraft— sets this on successopenFromDraft— takes a draft ID as input
draftName
draftName: stringUser-visible name for the draft configuration.
Editable via setDraftName. Sent to the API when calling saveOrUpdateDraft.
Related
setDraftName— settersavedDraftName— the last successfully persisted namesaveOrUpdateDraft— includes this in the payload
savedDraftName
savedDraftName: string | undefinedName that was persisted on the last successful draft save or update.
undefined before any successful save. Use this to detect unsaved changes (when draftName !== savedDraftName).
Related
draftName— the current (possibly unsaved) namesaveOrUpdateDraft— updates this on success
draftData
draftData: Json | undefinedArbitrary extra JSON payload attached to the draft (e.g., 3D configuration data).
This field is not interpreted by the SDK. Use it to round-trip any additional application state alongside the form configuration. Set via setDraftData.
Related
setDraftData— settersaveOrUpdateDraft— includes this in the API payload
Draft methods
setDraftName
setDraftName: (draftName: string) => voidUpdates the draft name.
Parameters
| Name | Type | Description |
|---|---|---|
draftName | string | New draft name |
Related
setDraftData
setDraftData: (draftData: Json) => voidUpdates the arbitrary extra draft payload.
Parameters
| Name | Type | Description |
|---|---|---|
draftData | Json | Any JSON-serialisable value |
Related
saveOrUpdateDraft
saveOrUpdateDraft: () => Promise<{ ok: boolean; type: "save" | "update" }>Saves a new draft or updates the existing one and returns a result object indicating success and operation type.
- When
isDraftSaveistrue(nodraftIdyet): calls the save API endpoint and setsdraftIdon success - When
isDraftSaveisfalse: calls the update API endpoint with the existingdraftId
Sets isLoadingDraft to true for the duration of the call. On failure, writes the error message to errorDraft.
Returns Promise<{ ok: boolean; type: "save" | "update" }>
| Field | Description |
|---|---|
ok | true if the operation succeeded |
type | "save" for a first-time save, "update" for a subsequent update |
Related
isDraftEnabled— gate before calling thisisDraftSave— determines save vs update modedraftId— set on success (save mode)draftName,draftData— included in the payloadisLoadingDraft,errorDraft— loading/error state
isLoadingOpenFromDraft
isLoadingOpenFromDraft: booleanWhether a draft is currently being loaded into the store.
Set to true for the duration of openFromDraft.
Related
openFromDraft
openFromDraft: (draftId: number) => Promise<{ ok: boolean }>Loads a draft by ID and restores the store state from it.
Fetches the draft from the API, then calls configsSubstore.setupFromPreConfig to re-populate the store with the saved configuration data.
Parameters
| Name | Type | Description |
|---|---|---|
draftId | number | ID of the draft to load |
Returns Promise<{ ok: boolean }> — ok is true if the draft was loaded successfully.
Related
isLoadingOpenFromDraftdraftId— set to the loaded draft’s ID on successconfigsSubstore.setupFromPreConfig— called internally to restore state
Submission
submit
submit: () => Promise<{ ok: boolean }>Submits the current configuration to the API and returns a success flag.
Builds the submission payload from:
configsSubstore.configs— config list and quantitiesvaluesSubstore.valuesConfigs— selected values and quantitiescontactDetailsSubstore.fixedContactDetails— name and emailcontactDetailsSubstore.requestFieldsValues— dynamic contact fields
Sets isLoadingSubmit to true during the call. On failure, writes to errorSubmit.
Returns Promise<{ ok: boolean }> — ok is true if the submission succeeded.
Related
isSubmitEnabled— gate before calling thisisLoadingSubmit,errorSubmitcontactDetailsSubstore.fixedContactDetailsvaluesSubstore.valuesConfigsconfigsSubstore.configs
isSubmitEnabled
isSubmitEnabled: booleanWhether all validations pass and submission is currently allowed.
true when:
- All configs have
status === "completed"(no missing required elements) - All
fixedContactDetailsfields pass validation (no errors) - All
requestFieldsErrorsarefalse
Use this to enable/disable the submit button.
Related
submit— the action gated by this flagconfigsSubstore.configs—statusof each config is checkedcontactDetailsSubstore.fixedContactDetailscontactDetailsSubstore.requestFieldsErrors
isLoadingSubmit
isLoadingSubmit: booleanWhether a form submission is currently in progress.
Set to true for the duration of the submit API call.
Related
errorSubmit
errorSubmit: string | undefinedError message from the last failed submission, or undefined if none.
Set when submit fails. Cleared on the next successful submission attempt.
Related
Request copy
isLoadingOpenFromRequestCopy
isLoadingOpenFromRequestCopy: booleanWhether a request copy is currently being loaded into the store.
Set to true for the duration of openFromRequestCopy.
Related
openFromRequestCopy
openFromRequestCopy: (requestId: number) => Promise<{ ok: boolean }>Restores the store state from a previously submitted request by its ID.
Fetches the historical request from the API, then calls configsSubstore.setupFromPreConfig to re-populate the store with the same configuration data that was originally submitted. Useful for “re-order” or “edit previous request” flows.
Parameters
| Name | Type | Description |
|---|---|---|
requestId | number | ID of the previously submitted request |
Returns Promise<{ ok: boolean }> — ok is true if the request was loaded successfully.
Related
isLoadingOpenFromRequestCopyconfigsSubstore.setupFromPreConfig— called internally to restore stateopenFromDraft— similar pattern for draft restoration