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.

The payload includes form submissions, contact name and email, dynamic request field values (contactDetailsSubstore.requestFieldsValues), configuration name, and 3D metadata. Name and email are required — the call returns { ok: false } if either is missing.

  • 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. Also restores contact name, email, and dynamic request field values from the draft’s extra_fields. On success, sets draftId to the loaded draft’s ID, making the session draft-bound — a subsequent submit will use the draft-submit flow.

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<SubmitResult>;
type SubmitResult =
| { ok: true; pdfUrl: string | undefined; documentUrls: string[] }
| { ok: false };

Submits the current configuration to the API and returns a result object.

Builds the submission payload from:

Requires both a selected country and language from localizationSubstore. Returns { ok: false } immediately if either is missing.

Draft-bound submission: When the user is authenticated (authSubstore.isAuth) and a draftId is active, submission routes through the draft-submit endpoint for that draft ID. On success the SDK clears the draft-bound state (draftId, savedDraftName, draftData, and related flags) while keeping the configuration name unchanged. If the user is not authenticated or no draftId is set, a normal (non-draft) submission is used instead.

On success, writes the returned URLs to submittedPdfUrl and submittedDocumentUrls.

Sets isLoadingSubmit to true during the call. On failure, writes to errorSubmit.

Returns Promise<SubmitResult>

FieldWhen ok: trueDescription
pdfUrlalways presentLegacy PDF URL from the API response, if any
documentUrlsalways presentURLs of all generated documents (PDF, DOCX, etc.)

Related


isSubmitEnabled

isSubmitEnabled: boolean;

Whether contact details are valid and supporting data has finished loading.

true when:

Use this to enable/disable the submit button. Config completion (status === "completed") is not checked here — gate on that separately in your UI if needed.

Related


submittedPdfUrl

submittedPdfUrl: string | undefined;

URL of the PDF generated by the last successful submission, or undefined before submit or when the API did not return one.

Set from the pdf_url field in the submit response. Prefer submittedDocumentUrls for the full list of generated documents.

Related


submittedDocumentUrls

submittedDocumentUrls: string[];

URLs of all documents generated by the last successful submission (PDF, DOCX, ODT, XLSX, ODS, etc.).

Populated from the document_urls field in the submit response. Cleared at the start of each new submit attempt.

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. Also restores contact name, email, and dynamic request field values from the request’s extra_fields. Clears any draft-bound state so the session is not tied to a previous draft. 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