@mindbill/react 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/index.d.ts +18 -6
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ npm install @mindbill/react @mindbill/node
|
|
|
8
8
|
|
|
9
9
|
## Connected lifecycle
|
|
10
10
|
|
|
11
|
-
`ConnectedBillLifecycle` starts after
|
|
11
|
+
`ConnectedBillLifecycle` starts after `BillSubmissionForm` atomically submits an immutable bill. It owns the submitted-to-closed progress rail, a read-only rendering of the exact submitted snapshot, server-owned human-readable history, packet download, EORs, payment posting, Second Bill Review, close, and reopen. The only persistent header action is **Download packet**; status-dependent actions appear in the details view when MindBill makes them available.
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { ConnectedBillLifecycle } from "@mindbill/react";
|
|
@@ -132,7 +132,7 @@ Browser callbacks such as `onChanged` are for immediate UI, navigation, optimist
|
|
|
132
132
|
|
|
133
133
|
`BillSubmissionForm` owns the complete pre-submission experience: the bill field schema, required-field rules and red asterisks, validation, service-line editing, source-document selection, PDF uploads, and the single Submit action. Its `bill` value is structurally identical to the server SDK's `CreateBillRequest`.
|
|
134
134
|
|
|
135
|
-
The partner application only loads initial values and
|
|
135
|
+
The partner application only loads initial values and mints a short-lived browser session. Uploaded files stay in the browser until the user submits; the component validates and sends the immutable snapshot and PDF bytes directly to MindBill.
|
|
136
136
|
|
|
137
137
|
```tsx
|
|
138
138
|
import { BillSubmissionForm } from "@mindbill/react";
|
|
@@ -142,9 +142,7 @@ import { BillSubmissionForm } from "@mindbill/react";
|
|
|
142
142
|
attachments={bootstrap.attachments}
|
|
143
143
|
getSession={() => fetch("/api/mindbill/session", { method: "POST" }).then(r => r.json())}
|
|
144
144
|
appearance={{ preset: "qme-companion" }}
|
|
145
|
-
|
|
146
|
-
submitBill({ bill, sourceAttachmentIds, uploads })
|
|
147
|
-
}
|
|
145
|
+
onSubmitted={({ billId }) => saveLocalBillLink(billId)}
|
|
148
146
|
/>
|
|
149
147
|
```
|
|
150
148
|
|
|
@@ -159,11 +157,11 @@ The component includes the interaction model, not just the markup:
|
|
|
159
157
|
- searchable workers-comp procedure/modifier controls, medical-legal fee-schedule amounts, totals, valid manual CPT/HCPCS entry, and an automatically maintained empty line;
|
|
160
158
|
- removable source documents with new-tab previews, a locked auto-attached practice W-9, and a full-width click, panel-drop, or whole-page PDF upload area. Every visible source document is included until removed; uploaded PDFs do not require document-type tagging.
|
|
161
159
|
|
|
162
|
-
Partners supply tenant-specific bootstrap data, one short-lived browser session callback, and
|
|
160
|
+
Partners supply tenant-specific bootstrap data, one short-lived browser session callback, and optionally an `onSubmitted` callback to persist the returned `billId`. Required fields, validation, ZIP lookup, ICD-10 and payer directories, service-line behavior, PDF encoding, wire-format serialization, atomic submission, attachments, and submission UX stay inside `@mindbill/react`, so every integration receives the same billing workflow. Optional `diagnosisOptions`, `procedureOptions`, `modifierOptions`, and lookup callbacks extend or replace defaults when a partner has licensed or organization-specific data.
|
|
163
161
|
|
|
164
162
|
Validation is component-owned as well. A missing routing payer is highlighted immediately; Submit highlights every invalid control with a specific message, focuses and scrolls to the first problem, and continues validating as the user corrects the form.
|
|
165
163
|
|
|
166
|
-
`BILL_SUBMISSION_REQUIRED_FIELDS` and `validateBillSubmission` expose the same contract for tests and non-visual integrations. The component never creates a draft;
|
|
164
|
+
`BILL_SUBMISSION_REQUIRED_FIELDS` and `validateBillSubmission` expose the same contract for tests and non-visual integrations. The component never creates a draft; `onSubmitted` fires only after MindBill accepts a locally valid immutable snapshot. The legacy `onSubmit` escape hatch remains optional for unusual deployments, but connected integrations should omit it so the library owns the complete contract.
|
|
167
165
|
|
|
168
166
|
`BillReviewForm` remains available for legacy integrations that already own a custom review model. New integrations should use `BillSubmissionForm`.
|
|
169
167
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MindBillAppearance, MindBillEventDetail, MindBillErrorDetail } from '@mindbill/embed';
|
|
2
2
|
export { MindBillAppearance, MindBillErrorDetail, MindBillEventDetail } from '@mindbill/embed';
|
|
3
3
|
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
4
|
-
import { BillReviewData as BillReviewData$1, BillReviewAttachment as BillReviewAttachment$1, BillLifecycleSessionProvider, BillReviewPayer as BillReviewPayer$1, BillLifecycleAction, BillLifecycleDelivery, BillPaymentRecord, BillRemittanceSummary, BillLifecycleData, BillLifecycleClientOptions, BillLifecycleClient, BillEorDocument } from '@mindbill/browser';
|
|
5
|
-
export { BillActivityRecord, BillEorDocument, BillLifecycleAction, BillLifecycleActionId, BillLifecycleClient, BillLifecycleClientOptions, BillLifecycleData, BillLifecycleDelivery, BillLifecycleSession, BillLifecycleSessionProvider, BillLifecycleSessionRequest, BillPaymentRecord, BillRemittanceSummary, CloseBillInput, PostBillPaymentInput, ReopenBillInput, SubmitSecondReviewInput, createBillLifecycleClient } from '@mindbill/browser';
|
|
4
|
+
import { BillReviewData as BillReviewData$1, BillReviewAttachment as BillReviewAttachment$1, BrowserBillSubmissionResult, BillLifecycleSessionProvider, BillReviewPayer as BillReviewPayer$1, BrowserBillSubmissionDocument, BillLifecycleAction, BillLifecycleDelivery, BillPaymentRecord, BillRemittanceSummary, BillLifecycleData, BillLifecycleClientOptions, BillLifecycleClient, BillEorDocument } from '@mindbill/browser';
|
|
5
|
+
export { BillActivityRecord, BillEorDocument, BillLifecycleAction, BillLifecycleActionId, BillLifecycleClient, BillLifecycleClientOptions, BillLifecycleData, BillLifecycleDelivery, BillLifecycleSession, BillLifecycleSessionProvider, BillLifecycleSessionRequest, BillPaymentRecord, BillRemittanceSummary, BrowserBillSubmissionResult, CloseBillInput, PostBillPaymentInput, ReopenBillInput, SubmitSecondReviewInput, createBillLifecycleClient } from '@mindbill/browser';
|
|
6
6
|
|
|
7
7
|
type MindBillThemePreset = "mindbill" | "qme-companion" | "orange-bright" | "clinical-blue";
|
|
8
8
|
type MindBillReactAppearance = MindBillAppearance & {
|
|
@@ -473,8 +473,14 @@ type BillSubmissionFormValue = {
|
|
|
473
473
|
type BillSubmissionFormProps = {
|
|
474
474
|
initialBill: BillSubmissionInput;
|
|
475
475
|
attachments?: BillSubmissionSourceAttachment[];
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
/**
|
|
477
|
+
* Legacy custom submission escape hatch. Connected forms should omit this so
|
|
478
|
+
* the component owns PDF encoding and the Partner API wire contract.
|
|
479
|
+
*/
|
|
480
|
+
onSubmit?: (value: BillSubmissionFormValue) => void | Promise<void>;
|
|
481
|
+
/** Called after the connected component atomically creates and submits the bill. */
|
|
482
|
+
onSubmitted?: (result: BrowserBillSubmissionResult) => void | Promise<void>;
|
|
483
|
+
/** Short-lived partner browser session. Enables reference data and direct submission. */
|
|
478
484
|
getSession?: BillLifecycleSessionProvider;
|
|
479
485
|
sessionEndpoint?: string;
|
|
480
486
|
apiBaseUrl?: string;
|
|
@@ -503,6 +509,12 @@ type BillSubmissionValidation = {
|
|
|
503
509
|
valid: boolean;
|
|
504
510
|
fieldErrors: Record<string, string>;
|
|
505
511
|
};
|
|
512
|
+
declare function prepareBillSubmissionDocuments({ attachments, selectedIds, uploads, fetch: fetchOverride, }: {
|
|
513
|
+
attachments: BillSubmissionSourceAttachment[];
|
|
514
|
+
selectedIds: string[];
|
|
515
|
+
uploads: BillSubmissionUpload[];
|
|
516
|
+
fetch?: typeof globalThis.fetch;
|
|
517
|
+
}): Promise<BrowserBillSubmissionDocument[]>;
|
|
506
518
|
declare function ensureTrailingBillSubmissionLine(lines: BillSubmissionInput["serviceLines"]): BillSubmissionInput["serviceLines"];
|
|
507
519
|
declare function parseBillSubmissionDate(value: string): string | undefined;
|
|
508
520
|
declare function formatBillSubmissionDate(value: string | null | undefined): string;
|
|
@@ -516,7 +528,7 @@ declare function BillSubmissionProvidersSection(): ReactElement;
|
|
|
516
528
|
declare function BillSubmissionServiceLinesSection(): ReactElement;
|
|
517
529
|
declare function BillSubmissionAttachmentsSection(): ReactElement;
|
|
518
530
|
declare function BillSubmissionActions(): ReactElement;
|
|
519
|
-
declare function BillSubmissionForm({ initialBill, attachments, onSubmit, getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride, onSearchClaimsAdministrators, diagnosisOptions, onSearchDiagnoses, onLookupPostalCode, procedureOptions, modifierOptions, appearance, className, style, disabled, submitLabel, heading, description, children, }: BillSubmissionFormProps): ReactElement;
|
|
531
|
+
declare function BillSubmissionForm({ initialBill, attachments, onSubmit, onSubmitted, getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride, onSearchClaimsAdministrators, diagnosisOptions, onSearchDiagnoses, onLookupPostalCode, procedureOptions, modifierOptions, appearance, className, style, disabled, submitLabel, heading, description, children, }: BillSubmissionFormProps): ReactElement;
|
|
520
532
|
|
|
521
533
|
/** Public-domain and MindBill-owned metadata. CPT descriptions are intentionally limited to the curated catalog. */
|
|
522
534
|
declare const DEFAULT_BILL_SUBMISSION_PROCEDURES: BillSubmissionProcedureOption[];
|
|
@@ -778,4 +790,4 @@ type MindBillWidgetProps = {
|
|
|
778
790
|
declare function MindBillBillTimeline(props: MindBillWidgetProps): ReactElement;
|
|
779
791
|
declare function MindBillBillReview(props: MindBillWidgetProps): ReactElement;
|
|
780
792
|
|
|
781
|
-
export { BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, BILL_SUBMISSION_DOCUMENT_TYPES, BILL_SUBMISSION_REQUIRED_FIELDS, type BillActivityEvent, BillActivityTimeline, type BillActivityTimelineProps, type BillAgingBucket, type BillAgingBucketId, BillAgingSummary, type BillAgingSummaryProps, BillLifecycleActions, type BillLifecycleActionsProps, BillLifecycleProgress, type BillLifecycleProgressProps, type BillLifecycleStage, BillList, type BillListProps, BillPayerContactCard, type BillPayerContactCardProps, BillPaymentLedger, type BillPaymentLedgerProps, BillReadOnlyForm, type BillReadOnlyFormProps, BillRemittanceCard, type BillRemittanceCardProps, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, BillSnapshotSummary, type BillSnapshotSummaryProps, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, BillSubmissionActions, type BillSubmissionAddress, BillSubmissionAttachmentsSection, BillSubmissionClaimSection, type BillSubmissionDiagnosisOption, type BillSubmissionDocumentType, type BillSubmissionEvaluationType, BillSubmissionForm, type BillSubmissionFormProps, type BillSubmissionFormValue, BillSubmissionHeader, type BillSubmissionInput, type BillSubmissionModifierOption, BillSubmissionPatientSection, type BillSubmissionPostalPlace, type BillSubmissionProcedureOption, BillSubmissionProvidersSection, type BillSubmissionRoute, type BillSubmissionSectionId, BillSubmissionServiceLinesSection, type BillSubmissionSourceAttachment, type BillSubmissionUpload, type BillSubmissionValidation, type BillingComponentProps, BillingDashboard, type BillingDashboardBill, type BillingDashboardProps, type BillingDashboardSummary, BillingReport, type BillingReportDimension, type BillingReportProps, type BillingReportRow, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, DEFAULT_BILL_SUBMISSION_MODIFIERS, DEFAULT_BILL_SUBMISSION_PROCEDURES, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, applyBillSubmissionEvaluationModifiers, billActivityEventLabel, billAgingBucket, billAgingDays, billLifecycleDisplayLabel, billLifecycleStage, buildBillReviewSaveInput, buildBillingReportCsv, buildBillingReportRows, calculateBillSubmissionAllowedAmount, createBillStatusClient, ensureTrailingBillSubmissionLine, ensureTrailingProcedureLine, formatBillSubmissionDate, mindBillAppearanceStyle, mindBillThemePresets, parseBillSubmissionDate, resolveMindBillAppearance, summarizeBillingDashboard, useBillLifecycle, useBillStatus, validateBillSubmission, visibleBillLifecycleActions };
|
|
793
|
+
export { BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, BILL_SUBMISSION_DOCUMENT_TYPES, BILL_SUBMISSION_REQUIRED_FIELDS, type BillActivityEvent, BillActivityTimeline, type BillActivityTimelineProps, type BillAgingBucket, type BillAgingBucketId, BillAgingSummary, type BillAgingSummaryProps, BillLifecycleActions, type BillLifecycleActionsProps, BillLifecycleProgress, type BillLifecycleProgressProps, type BillLifecycleStage, BillList, type BillListProps, BillPayerContactCard, type BillPayerContactCardProps, BillPaymentLedger, type BillPaymentLedgerProps, BillReadOnlyForm, type BillReadOnlyFormProps, BillRemittanceCard, type BillRemittanceCardProps, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, BillSnapshotSummary, type BillSnapshotSummaryProps, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, BillSubmissionActions, type BillSubmissionAddress, BillSubmissionAttachmentsSection, BillSubmissionClaimSection, type BillSubmissionDiagnosisOption, type BillSubmissionDocumentType, type BillSubmissionEvaluationType, BillSubmissionForm, type BillSubmissionFormProps, type BillSubmissionFormValue, BillSubmissionHeader, type BillSubmissionInput, type BillSubmissionModifierOption, BillSubmissionPatientSection, type BillSubmissionPostalPlace, type BillSubmissionProcedureOption, BillSubmissionProvidersSection, type BillSubmissionRoute, type BillSubmissionSectionId, BillSubmissionServiceLinesSection, type BillSubmissionSourceAttachment, type BillSubmissionUpload, type BillSubmissionValidation, type BillingComponentProps, BillingDashboard, type BillingDashboardBill, type BillingDashboardProps, type BillingDashboardSummary, BillingReport, type BillingReportDimension, type BillingReportProps, type BillingReportRow, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, DEFAULT_BILL_SUBMISSION_MODIFIERS, DEFAULT_BILL_SUBMISSION_PROCEDURES, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, applyBillSubmissionEvaluationModifiers, billActivityEventLabel, billAgingBucket, billAgingDays, billLifecycleDisplayLabel, billLifecycleStage, buildBillReviewSaveInput, buildBillingReportCsv, buildBillingReportRows, calculateBillSubmissionAllowedAmount, createBillStatusClient, ensureTrailingBillSubmissionLine, ensureTrailingProcedureLine, formatBillSubmissionDate, mindBillAppearanceStyle, mindBillThemePresets, parseBillSubmissionDate, prepareBillSubmissionDocuments, resolveMindBillAppearance, summarizeBillingDashboard, useBillLifecycle, useBillStatus, validateBillSubmission, visibleBillLifecycleActions };
|
package/dist/index.js
CHANGED
|
@@ -1157,7 +1157,8 @@ var READ_ONLY_STYLES = `
|
|
|
1157
1157
|
// src/bill-submission-form.tsx
|
|
1158
1158
|
import { createContext, useCallback, useContext, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
1159
1159
|
import {
|
|
1160
|
-
createBillReferenceClient
|
|
1160
|
+
createBillReferenceClient,
|
|
1161
|
+
createBillSubmissionClient
|
|
1161
1162
|
} from "@mindbill/browser";
|
|
1162
1163
|
|
|
1163
1164
|
// src/billing-catalog.ts
|
|
@@ -1322,6 +1323,48 @@ var MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
|
1322
1323
|
var MAX_DOCUMENTS = 25;
|
|
1323
1324
|
var DIAGNOSIS_PAGE_SIZE = 100;
|
|
1324
1325
|
var EMPTY_ATTACHMENTS = [];
|
|
1326
|
+
function bytesToBase64(bytes) {
|
|
1327
|
+
let binary = "";
|
|
1328
|
+
for (let offset = 0; offset < bytes.length; offset += 32768) {
|
|
1329
|
+
binary += String.fromCharCode(...bytes.subarray(offset, offset + 32768));
|
|
1330
|
+
}
|
|
1331
|
+
return globalThis.btoa(binary);
|
|
1332
|
+
}
|
|
1333
|
+
async function pdfDocument(blob, input) {
|
|
1334
|
+
if (blob.size > MAX_PDF_BYTES) throw new Error(`${input.filename} is larger than 25 MB.`);
|
|
1335
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
1336
|
+
if (bytes.length < 5 || bytes[0] !== 37 || bytes[1] !== 80 || bytes[2] !== 68 || bytes[3] !== 70 || bytes[4] !== 45) {
|
|
1337
|
+
throw new Error(`${input.filename} is not a valid PDF.`);
|
|
1338
|
+
}
|
|
1339
|
+
return { ...input, contentBase64: bytesToBase64(bytes) };
|
|
1340
|
+
}
|
|
1341
|
+
async function prepareBillSubmissionDocuments({
|
|
1342
|
+
attachments,
|
|
1343
|
+
selectedIds,
|
|
1344
|
+
uploads,
|
|
1345
|
+
fetch: fetchOverride
|
|
1346
|
+
}) {
|
|
1347
|
+
const fetcher = fetchOverride ?? globalThis.fetch;
|
|
1348
|
+
if (typeof fetcher !== "function") throw new Error("A Fetch API implementation is required.");
|
|
1349
|
+
const selected = selectedIds.map((id) => attachments.find((item) => item.id === id)).filter((item) => Boolean(item));
|
|
1350
|
+
const sourceDocuments = await Promise.all(selected.map(async (attachment) => {
|
|
1351
|
+
if (!attachment.previewUrl) throw new Error(`${attachment.fileName} cannot be submitted because its document URL is missing.`);
|
|
1352
|
+
const response = await fetcher(attachment.previewUrl, { credentials: "same-origin" });
|
|
1353
|
+
if (!response.ok) throw new Error(`${attachment.fileName} could not be loaded for submission.`);
|
|
1354
|
+
return pdfDocument(await response.blob(), {
|
|
1355
|
+
externalId: attachment.id,
|
|
1356
|
+
filename: attachment.fileName,
|
|
1357
|
+
documentType: attachment.documentType,
|
|
1358
|
+
...attachment.description ? { description: attachment.description } : {}
|
|
1359
|
+
});
|
|
1360
|
+
}));
|
|
1361
|
+
const uploadedDocuments = await Promise.all(uploads.map(({ file, documentType, description }) => pdfDocument(file, {
|
|
1362
|
+
filename: file.name,
|
|
1363
|
+
documentType,
|
|
1364
|
+
...description ? { description } : {}
|
|
1365
|
+
})));
|
|
1366
|
+
return [...sourceDocuments, ...uploadedDocuments];
|
|
1367
|
+
}
|
|
1325
1368
|
function previewUploadedPdf(file) {
|
|
1326
1369
|
const url = URL.createObjectURL(file);
|
|
1327
1370
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
@@ -1559,6 +1602,7 @@ function BillSubmissionForm({
|
|
|
1559
1602
|
initialBill,
|
|
1560
1603
|
attachments = EMPTY_ATTACHMENTS,
|
|
1561
1604
|
onSubmit,
|
|
1605
|
+
onSubmitted,
|
|
1562
1606
|
getSession,
|
|
1563
1607
|
sessionEndpoint,
|
|
1564
1608
|
apiBaseUrl,
|
|
@@ -1602,7 +1646,9 @@ function BillSubmissionForm({
|
|
|
1602
1646
|
const procedures = useMemo2(() => mergeOptions(DEFAULT_BILL_SUBMISSION_PROCEDURES, procedureOptions), [procedureOptions]);
|
|
1603
1647
|
const modifiers = useMemo2(() => mergeOptions(DEFAULT_BILL_SUBMISSION_MODIFIERS, modifierOptions), [modifierOptions]);
|
|
1604
1648
|
const [evaluationType, setEvaluationType] = useState2(() => initialBill.renderingProvider?.isAme ? "ame" : initialBill.renderingProvider?.specialty?.toLowerCase().includes("psych") ? "psych_qme" : "qme");
|
|
1605
|
-
const
|
|
1649
|
+
const connected = !onSubmit;
|
|
1650
|
+
const referenceClient = useMemo2(() => getSession || sessionEndpoint || connected ? createBillReferenceClient({ getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride }) : null, [getSession, sessionEndpoint, apiBaseUrl, fetchOverride, connected]);
|
|
1651
|
+
const submissionClient = useMemo2(() => connected ? createBillSubmissionClient({ getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride }) : null, [getSession, sessionEndpoint, apiBaseUrl, fetchOverride, connected]);
|
|
1606
1652
|
const locked = disabled || submitting;
|
|
1607
1653
|
useEffect2(() => {
|
|
1608
1654
|
setBill(cloneBill(initialBill));
|
|
@@ -1760,7 +1806,19 @@ function BillSubmissionForm({
|
|
|
1760
1806
|
if (selectedIds.length + uploads.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
|
|
1761
1807
|
setSubmitting(true);
|
|
1762
1808
|
try {
|
|
1763
|
-
|
|
1809
|
+
if (onSubmit) {
|
|
1810
|
+
await onSubmit({ bill: clean, sourceAttachmentIds: selectedIds, uploads });
|
|
1811
|
+
} else {
|
|
1812
|
+
if (!submissionClient) throw new Error("The connected billing client is unavailable.");
|
|
1813
|
+
const documents = await prepareBillSubmissionDocuments({
|
|
1814
|
+
attachments,
|
|
1815
|
+
selectedIds,
|
|
1816
|
+
uploads,
|
|
1817
|
+
...fetchOverride ? { fetch: fetchOverride } : {}
|
|
1818
|
+
});
|
|
1819
|
+
const result = await submissionClient.submitBill({ bill: clean, documents });
|
|
1820
|
+
await onSubmitted?.(result);
|
|
1821
|
+
}
|
|
1764
1822
|
} catch (caught) {
|
|
1765
1823
|
setFormError(caught instanceof Error ? caught.message : "Unable to submit the bill.");
|
|
1766
1824
|
} finally {
|
|
@@ -3225,6 +3283,7 @@ export {
|
|
|
3225
3283
|
mindBillAppearanceStyle,
|
|
3226
3284
|
mindBillThemePresets,
|
|
3227
3285
|
parseBillSubmissionDate,
|
|
3286
|
+
prepareBillSubmissionDocuments,
|
|
3228
3287
|
resolveMindBillAppearance,
|
|
3229
3288
|
summarizeBillingDashboard,
|
|
3230
3289
|
useBillLifecycle,
|