Skip to content

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: boolean

Whether 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


isDraftSave

isDraftSave: boolean

Whether 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


isLoadingDraft

isLoadingDraft: boolean

Whether 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 | undefined

Error 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 | undefined

ID 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


draftName

draftName: string

User-visible name for the draft configuration.

Editable via setDraftName. Sent to the API when calling saveOrUpdateDraft.

Related


savedDraftName

savedDraftName: string | undefined

Name 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


draftData

draftData: Json | undefined

Arbitrary 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


Draft methods

setDraftName

setDraftName: (draftName: string) => void

Updates the draft name.

Parameters

NameTypeDescription
draftNamestringNew draft name

Related


setDraftData

setDraftData: (draftData: Json) => void

Updates the arbitrary extra draft payload.

Parameters

NameTypeDescription
draftDataJsonAny 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 isDraftSave is true (no draftId yet): calls the save API endpoint and sets draftId on success
  • When isDraftSave is false: calls the update API endpoint with the existing draftId

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" }>

FieldDescription
oktrue if the operation succeeded
type"save" for a first-time save, "update" for a subsequent update

Related


isLoadingOpenFromDraft

isLoadingOpenFromDraft: boolean

Whether 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

NameTypeDescription
draftIdnumberID of the draft to load

Returns Promise<{ ok: boolean }>ok is true if the draft was loaded successfully.

Related


Submission

submit

submit: () => Promise<{ ok: boolean }>

Submits the current configuration to the API and returns a success flag.

Builds the submission payload from:

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

isSubmitEnabled: boolean

Whether all validations pass and submission is currently allowed.

true when:

  • All configs have status === "completed" (no missing required elements)
  • All fixedContactDetails fields pass validation (no errors)
  • All requestFieldsErrors are false

Use this to enable/disable the submit button.

Related


isLoadingSubmit

isLoadingSubmit: boolean

Whether a form submission is currently in progress.

Set to true for the duration of the submit API call.

Related


errorSubmit

errorSubmit: string | undefined

Error 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: boolean

Whether 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

NameTypeDescription
requestIdnumberID of the previously submitted request

Returns Promise<{ ok: boolean }>ok is true if the request was loaded successfully.

Related