@paro.io/expert-shared-components 1.14.61 → 1.14.63
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/lib/components/TaxAxis/TaxAxisShell.js +2 -2
- package/lib/tax-axis/components/dashboard/TaxAxisDashboard.d.ts +2 -1
- package/lib/tax-axis/components/dashboard/TaxAxisDashboard.js +74 -9
- package/lib/tax-axis/components/documents/DocumentCard.d.ts +3 -1
- package/lib/tax-axis/components/documents/DocumentCard.js +15 -3
- package/lib/tax-axis/components/documents/DocumentReviewModal.d.ts +1 -3
- package/lib/tax-axis/components/documents/DocumentReviewModal.js +263 -113
- package/lib/tax-axis/components/documents/DocumentTier.d.ts +3 -1
- package/lib/tax-axis/components/documents/DocumentTier.js +2 -2
- package/lib/tax-axis/components/documents/TaxAxisDocuments.js +21 -2
- package/lib/tax-axis/components/extractionReview/TaxAxisExtractionReview.js +17 -17
- package/lib/tax-axis/components/intake/TaxAxisIntake.js +67 -6
- package/lib/tax-axis/index.d.ts +2 -0
- package/lib/tax-axis/index.js +5 -1
- package/package.json +1 -1
- package/lib/tax-axis/components/documents/qbo/QboAvailableReportsModal.d.ts +0 -13
- package/lib/tax-axis/components/documents/qbo/QboAvailableReportsModal.js +0 -180
- package/lib/tax-axis/components/documents/qbo/QboClientSelectorModal.d.ts +0 -10
- package/lib/tax-axis/components/documents/qbo/QboClientSelectorModal.js +0 -155
- package/lib/tax-axis/components/documents/qbo/QboConnectBanner.d.ts +0 -9
- package/lib/tax-axis/components/documents/qbo/QboConnectBanner.js +0 -55
- package/lib/tax-axis/components/documents/qbo/QboDocumentMappingModal.d.ts +0 -10
- package/lib/tax-axis/components/documents/qbo/QboDocumentMappingModal.js +0 -202
- package/lib/tax-axis/components/documents/qbo/QboImportingModal.d.ts +0 -8
- package/lib/tax-axis/components/documents/qbo/QboImportingModal.js +0 -75
- package/lib/tax-axis/components/documents/qbo/QboPermissionsModal.d.ts +0 -8
- package/lib/tax-axis/components/documents/qbo/QboPermissionsModal.js +0 -126
- package/lib/tax-axis/components/documents/qbo/index.d.ts +0 -8
- package/lib/tax-axis/components/documents/qbo/index.js +0 -17
- package/lib/tax-axis/components/documents/qbo/qboConstants.d.ts +0 -24
- package/lib/tax-axis/components/documents/qbo/qboConstants.js +0 -71
- package/lib/tax-axis/components/documents/qbo/types.d.ts +0 -43
- package/lib/tax-axis/components/documents/qbo/types.js +0 -3
- package/lib/tax-axis/components/documents/qbo/useQboFlow.d.ts +0 -19
- package/lib/tax-axis/components/documents/qbo/useQboFlow.js +0 -207
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useQboFlow = useQboFlow;
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
const qboConstants_1 = require("./qboConstants");
|
|
15
|
-
function buildCompany(companyName) {
|
|
16
|
-
const name = companyName || "My QuickBooks Company";
|
|
17
|
-
const initials = name
|
|
18
|
-
.split(/\s+/)
|
|
19
|
-
.slice(0, 2)
|
|
20
|
-
.map((w) => { var _a, _b; return (_b = (_a = w[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : ""; })
|
|
21
|
-
.join("");
|
|
22
|
-
return { id: "connected", name, initials, color: "#2CA01C" };
|
|
23
|
-
}
|
|
24
|
-
function useQboFlow({ qboConnected, qboCompanyName, qboAuthorizeUrl, onImportQboReport, fetchUploadedDocuments, sessionId, profileYear, onQboConnected, onQboDisconnected, onQboImportComplete, }) {
|
|
25
|
-
const [modalStep, setModalStep] = (0, react_1.useState)("closed");
|
|
26
|
-
const [selectedCompany, setSelectedCompany] = (0, react_1.useState)(qboConnected ? buildCompany(qboCompanyName) : null);
|
|
27
|
-
const [selectedReports, setSelectedReports] = (0, react_1.useState)([]);
|
|
28
|
-
const [selectedYear, setSelectedYear] = (0, react_1.useState)(profileYear !== null && profileYear !== void 0 ? profileYear : new Date().getFullYear());
|
|
29
|
-
const [importStepIndex, setImportStepIndex] = (0, react_1.useState)(0);
|
|
30
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
31
|
-
const pollTimerRef = (0, react_1.useRef)(null);
|
|
32
|
-
// Keep selectedYear in sync if profileYear prop changes
|
|
33
|
-
const prevProfileYear = (0, react_1.useRef)(profileYear);
|
|
34
|
-
if (profileYear !== prevProfileYear.current) {
|
|
35
|
-
prevProfileYear.current = profileYear;
|
|
36
|
-
if (profileYear)
|
|
37
|
-
setSelectedYear(profileYear);
|
|
38
|
-
}
|
|
39
|
-
// Sync company when qboCompanyName prop changes
|
|
40
|
-
(0, react_1.useEffect)(() => {
|
|
41
|
-
if (qboConnected)
|
|
42
|
-
setSelectedCompany(buildCompany(qboCompanyName));
|
|
43
|
-
}, [qboConnected, qboCompanyName]);
|
|
44
|
-
// Cleanup poll timer on unmount
|
|
45
|
-
(0, react_1.useEffect)(() => {
|
|
46
|
-
return () => {
|
|
47
|
-
if (pollTimerRef.current)
|
|
48
|
-
clearInterval(pollTimerRef.current);
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
// ── Already connected: skip straight to report selection ──
|
|
52
|
-
const openImport = (0, react_1.useCallback)(() => {
|
|
53
|
-
setError(null);
|
|
54
|
-
setSelectedCompany(buildCompany(qboCompanyName));
|
|
55
|
-
setModalStep("available_reports");
|
|
56
|
-
}, [qboCompanyName]);
|
|
57
|
-
// ── Not yet connected: start OAuth flow ──
|
|
58
|
-
const openPermissions = (0, react_1.useCallback)(() => {
|
|
59
|
-
setError(null);
|
|
60
|
-
setModalStep("permissions");
|
|
61
|
-
}, []);
|
|
62
|
-
// ── After permissions: start OAuth popup ──
|
|
63
|
-
const handlePermissionsContinue = (0, react_1.useCallback)(() => {
|
|
64
|
-
const isDemoMode = typeof window !== "undefined" &&
|
|
65
|
-
(!qboAuthorizeUrl || window.location.hostname === "localhost");
|
|
66
|
-
if (isDemoMode) {
|
|
67
|
-
setSelectedCompany(buildCompany(qboCompanyName));
|
|
68
|
-
setModalStep("client_selector");
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
setModalStep("oauth_pending");
|
|
72
|
-
const authorizeUrl = qboAuthorizeUrl;
|
|
73
|
-
const redirectUri = `${window.location.origin}/integrations-hub/callback`;
|
|
74
|
-
const authUrl = authorizeUrl.includes("?")
|
|
75
|
-
? `${authorizeUrl}&redirectUri=${encodeURIComponent(redirectUri)}`
|
|
76
|
-
: `${authorizeUrl}?redirectUri=${encodeURIComponent(redirectUri)}`;
|
|
77
|
-
const popup = window.open(authUrl, "qbo_oauth", "width=600,height=700,scrollbars=yes");
|
|
78
|
-
// Poll for popup close — parent will re-fetch EPS and update qboConnected prop
|
|
79
|
-
let elapsed = 0;
|
|
80
|
-
pollTimerRef.current = setInterval(() => {
|
|
81
|
-
elapsed += 500;
|
|
82
|
-
if (popup && popup.closed) {
|
|
83
|
-
if (pollTimerRef.current)
|
|
84
|
-
clearInterval(pollTimerRef.current);
|
|
85
|
-
// Parent prop update will trigger the useEffect above to set selectedCompany
|
|
86
|
-
setModalStep("client_selector");
|
|
87
|
-
}
|
|
88
|
-
if (elapsed >= 120000) {
|
|
89
|
-
if (pollTimerRef.current)
|
|
90
|
-
clearInterval(pollTimerRef.current);
|
|
91
|
-
setError("QuickBooks authorization timed out. Please try again.");
|
|
92
|
-
setModalStep("closed");
|
|
93
|
-
}
|
|
94
|
-
}, 500);
|
|
95
|
-
}, [qboAuthorizeUrl, qboCompanyName]);
|
|
96
|
-
// ── Company selected ──
|
|
97
|
-
const handleCompanySelected = (0, react_1.useCallback)((company) => {
|
|
98
|
-
setSelectedCompany(company);
|
|
99
|
-
setModalStep("available_reports");
|
|
100
|
-
}, []);
|
|
101
|
-
// ── Reports confirmed → import ──
|
|
102
|
-
const handleReportsConfirmed = (0, react_1.useCallback)((reportIds) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
var _a;
|
|
104
|
-
setSelectedReports(reportIds);
|
|
105
|
-
if (!onImportQboReport || !sessionId || !selectedCompany) {
|
|
106
|
-
setError("Import configuration is incomplete.");
|
|
107
|
-
setModalStep("closed");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
setModalStep("importing");
|
|
111
|
-
setImportStepIndex(0);
|
|
112
|
-
try {
|
|
113
|
-
yield new Promise((r) => setTimeout(r, 600));
|
|
114
|
-
setImportStepIndex(1);
|
|
115
|
-
yield new Promise((r) => setTimeout(r, 400));
|
|
116
|
-
setImportStepIndex(2);
|
|
117
|
-
const realmId = selectedCompany.id;
|
|
118
|
-
const importPromises = reportIds.map((reportId) => {
|
|
119
|
-
const reportType = reportId === "profit_loss" ? "profit_loss" : "balance_sheet";
|
|
120
|
-
return onImportQboReport(sessionId, realmId, reportType, "Accrual", selectedYear);
|
|
121
|
-
});
|
|
122
|
-
const results = yield Promise.allSettled(importPromises);
|
|
123
|
-
setImportStepIndex(3);
|
|
124
|
-
const failures = results.filter((r) => r.status === "rejected");
|
|
125
|
-
if (failures.length === results.length) {
|
|
126
|
-
const msg = ((_a = failures[0].reason) === null || _a === void 0 ? void 0 : _a.message) || "Import failed";
|
|
127
|
-
setError(msg);
|
|
128
|
-
setModalStep("closed");
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
yield new Promise((r) => setTimeout(r, 500));
|
|
132
|
-
setImportStepIndex(4);
|
|
133
|
-
if (failures.length > 0) {
|
|
134
|
-
const msg = failures
|
|
135
|
-
.map((f) => { var _a; return ((_a = f.reason) === null || _a === void 0 ? void 0 : _a.message) || "Import failed"; })
|
|
136
|
-
.join("; ");
|
|
137
|
-
setError(msg);
|
|
138
|
-
}
|
|
139
|
-
if (fetchUploadedDocuments) {
|
|
140
|
-
try {
|
|
141
|
-
yield fetchUploadedDocuments();
|
|
142
|
-
}
|
|
143
|
-
catch ( /* non-fatal */_b) { /* non-fatal */ }
|
|
144
|
-
}
|
|
145
|
-
if (onQboConnected)
|
|
146
|
-
onQboConnected(selectedCompany.name);
|
|
147
|
-
if (onQboImportComplete) {
|
|
148
|
-
const mappedDocs = reportIds
|
|
149
|
-
.map((reportId) => {
|
|
150
|
-
const option = qboConstants_1.QBO_REPORT_OPTIONS.find((o) => o.id === reportId);
|
|
151
|
-
return option ? { slot: option.documentType, fileName: option.label } : null;
|
|
152
|
-
})
|
|
153
|
-
.filter((m) => m !== null);
|
|
154
|
-
onQboImportComplete(mappedDocs);
|
|
155
|
-
}
|
|
156
|
-
setModalStep("done");
|
|
157
|
-
setTimeout(() => { setModalStep("closed"); }, 1500);
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
const msg = err instanceof Error ? err.message : "Import failed. Please try again.";
|
|
161
|
-
setError(msg);
|
|
162
|
-
setModalStep("closed");
|
|
163
|
-
}
|
|
164
|
-
}), [
|
|
165
|
-
onImportQboReport,
|
|
166
|
-
sessionId,
|
|
167
|
-
selectedCompany,
|
|
168
|
-
selectedYear,
|
|
169
|
-
fetchUploadedDocuments,
|
|
170
|
-
onQboConnected,
|
|
171
|
-
onQboImportComplete,
|
|
172
|
-
]);
|
|
173
|
-
const handleMappingConfirm = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
yield handleReportsConfirmed(selectedReports);
|
|
175
|
-
}), [handleReportsConfirmed, selectedReports]);
|
|
176
|
-
const handleDisconnect = (0, react_1.useCallback)(() => {
|
|
177
|
-
setSelectedCompany(null);
|
|
178
|
-
setSelectedReports([]);
|
|
179
|
-
setImportStepIndex(0);
|
|
180
|
-
setModalStep("closed");
|
|
181
|
-
if (onQboDisconnected)
|
|
182
|
-
onQboDisconnected();
|
|
183
|
-
}, [onQboDisconnected]);
|
|
184
|
-
const closeModal = (0, react_1.useCallback)(() => {
|
|
185
|
-
setModalStep("closed");
|
|
186
|
-
setError(null);
|
|
187
|
-
}, []);
|
|
188
|
-
const companies = selectedCompany ? [selectedCompany] : [];
|
|
189
|
-
return {
|
|
190
|
-
modalStep,
|
|
191
|
-
selectedCompany,
|
|
192
|
-
selectedReports,
|
|
193
|
-
selectedYear,
|
|
194
|
-
setSelectedYear,
|
|
195
|
-
importStepIndex,
|
|
196
|
-
error,
|
|
197
|
-
companies,
|
|
198
|
-
openPermissions,
|
|
199
|
-
openImport,
|
|
200
|
-
handlePermissionsContinue,
|
|
201
|
-
handleCompanySelected,
|
|
202
|
-
handleReportsConfirmed,
|
|
203
|
-
handleMappingConfirm,
|
|
204
|
-
handleDisconnect,
|
|
205
|
-
closeModal,
|
|
206
|
-
};
|
|
207
|
-
}
|