@layerfi/components 0.1.99-alpha-1 → 0.1.99
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/dist/cjs/index.cjs +1202 -1035
- package/dist/esm/index.mjs +633 -466
- package/dist/index.css +123 -137
- package/dist/index.d.ts +79 -54
- package/package.json +2 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -5570,7 +5570,7 @@ import { useState as useState8 } from "react";
|
|
|
5570
5570
|
import { useReducer, useEffect as useEffect4 } from "react";
|
|
5571
5571
|
|
|
5572
5572
|
// package.json
|
|
5573
|
-
var version = "0.1.99
|
|
5573
|
+
var version = "0.1.99";
|
|
5574
5574
|
|
|
5575
5575
|
// src/models/APIError.ts
|
|
5576
5576
|
var APIError = class _APIError extends Error {
|
|
@@ -5643,7 +5643,7 @@ var postWithFormData = (url, formData, baseUrl, accessToken) => {
|
|
|
5643
5643
|
body: formData
|
|
5644
5644
|
}).then((res) => handleResponse(res)).catch((error) => handleException(error));
|
|
5645
5645
|
};
|
|
5646
|
-
var handleResponse = (res) => __async(
|
|
5646
|
+
var handleResponse = (res) => __async(null, null, function* () {
|
|
5647
5647
|
var _a;
|
|
5648
5648
|
if (!res.ok) {
|
|
5649
5649
|
const errors = yield tryToReadErrorsFromResponse(res);
|
|
@@ -5684,7 +5684,7 @@ var handleException = (error) => {
|
|
|
5684
5684
|
});
|
|
5685
5685
|
throw apiError;
|
|
5686
5686
|
};
|
|
5687
|
-
var tryToReadErrorsFromResponse = (res) => __async(
|
|
5687
|
+
var tryToReadErrorsFromResponse = (res) => __async(null, null, function* () {
|
|
5688
5688
|
var _a;
|
|
5689
5689
|
try {
|
|
5690
5690
|
const data = yield res == null ? void 0 : res.json();
|
|
@@ -5910,7 +5910,7 @@ var updateConnectionStatus = post(
|
|
|
5910
5910
|
var updateOpeningBalance = post(
|
|
5911
5911
|
({ businessId, accountId }) => `/v1/businesses/${businessId}/external-accounts/${accountId}/opening-balance`
|
|
5912
5912
|
);
|
|
5913
|
-
var
|
|
5913
|
+
var listExternalAccounts = get(({ businessId }) => `/v1/businesses/${businessId}/external-accounts`);
|
|
5914
5914
|
var confirmAccount = post(
|
|
5915
5915
|
({ businessId, accountId }) => `/v1/businesses/${businessId}/external-accounts/${accountId}/confirm`
|
|
5916
5916
|
);
|
|
@@ -6008,8 +6008,6 @@ var getVendors = get(
|
|
|
6008
6008
|
// src/api/layer.ts
|
|
6009
6009
|
var Layer = {
|
|
6010
6010
|
getBusiness,
|
|
6011
|
-
categorizeBankTransaction,
|
|
6012
|
-
matchBankTransaction,
|
|
6013
6011
|
createAccount,
|
|
6014
6012
|
updateAccount,
|
|
6015
6013
|
createChildAccount,
|
|
@@ -6036,7 +6034,6 @@ var Layer = {
|
|
|
6036
6034
|
getProfitAndLossSummaries,
|
|
6037
6035
|
getProfitAndLossCsv,
|
|
6038
6036
|
getProfitAndLossExcel,
|
|
6039
|
-
getLinkedAccounts,
|
|
6040
6037
|
getJournal,
|
|
6041
6038
|
getJournalEntriesCSV,
|
|
6042
6039
|
reverseJournalEntry,
|
|
@@ -6751,9 +6748,6 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
|
|
|
6751
6748
|
}
|
|
6752
6749
|
];
|
|
6753
6750
|
|
|
6754
|
-
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
6755
|
-
import useSWR2 from "swr";
|
|
6756
|
-
|
|
6757
6751
|
// src/hooks/useAuth.ts
|
|
6758
6752
|
import useSWR from "swr";
|
|
6759
6753
|
|
|
@@ -6986,6 +6980,42 @@ function AccountConfirmationStoreProvider({
|
|
|
6986
6980
|
return /* @__PURE__ */ jsx6(AccountConfirmationStoreContext.Provider, { value: store, children });
|
|
6987
6981
|
}
|
|
6988
6982
|
|
|
6983
|
+
// src/hooks/useLinkedAccounts/useListExternalAccounts.ts
|
|
6984
|
+
import useSWR2 from "swr";
|
|
6985
|
+
var EXTERNAL_ACCOUNTS_TAG_KEY = "#external-accounts";
|
|
6986
|
+
function buildKey2({
|
|
6987
|
+
access_token: accessToken,
|
|
6988
|
+
apiUrl,
|
|
6989
|
+
businessId
|
|
6990
|
+
}) {
|
|
6991
|
+
if (accessToken && apiUrl) {
|
|
6992
|
+
return {
|
|
6993
|
+
accessToken,
|
|
6994
|
+
apiUrl,
|
|
6995
|
+
businessId,
|
|
6996
|
+
tags: [EXTERNAL_ACCOUNTS_TAG_KEY]
|
|
6997
|
+
};
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
function useListExternalAccounts() {
|
|
7001
|
+
const { businessId } = useLayerContext();
|
|
7002
|
+
const { apiUrl } = useEnvironment();
|
|
7003
|
+
const { data: auth } = useAuth();
|
|
7004
|
+
return useSWR2(
|
|
7005
|
+
() => buildKey2(__spreadProps(__spreadValues({}, auth), {
|
|
7006
|
+
apiUrl,
|
|
7007
|
+
businessId
|
|
7008
|
+
})),
|
|
7009
|
+
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => listExternalAccounts(
|
|
7010
|
+
apiUrl2,
|
|
7011
|
+
accessToken,
|
|
7012
|
+
{
|
|
7013
|
+
params: { businessId: businessId2 }
|
|
7014
|
+
}
|
|
7015
|
+
)().then(({ data }) => data.external_accounts)
|
|
7016
|
+
);
|
|
7017
|
+
}
|
|
7018
|
+
|
|
6989
7019
|
// src/hooks/useLinkedAccounts/useLinkedAccounts.ts
|
|
6990
7020
|
function getAccountsNeedingConfirmation(linkedAccounts) {
|
|
6991
7021
|
return linkedAccounts.filter(
|
|
@@ -6995,7 +7025,6 @@ function getAccountsNeedingConfirmation(linkedAccounts) {
|
|
|
6995
7025
|
var DEBUG = false;
|
|
6996
7026
|
var USE_MOCK_RESPONSE_DATA = false;
|
|
6997
7027
|
var useLinkedAccounts = () => {
|
|
6998
|
-
var _a;
|
|
6999
7028
|
const {
|
|
7000
7029
|
businessId,
|
|
7001
7030
|
touch,
|
|
@@ -7015,19 +7044,14 @@ var useLinkedAccounts = () => {
|
|
|
7015
7044
|
const [accountsToAddOpeningBalanceInModal, setAccountsToAddOpeningBalanceInModal] = useState5([]);
|
|
7016
7045
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `linked-accounts-${businessId}`;
|
|
7017
7046
|
const {
|
|
7018
|
-
data:
|
|
7047
|
+
data: externalAccounts,
|
|
7019
7048
|
isLoading,
|
|
7020
7049
|
isValidating,
|
|
7021
7050
|
error: responseError,
|
|
7022
7051
|
mutate
|
|
7023
|
-
} =
|
|
7024
|
-
queryKey,
|
|
7025
|
-
Layer.getLinkedAccounts(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7026
|
-
params: { businessId }
|
|
7027
|
-
})
|
|
7028
|
-
);
|
|
7052
|
+
} = useListExternalAccounts();
|
|
7029
7053
|
useEffect2(() => {
|
|
7030
|
-
if (!isLoading &&
|
|
7054
|
+
if (!isLoading && externalAccounts) {
|
|
7031
7055
|
setLoadingStatus("complete");
|
|
7032
7056
|
return;
|
|
7033
7057
|
}
|
|
@@ -7039,7 +7063,7 @@ var useLinkedAccounts = () => {
|
|
|
7039
7063
|
setLoadingStatus("complete");
|
|
7040
7064
|
}
|
|
7041
7065
|
}, [isLoading]);
|
|
7042
|
-
const fetchPlaidLinkToken = () => __async(
|
|
7066
|
+
const fetchPlaidLinkToken = () => __async(null, null, function* () {
|
|
7043
7067
|
if (auth == null ? void 0 : auth.access_token) {
|
|
7044
7068
|
const linkToken2 = (yield Layer.getPlaidLinkToken(apiUrl, auth.access_token, {
|
|
7045
7069
|
params: { businessId }
|
|
@@ -7048,7 +7072,7 @@ var useLinkedAccounts = () => {
|
|
|
7048
7072
|
setLinkToken(linkToken2);
|
|
7049
7073
|
}
|
|
7050
7074
|
});
|
|
7051
|
-
const fetchPlaidUpdateModeLinkToken = (plaidItemPlaidId) => __async(
|
|
7075
|
+
const fetchPlaidUpdateModeLinkToken = (plaidItemPlaidId) => __async(null, null, function* () {
|
|
7052
7076
|
if (auth == null ? void 0 : auth.access_token) {
|
|
7053
7077
|
const linkToken2 = (yield Layer.getPlaidUpdateModeLinkToken(apiUrl, auth.access_token, {
|
|
7054
7078
|
params: { businessId },
|
|
@@ -7058,7 +7082,7 @@ var useLinkedAccounts = () => {
|
|
|
7058
7082
|
setLinkToken(linkToken2);
|
|
7059
7083
|
}
|
|
7060
7084
|
});
|
|
7061
|
-
const exchangePlaidPublicToken2 = (publicToken, metadata) => __async(
|
|
7085
|
+
const exchangePlaidPublicToken2 = (publicToken, metadata) => __async(null, null, function* () {
|
|
7062
7086
|
preloadAccountConfirmation();
|
|
7063
7087
|
try {
|
|
7064
7088
|
yield Layer.exchangePlaidPublicToken(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -7074,7 +7098,7 @@ var useLinkedAccounts = () => {
|
|
|
7074
7098
|
token: linkToken,
|
|
7075
7099
|
// If in update mode, we don't need to exchange the public token for an access token.
|
|
7076
7100
|
// The existing access token will automatically become valid again
|
|
7077
|
-
onSuccess: (publicToken, metadata) => __async(
|
|
7101
|
+
onSuccess: (publicToken, metadata) => __async(null, null, function* () {
|
|
7078
7102
|
if (linkMode == "add") {
|
|
7079
7103
|
exchangePlaidPublicToken2(publicToken, metadata);
|
|
7080
7104
|
} else {
|
|
@@ -7106,7 +7130,7 @@ var useLinkedAccounts = () => {
|
|
|
7106
7130
|
);
|
|
7107
7131
|
}
|
|
7108
7132
|
};
|
|
7109
|
-
const repairConnection = (source, connectionExternalId) => __async(
|
|
7133
|
+
const repairConnection = (source, connectionExternalId) => __async(null, null, function* () {
|
|
7110
7134
|
if (source === "PLAID") {
|
|
7111
7135
|
yield fetchPlaidUpdateModeLinkToken(connectionExternalId);
|
|
7112
7136
|
} else {
|
|
@@ -7115,7 +7139,7 @@ var useLinkedAccounts = () => {
|
|
|
7115
7139
|
);
|
|
7116
7140
|
}
|
|
7117
7141
|
});
|
|
7118
|
-
const removeConnection = (source, connectionExternalId) => __async(
|
|
7142
|
+
const removeConnection = (source, connectionExternalId) => __async(null, null, function* () {
|
|
7119
7143
|
if (source === "PLAID") {
|
|
7120
7144
|
yield unlinkPlaidItem2(connectionExternalId);
|
|
7121
7145
|
yield refetchAccounts();
|
|
@@ -7125,7 +7149,7 @@ var useLinkedAccounts = () => {
|
|
|
7125
7149
|
);
|
|
7126
7150
|
}
|
|
7127
7151
|
});
|
|
7128
|
-
const unlinkAccount2 = (source, accountId) => __async(
|
|
7152
|
+
const unlinkAccount2 = (source, accountId) => __async(null, null, function* () {
|
|
7129
7153
|
DEBUG && console.debug("unlinking account");
|
|
7130
7154
|
if (source === "PLAID") {
|
|
7131
7155
|
yield Layer.unlinkAccount(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -7139,7 +7163,7 @@ var useLinkedAccounts = () => {
|
|
|
7139
7163
|
);
|
|
7140
7164
|
}
|
|
7141
7165
|
});
|
|
7142
|
-
const confirmAccount2 = (source, accountId) => __async(
|
|
7166
|
+
const confirmAccount2 = (source, accountId) => __async(null, null, function* () {
|
|
7143
7167
|
DEBUG && console.debug("confirming account");
|
|
7144
7168
|
if (source === "PLAID") {
|
|
7145
7169
|
yield Layer.confirmAccount(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -7156,7 +7180,7 @@ var useLinkedAccounts = () => {
|
|
|
7156
7180
|
);
|
|
7157
7181
|
}
|
|
7158
7182
|
});
|
|
7159
|
-
const excludeAccount2 = (source, accountId) => __async(
|
|
7183
|
+
const excludeAccount2 = (source, accountId) => __async(null, null, function* () {
|
|
7160
7184
|
DEBUG && console.debug("excluding account");
|
|
7161
7185
|
if (source === "PLAID") {
|
|
7162
7186
|
yield Layer.excludeAccount(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -7176,7 +7200,7 @@ var useLinkedAccounts = () => {
|
|
|
7176
7200
|
);
|
|
7177
7201
|
}
|
|
7178
7202
|
});
|
|
7179
|
-
const breakConnection = (source, connectionExternalId) => __async(
|
|
7203
|
+
const breakConnection = (source, connectionExternalId) => __async(null, null, function* () {
|
|
7180
7204
|
DEBUG && console.debug("Breaking sandbox plaid item connection");
|
|
7181
7205
|
if (source === "PLAID") {
|
|
7182
7206
|
yield Layer.breakPlaidItemConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
@@ -7193,23 +7217,23 @@ var useLinkedAccounts = () => {
|
|
|
7193
7217
|
);
|
|
7194
7218
|
}
|
|
7195
7219
|
});
|
|
7196
|
-
const refetchAccounts = () => __async(
|
|
7220
|
+
const refetchAccounts = () => __async(null, null, function* () {
|
|
7197
7221
|
DEBUG && console.debug("refetching accounts...");
|
|
7198
7222
|
yield mutate();
|
|
7199
7223
|
});
|
|
7200
|
-
const syncAccounts = () => __async(
|
|
7224
|
+
const syncAccounts = () => __async(null, null, function* () {
|
|
7201
7225
|
DEBUG && console.debug("resyncing accounts...");
|
|
7202
7226
|
yield Layer.syncConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7203
7227
|
params: { businessId }
|
|
7204
7228
|
});
|
|
7205
7229
|
});
|
|
7206
|
-
const updateConnectionStatus2 = () => __async(
|
|
7230
|
+
const updateConnectionStatus2 = () => __async(null, null, function* () {
|
|
7207
7231
|
DEBUG && console.debug("updating connection status...");
|
|
7208
7232
|
yield Layer.updateConnectionStatus(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7209
7233
|
params: { businessId }
|
|
7210
7234
|
});
|
|
7211
7235
|
});
|
|
7212
|
-
const unlinkPlaidItem2 = (plaidItemPlaidId) => __async(
|
|
7236
|
+
const unlinkPlaidItem2 = (plaidItemPlaidId) => __async(null, null, function* () {
|
|
7213
7237
|
DEBUG && console.debug("unlinking plaid item");
|
|
7214
7238
|
yield Layer.unlinkPlaidItem(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7215
7239
|
params: { businessId, plaidItemPlaidId }
|
|
@@ -7228,7 +7252,7 @@ var useLinkedAccounts = () => {
|
|
|
7228
7252
|
}
|
|
7229
7253
|
}, [syncTimestamps]);
|
|
7230
7254
|
return {
|
|
7231
|
-
data: USE_MOCK_RESPONSE_DATA ? mockResponseData.data :
|
|
7255
|
+
data: USE_MOCK_RESPONSE_DATA ? mockResponseData.data : externalAccounts != null ? externalAccounts : [],
|
|
7232
7256
|
isLoading,
|
|
7233
7257
|
loadingStatus,
|
|
7234
7258
|
isValidating,
|
|
@@ -7316,6 +7340,7 @@ import { endOfMonth, startOfMonth } from "date-fns";
|
|
|
7316
7340
|
|
|
7317
7341
|
// src/hooks/useBankTransactions/useBankTransactions.ts
|
|
7318
7342
|
import useSWRInfinite from "swr/infinite";
|
|
7343
|
+
var BANK_TRANSACTIONS_TAG_KEY = "#bank-transactions";
|
|
7319
7344
|
function keyLoader(previousPageData, {
|
|
7320
7345
|
access_token: accessToken,
|
|
7321
7346
|
apiUrl,
|
|
@@ -7339,7 +7364,7 @@ function keyLoader(previousPageData, {
|
|
|
7339
7364
|
startDate,
|
|
7340
7365
|
endDate,
|
|
7341
7366
|
tagFilterQueryString,
|
|
7342
|
-
tags: [
|
|
7367
|
+
tags: [BANK_TRANSACTIONS_TAG_KEY]
|
|
7343
7368
|
};
|
|
7344
7369
|
}
|
|
7345
7370
|
}
|
|
@@ -7404,6 +7429,212 @@ function useBankTransactions({
|
|
|
7404
7429
|
);
|
|
7405
7430
|
}
|
|
7406
7431
|
|
|
7432
|
+
// src/hooks/useBankTransactions/useCategorizeBankTransaction.ts
|
|
7433
|
+
import { useCallback } from "react";
|
|
7434
|
+
import { useSWRConfig } from "swr";
|
|
7435
|
+
import useSWRMutation from "swr/mutation";
|
|
7436
|
+
|
|
7437
|
+
// src/utils/swr/withSWRKeyTags.ts
|
|
7438
|
+
function withSWRKeyTags(key, predicate) {
|
|
7439
|
+
if (typeof key !== "object" || key === null || !("tags" in key)) {
|
|
7440
|
+
return false;
|
|
7441
|
+
}
|
|
7442
|
+
return isStringArray(key.tags) ? predicate(key.tags) : false;
|
|
7443
|
+
}
|
|
7444
|
+
|
|
7445
|
+
// src/hooks/bookkeeping/useBankAccounts.ts
|
|
7446
|
+
import useSWR3 from "swr";
|
|
7447
|
+
var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
|
|
7448
|
+
var getBankAccounts = get(
|
|
7449
|
+
({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
|
|
7450
|
+
);
|
|
7451
|
+
function buildKey3({
|
|
7452
|
+
access_token: accessToken,
|
|
7453
|
+
apiUrl,
|
|
7454
|
+
businessId
|
|
7455
|
+
}) {
|
|
7456
|
+
if (accessToken && apiUrl) {
|
|
7457
|
+
return {
|
|
7458
|
+
accessToken,
|
|
7459
|
+
apiUrl,
|
|
7460
|
+
businessId,
|
|
7461
|
+
tags: [BANK_ACCOUNTS_TAG_KEY]
|
|
7462
|
+
};
|
|
7463
|
+
}
|
|
7464
|
+
}
|
|
7465
|
+
var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
|
|
7466
|
+
var useBankAccounts = () => {
|
|
7467
|
+
var _a, _b;
|
|
7468
|
+
const { businessId } = useLayerContext();
|
|
7469
|
+
const { apiUrl } = useEnvironment();
|
|
7470
|
+
const { data: auth } = useAuth();
|
|
7471
|
+
const { data, error, isLoading } = useSWR3(
|
|
7472
|
+
() => buildKey3(__spreadProps(__spreadValues({}, auth), {
|
|
7473
|
+
apiUrl,
|
|
7474
|
+
businessId
|
|
7475
|
+
})),
|
|
7476
|
+
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getBankAccounts(apiUrl2, accessToken, { params: { businessId: businessId2 } })()
|
|
7477
|
+
);
|
|
7478
|
+
const disconnectedAccountsRequiringNotification = ((_a = data == null ? void 0 : data.data) != null ? _a : []).filter(
|
|
7479
|
+
(account) => requiresNotification(account)
|
|
7480
|
+
).length;
|
|
7481
|
+
return {
|
|
7482
|
+
bankAccounts: (_b = data == null ? void 0 : data.data) != null ? _b : [],
|
|
7483
|
+
isLoading,
|
|
7484
|
+
error,
|
|
7485
|
+
disconnectedAccountsRequiringNotification
|
|
7486
|
+
};
|
|
7487
|
+
};
|
|
7488
|
+
|
|
7489
|
+
// src/hooks/useBankTransactions/useCategorizeBankTransaction.ts
|
|
7490
|
+
var CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
|
|
7491
|
+
function buildKey4({
|
|
7492
|
+
access_token: accessToken,
|
|
7493
|
+
apiUrl,
|
|
7494
|
+
businessId
|
|
7495
|
+
}) {
|
|
7496
|
+
if (accessToken && apiUrl) {
|
|
7497
|
+
return {
|
|
7498
|
+
accessToken,
|
|
7499
|
+
apiUrl,
|
|
7500
|
+
businessId,
|
|
7501
|
+
tags: [CATEGORIZE_BANK_TRANSACTION_TAG]
|
|
7502
|
+
};
|
|
7503
|
+
}
|
|
7504
|
+
}
|
|
7505
|
+
function useCategorizeBankTransaction({
|
|
7506
|
+
mutateBankTransactions
|
|
7507
|
+
}) {
|
|
7508
|
+
const { data: auth } = useAuth();
|
|
7509
|
+
const { businessId } = useLayerContext();
|
|
7510
|
+
const { mutate } = useSWRConfig();
|
|
7511
|
+
const mutationResponse = useSWRMutation(
|
|
7512
|
+
() => buildKey4({
|
|
7513
|
+
access_token: auth == null ? void 0 : auth.access_token,
|
|
7514
|
+
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
7515
|
+
businessId
|
|
7516
|
+
}),
|
|
7517
|
+
({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
|
|
7518
|
+
var { arg: _b } = _a, _c = _b, { bankTransactionId } = _c, body = __objRest(_c, ["bankTransactionId"]);
|
|
7519
|
+
return categorizeBankTransaction(
|
|
7520
|
+
apiUrl,
|
|
7521
|
+
accessToken,
|
|
7522
|
+
{
|
|
7523
|
+
params: {
|
|
7524
|
+
businessId: businessId2,
|
|
7525
|
+
bankTransactionId
|
|
7526
|
+
},
|
|
7527
|
+
body
|
|
7528
|
+
}
|
|
7529
|
+
).then(({ data }) => data);
|
|
7530
|
+
},
|
|
7531
|
+
{
|
|
7532
|
+
revalidate: false
|
|
7533
|
+
}
|
|
7534
|
+
);
|
|
7535
|
+
const { trigger: originalTrigger } = mutationResponse;
|
|
7536
|
+
const stableProxiedTrigger = useCallback(
|
|
7537
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
7538
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
7539
|
+
void mutate((key) => withSWRKeyTags(
|
|
7540
|
+
key,
|
|
7541
|
+
(tags) => tags.includes(BANK_ACCOUNTS_TAG_KEY) || tags.includes(EXTERNAL_ACCOUNTS_TAG_KEY)
|
|
7542
|
+
));
|
|
7543
|
+
void mutateBankTransactions(void 0, { revalidate: true });
|
|
7544
|
+
return triggerResult;
|
|
7545
|
+
}),
|
|
7546
|
+
[
|
|
7547
|
+
originalTrigger,
|
|
7548
|
+
mutate,
|
|
7549
|
+
mutateBankTransactions
|
|
7550
|
+
]
|
|
7551
|
+
);
|
|
7552
|
+
return new Proxy(mutationResponse, {
|
|
7553
|
+
get(target, prop) {
|
|
7554
|
+
if (prop === "trigger") {
|
|
7555
|
+
return stableProxiedTrigger;
|
|
7556
|
+
}
|
|
7557
|
+
return Reflect.get(target, prop);
|
|
7558
|
+
}
|
|
7559
|
+
});
|
|
7560
|
+
}
|
|
7561
|
+
|
|
7562
|
+
// src/hooks/useBankTransactions/useMatchBankTransaction.ts
|
|
7563
|
+
import { useCallback as useCallback2 } from "react";
|
|
7564
|
+
import { useSWRConfig as useSWRConfig2 } from "swr";
|
|
7565
|
+
import useSWRMutation2 from "swr/mutation";
|
|
7566
|
+
var MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
|
|
7567
|
+
function buildKey5({
|
|
7568
|
+
access_token: accessToken,
|
|
7569
|
+
apiUrl,
|
|
7570
|
+
businessId
|
|
7571
|
+
}) {
|
|
7572
|
+
if (accessToken && apiUrl) {
|
|
7573
|
+
return {
|
|
7574
|
+
accessToken,
|
|
7575
|
+
apiUrl,
|
|
7576
|
+
businessId,
|
|
7577
|
+
tags: [MATCH_BANK_TRANSACTION_TAG]
|
|
7578
|
+
};
|
|
7579
|
+
}
|
|
7580
|
+
}
|
|
7581
|
+
function useMatchBankTransaction({
|
|
7582
|
+
mutateBankTransactions
|
|
7583
|
+
}) {
|
|
7584
|
+
const { data: auth } = useAuth();
|
|
7585
|
+
const { businessId } = useLayerContext();
|
|
7586
|
+
const { mutate } = useSWRConfig2();
|
|
7587
|
+
const mutationResponse = useSWRMutation2(
|
|
7588
|
+
() => buildKey5({
|
|
7589
|
+
access_token: auth == null ? void 0 : auth.access_token,
|
|
7590
|
+
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
7591
|
+
businessId
|
|
7592
|
+
}),
|
|
7593
|
+
({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
|
|
7594
|
+
var { arg: _b } = _a, _c = _b, { bankTransactionId } = _c, body = __objRest(_c, ["bankTransactionId"]);
|
|
7595
|
+
return matchBankTransaction(
|
|
7596
|
+
apiUrl,
|
|
7597
|
+
accessToken,
|
|
7598
|
+
{
|
|
7599
|
+
params: {
|
|
7600
|
+
businessId: businessId2,
|
|
7601
|
+
bankTransactionId
|
|
7602
|
+
},
|
|
7603
|
+
body
|
|
7604
|
+
}
|
|
7605
|
+
).then(({ data }) => data);
|
|
7606
|
+
},
|
|
7607
|
+
{
|
|
7608
|
+
revalidate: false
|
|
7609
|
+
}
|
|
7610
|
+
);
|
|
7611
|
+
const { trigger: originalTrigger } = mutationResponse;
|
|
7612
|
+
const stableProxiedTrigger = useCallback2(
|
|
7613
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
7614
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
7615
|
+
void mutate((key) => withSWRKeyTags(
|
|
7616
|
+
key,
|
|
7617
|
+
(tags) => tags.includes(BANK_ACCOUNTS_TAG_KEY) || tags.includes(EXTERNAL_ACCOUNTS_TAG_KEY)
|
|
7618
|
+
));
|
|
7619
|
+
void mutateBankTransactions(void 0, { revalidate: true });
|
|
7620
|
+
return triggerResult;
|
|
7621
|
+
}),
|
|
7622
|
+
[
|
|
7623
|
+
originalTrigger,
|
|
7624
|
+
mutate,
|
|
7625
|
+
mutateBankTransactions
|
|
7626
|
+
]
|
|
7627
|
+
);
|
|
7628
|
+
return new Proxy(mutationResponse, {
|
|
7629
|
+
get(target, prop) {
|
|
7630
|
+
if (prop === "trigger") {
|
|
7631
|
+
return stableProxiedTrigger;
|
|
7632
|
+
}
|
|
7633
|
+
return Reflect.get(target, prop);
|
|
7634
|
+
}
|
|
7635
|
+
});
|
|
7636
|
+
}
|
|
7637
|
+
|
|
7407
7638
|
// src/hooks/useBankTransactions/useAugmentedBankTransactions.tsx
|
|
7408
7639
|
var INITIAL_POLL_INTERVAL_MS = 1e3;
|
|
7409
7640
|
var POLL_INTERVAL_AFTER_TXNS_RECEIVED_MS = 5e3;
|
|
@@ -7461,7 +7692,6 @@ function bankTransactionFiltersToHookOptions(filters) {
|
|
|
7461
7692
|
}
|
|
7462
7693
|
var useAugmentedBankTransactions = (params) => {
|
|
7463
7694
|
const {
|
|
7464
|
-
businessId,
|
|
7465
7695
|
addToast,
|
|
7466
7696
|
touch,
|
|
7467
7697
|
read,
|
|
@@ -7469,8 +7699,6 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7469
7699
|
hasBeenTouched,
|
|
7470
7700
|
eventCallbacks
|
|
7471
7701
|
} = useLayerContext();
|
|
7472
|
-
const { apiUrl } = useEnvironment();
|
|
7473
|
-
const { data: auth } = useAuth();
|
|
7474
7702
|
const [filters, setTheFilters] = useState6(
|
|
7475
7703
|
buildInitialFilters(params != null ? params : {})
|
|
7476
7704
|
);
|
|
@@ -7542,122 +7770,107 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7542
7770
|
}
|
|
7543
7771
|
return filtered;
|
|
7544
7772
|
}, [filters, data]);
|
|
7545
|
-
const
|
|
7546
|
-
const
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7773
|
+
const updateOneLocal = (newBankTransaction) => {
|
|
7774
|
+
const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
|
|
7775
|
+
var _a;
|
|
7776
|
+
return __spreadProps(__spreadValues({}, page), {
|
|
7777
|
+
data: (_a = page.data) == null ? void 0 : _a.map(
|
|
7778
|
+
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
7779
|
+
)
|
|
7780
|
+
});
|
|
7781
|
+
});
|
|
7782
|
+
void mutate(updatedData, { revalidate: false });
|
|
7783
|
+
};
|
|
7784
|
+
const { trigger: categorizeBankTransaction2 } = useCategorizeBankTransaction({
|
|
7785
|
+
mutateBankTransactions: mutate
|
|
7786
|
+
});
|
|
7787
|
+
const categorizeWithOptimisticUpdate = (bankTransactionId, newCategory, notify) => __async(null, null, function* () {
|
|
7788
|
+
const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7789
|
+
if (existingTransaction) {
|
|
7790
|
+
updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), { processing: true, error: void 0 }));
|
|
7791
|
+
}
|
|
7792
|
+
return categorizeBankTransaction2(__spreadValues({
|
|
7793
|
+
bankTransactionId
|
|
7794
|
+
}, newCategory)).then((updatedTransaction) => {
|
|
7795
|
+
updateOneLocal(__spreadProps(__spreadValues({}, updatedTransaction), {
|
|
7796
|
+
processing: false,
|
|
7797
|
+
recently_categorized: true
|
|
7798
|
+
}));
|
|
7799
|
+
if (notify) {
|
|
7565
7800
|
addToast({ content: "Transaction confirmed" });
|
|
7566
7801
|
}
|
|
7567
|
-
}).catch((
|
|
7568
|
-
const
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
updateOneLocal(__spreadProps(__spreadValues({}, newBT), {
|
|
7573
|
-
error: err.message,
|
|
7802
|
+
}).catch((error) => {
|
|
7803
|
+
const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7804
|
+
if (targetedTransaction) {
|
|
7805
|
+
updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
|
|
7806
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
7574
7807
|
processing: false
|
|
7575
7808
|
}));
|
|
7576
7809
|
}
|
|
7577
7810
|
}).finally(() => {
|
|
7578
7811
|
var _a;
|
|
7579
|
-
|
|
7580
|
-
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, id);
|
|
7812
|
+
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, bankTransactionId);
|
|
7581
7813
|
});
|
|
7582
|
-
};
|
|
7583
|
-
const
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7814
|
+
});
|
|
7815
|
+
const { trigger: matchBankTransaction2 } = useMatchBankTransaction({
|
|
7816
|
+
mutateBankTransactions: mutate
|
|
7817
|
+
});
|
|
7818
|
+
const matchWithOptimisticUpdate = (bankTransactionId, suggestedMatchId, notify) => __async(null, null, function* () {
|
|
7819
|
+
const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7820
|
+
if (existingTransaction) {
|
|
7821
|
+
updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), {
|
|
7822
|
+
processing: true,
|
|
7823
|
+
error: void 0
|
|
7824
|
+
}));
|
|
7589
7825
|
}
|
|
7590
|
-
const
|
|
7591
|
-
(
|
|
7592
|
-
var _a;
|
|
7593
|
-
return x.id !== id && ((_a = x == null ? void 0 : x.suggested_matches) == null ? void 0 : _a.some((sm) => sm.id == matchId));
|
|
7594
|
-
}
|
|
7826
|
+
const transferBankTransaction = data == null ? void 0 : data.find(
|
|
7827
|
+
({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
|
|
7595
7828
|
);
|
|
7596
|
-
if (
|
|
7597
|
-
updateOneLocal(__spreadProps(__spreadValues({},
|
|
7829
|
+
if (transferBankTransaction) {
|
|
7830
|
+
updateOneLocal(__spreadProps(__spreadValues({}, transferBankTransaction), {
|
|
7598
7831
|
processing: true,
|
|
7599
7832
|
error: void 0
|
|
7600
7833
|
}));
|
|
7601
7834
|
}
|
|
7602
|
-
return
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
)
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
const newTransferBT = data == null ? void 0 : data.find(
|
|
7616
|
-
(x) => {
|
|
7617
|
-
var _a;
|
|
7618
|
-
return x.id !== id && ((_a = x == null ? void 0 : x.suggested_matches) == null ? void 0 : _a.some((sm) => sm.id == matchId));
|
|
7619
|
-
}
|
|
7620
|
-
);
|
|
7621
|
-
if (newTransferBT) {
|
|
7622
|
-
newTransferBT.recently_categorized = true;
|
|
7623
|
-
newTransferBT.match = bt;
|
|
7624
|
-
newTransferBT.categorization_status = "MATCHED" /* MATCHED */;
|
|
7625
|
-
updateOneLocal(newTransferBT);
|
|
7835
|
+
return matchBankTransaction2({
|
|
7836
|
+
bankTransactionId,
|
|
7837
|
+
match_id: suggestedMatchId,
|
|
7838
|
+
type: "Confirm_Match" /* CONFIRM_MATCH */
|
|
7839
|
+
}).then((match) => {
|
|
7840
|
+
const matchedTransaction = data == null ? void 0 : data.find(({ id }) => id === match.bank_transaction.id);
|
|
7841
|
+
if (matchedTransaction) {
|
|
7842
|
+
updateOneLocal(__spreadProps(__spreadValues({}, matchedTransaction), {
|
|
7843
|
+
categorization_status: "MATCHED" /* MATCHED */,
|
|
7844
|
+
match,
|
|
7845
|
+
processing: false,
|
|
7846
|
+
recently_categorized: true
|
|
7847
|
+
}));
|
|
7626
7848
|
}
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7849
|
+
const matchedTransferTransaction = data == null ? void 0 : data.find(
|
|
7850
|
+
({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
|
|
7851
|
+
);
|
|
7852
|
+
if (matchedTransferTransaction) {
|
|
7853
|
+
updateOneLocal(__spreadProps(__spreadValues({}, matchedTransferTransaction), {
|
|
7854
|
+
processing: false,
|
|
7855
|
+
recently_categorized: true
|
|
7856
|
+
}));
|
|
7630
7857
|
}
|
|
7631
|
-
if (
|
|
7858
|
+
if (notify) {
|
|
7632
7859
|
addToast({ content: "Transaction saved" });
|
|
7633
7860
|
}
|
|
7634
|
-
}).catch((
|
|
7635
|
-
const
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
updateOneLocal(__spreadProps(__spreadValues({}, newBT), {
|
|
7640
|
-
error: err.message,
|
|
7861
|
+
}).catch((error) => {
|
|
7862
|
+
const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7863
|
+
if (targetedTransaction) {
|
|
7864
|
+
updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
|
|
7865
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
7641
7866
|
processing: false
|
|
7642
7867
|
}));
|
|
7643
7868
|
}
|
|
7644
7869
|
}).finally(() => {
|
|
7645
7870
|
var _a;
|
|
7646
|
-
|
|
7647
|
-
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, id);
|
|
7648
|
-
});
|
|
7649
|
-
};
|
|
7650
|
-
const updateOneLocal = (newBankTransaction) => {
|
|
7651
|
-
const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
|
|
7652
|
-
var _a;
|
|
7653
|
-
return __spreadProps(__spreadValues({}, page), {
|
|
7654
|
-
data: (_a = page.data) == null ? void 0 : _a.map(
|
|
7655
|
-
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
7656
|
-
)
|
|
7657
|
-
});
|
|
7871
|
+
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, bankTransactionId);
|
|
7658
7872
|
});
|
|
7659
|
-
|
|
7660
|
-
};
|
|
7873
|
+
});
|
|
7661
7874
|
const shouldHideAfterCategorize = () => {
|
|
7662
7875
|
return (filters == null ? void 0 : filters.categorizationStatus) === "review" /* review */;
|
|
7663
7876
|
};
|
|
@@ -7743,8 +7956,8 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7743
7956
|
isValidating,
|
|
7744
7957
|
refetch,
|
|
7745
7958
|
error: responseError,
|
|
7746
|
-
categorize,
|
|
7747
|
-
match,
|
|
7959
|
+
categorize: categorizeWithOptimisticUpdate,
|
|
7960
|
+
match: matchWithOptimisticUpdate,
|
|
7748
7961
|
updateOneLocal,
|
|
7749
7962
|
shouldHideAfterCategorize,
|
|
7750
7963
|
removeAfterCategorize,
|
|
@@ -7767,7 +7980,7 @@ var BankTransactionsProvider = ({
|
|
|
7767
7980
|
};
|
|
7768
7981
|
|
|
7769
7982
|
// src/providers/BusinessProvider/BusinessProvider.tsx
|
|
7770
|
-
import
|
|
7983
|
+
import useSWR4 from "swr";
|
|
7771
7984
|
|
|
7772
7985
|
// src/utils/swr/defaultSWRConfig.ts
|
|
7773
7986
|
var DEFAULT_SWR_CONFIG = {
|
|
@@ -7835,7 +8048,7 @@ var BusinessProvider = ({
|
|
|
7835
8048
|
} = useDataSync();
|
|
7836
8049
|
const { apiUrl } = useEnvironment();
|
|
7837
8050
|
const { data: auth } = useAuth();
|
|
7838
|
-
const { data: businessData } =
|
|
8051
|
+
const { data: businessData } = useSWR4(
|
|
7839
8052
|
businessId && (auth == null ? void 0 : auth.access_token) && `business-${businessId}`,
|
|
7840
8053
|
Layer.getBusiness(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7841
8054
|
params: { businessId }
|
|
@@ -11026,13 +11239,13 @@ var LinkedAccountItemThumb = ({
|
|
|
11026
11239
|
config: [
|
|
11027
11240
|
{
|
|
11028
11241
|
name: "Mark as a duplicate account",
|
|
11029
|
-
action: () => __async(
|
|
11242
|
+
action: () => __async(null, null, function* () {
|
|
11030
11243
|
yield excludeAccount2(account.external_account_source, account.id);
|
|
11031
11244
|
})
|
|
11032
11245
|
},
|
|
11033
11246
|
{
|
|
11034
11247
|
name: "Mark as not a duplicate account",
|
|
11035
|
-
action: () => __async(
|
|
11248
|
+
action: () => __async(null, null, function* () {
|
|
11036
11249
|
yield confirmAccount2(account.external_account_source, account.id);
|
|
11037
11250
|
})
|
|
11038
11251
|
}
|
|
@@ -11044,7 +11257,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11044
11257
|
config: [
|
|
11045
11258
|
{
|
|
11046
11259
|
name: "Repair connection",
|
|
11047
|
-
action: () => __async(
|
|
11260
|
+
action: () => __async(null, null, function* () {
|
|
11048
11261
|
if (account.connection_external_id) {
|
|
11049
11262
|
yield repairConnection(
|
|
11050
11263
|
account.external_account_source,
|
|
@@ -11059,7 +11272,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11059
11272
|
const additionalConfigs = [
|
|
11060
11273
|
{
|
|
11061
11274
|
name: "Unlink account",
|
|
11062
|
-
action: () => __async(
|
|
11275
|
+
action: () => __async(null, null, function* () {
|
|
11063
11276
|
if (confirm("Please confirm you wish to remove this financial account")) {
|
|
11064
11277
|
yield unlinkAccount2(account.external_account_source, account.id);
|
|
11065
11278
|
}
|
|
@@ -11069,7 +11282,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11069
11282
|
if (showUnlinkItem) {
|
|
11070
11283
|
additionalConfigs.push({
|
|
11071
11284
|
name: `Unlink all accounts under this ${(_a = account.institution) == null ? void 0 : _a.name} connection`,
|
|
11072
|
-
action: () => __async(
|
|
11285
|
+
action: () => __async(null, null, function* () {
|
|
11073
11286
|
var _a2;
|
|
11074
11287
|
if (account.connection_external_id && confirm(
|
|
11075
11288
|
`Please confirm you wish to remove all accounts belonging to ${((_a2 = account.institution) == null ? void 0 : _a2.name) || "this institution"}`
|
|
@@ -11093,7 +11306,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11093
11306
|
if (environment === "staging" && !account.connection_needs_repair_as_of && account.external_account_source === "PLAID" && showBreakConnection) {
|
|
11094
11307
|
additionalConfigs.push({
|
|
11095
11308
|
name: "Break connection (test utility)",
|
|
11096
|
-
action: () => __async(
|
|
11309
|
+
action: () => __async(null, null, function* () {
|
|
11097
11310
|
if (account.connection_external_id) {
|
|
11098
11311
|
yield breakConnection(
|
|
11099
11312
|
account.external_account_source,
|
|
@@ -11446,8 +11659,8 @@ function LinkedAccountToConfirm({
|
|
|
11446
11659
|
}
|
|
11447
11660
|
|
|
11448
11661
|
// src/components/LinkedAccounts/ConfirmationModal/useConfirmAndExcludeMultiple.ts
|
|
11449
|
-
import
|
|
11450
|
-
function
|
|
11662
|
+
import useSWRMutation3 from "swr/mutation";
|
|
11663
|
+
function buildKey6({
|
|
11451
11664
|
access_token: accessToken,
|
|
11452
11665
|
apiUrl,
|
|
11453
11666
|
businessId
|
|
@@ -11504,8 +11717,8 @@ function confirm2({
|
|
|
11504
11717
|
function useConfirmAndExcludeMultiple({ onSuccess }) {
|
|
11505
11718
|
const { data: auth } = useAuth();
|
|
11506
11719
|
const { businessId } = useLayerContext();
|
|
11507
|
-
return
|
|
11508
|
-
() =>
|
|
11720
|
+
return useSWRMutation3(
|
|
11721
|
+
() => buildKey6({
|
|
11509
11722
|
access_token: auth == null ? void 0 : auth.access_token,
|
|
11510
11723
|
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
11511
11724
|
businessId
|
|
@@ -11594,7 +11807,7 @@ function LinkedAccountsConfirmationModalContent({ onClose }) {
|
|
|
11594
11807
|
));
|
|
11595
11808
|
const { trigger, isMutating, error } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
|
|
11596
11809
|
const hasError = Boolean(error);
|
|
11597
|
-
const handleFinish = () => __async(
|
|
11810
|
+
const handleFinish = () => __async(null, null, function* () {
|
|
11598
11811
|
const success = yield trigger(formState);
|
|
11599
11812
|
if (success) {
|
|
11600
11813
|
onFinish();
|
|
@@ -11920,7 +12133,7 @@ var FileInput = ({
|
|
|
11920
12133
|
};
|
|
11921
12134
|
|
|
11922
12135
|
// src/components/Input/Select.tsx
|
|
11923
|
-
import { useCallback } from "react";
|
|
12136
|
+
import { useCallback as useCallback3 } from "react";
|
|
11924
12137
|
import ReactSelect, {
|
|
11925
12138
|
components
|
|
11926
12139
|
} from "react-select";
|
|
@@ -11975,7 +12188,7 @@ var Select = ({
|
|
|
11975
12188
|
isInvalid ? "Layer__select--error" : "",
|
|
11976
12189
|
className
|
|
11977
12190
|
);
|
|
11978
|
-
const DropdownIndicator2 =
|
|
12191
|
+
const DropdownIndicator2 = useCallback3((props) => /* @__PURE__ */ jsx83(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx83(ChevronDownFill_default, {}) })), []);
|
|
11979
12192
|
return /* @__PURE__ */ jsxs46(Tooltip, { disabled: !isInvalid || !errorMessage, children: [
|
|
11980
12193
|
/* @__PURE__ */ jsx83(TooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx83(
|
|
11981
12194
|
ReactSelect,
|
|
@@ -12035,7 +12248,7 @@ var InputWithBadge = (_a) => {
|
|
|
12035
12248
|
};
|
|
12036
12249
|
|
|
12037
12250
|
// src/components/Input/MultiSelect.tsx
|
|
12038
|
-
import { useCallback as
|
|
12251
|
+
import { useCallback as useCallback4 } from "react";
|
|
12039
12252
|
import ReactSelect2, {
|
|
12040
12253
|
components as components2
|
|
12041
12254
|
} from "react-select";
|
|
@@ -12060,7 +12273,7 @@ var MultiSelect = ({
|
|
|
12060
12273
|
isInvalid ? "Layer__select--error" : "",
|
|
12061
12274
|
className
|
|
12062
12275
|
);
|
|
12063
|
-
const DropdownIndicator2 =
|
|
12276
|
+
const DropdownIndicator2 = useCallback4((props) => /* @__PURE__ */ jsx85(components2.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx85(ChevronDownFill_default, {}) })), []);
|
|
12064
12277
|
return /* @__PURE__ */ jsxs48(Tooltip, { disabled: !isInvalid || !errorMessage, children: [
|
|
12065
12278
|
/* @__PURE__ */ jsx85(TooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx85(
|
|
12066
12279
|
ReactSelect2,
|
|
@@ -12677,8 +12890,8 @@ var AccountFormBox = ({
|
|
|
12677
12890
|
};
|
|
12678
12891
|
|
|
12679
12892
|
// src/components/LinkedAccounts/OpeningBalanceModal/useUpdateOpeningBalanceAndDate.ts
|
|
12680
|
-
import
|
|
12681
|
-
function
|
|
12893
|
+
import useSWRMutation4 from "swr/mutation";
|
|
12894
|
+
function buildKey7({
|
|
12682
12895
|
access_token: accessToken,
|
|
12683
12896
|
apiUrl,
|
|
12684
12897
|
businessId,
|
|
@@ -12730,8 +12943,8 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
|
|
|
12730
12943
|
}
|
|
12731
12944
|
return errors;
|
|
12732
12945
|
};
|
|
12733
|
-
return
|
|
12734
|
-
() =>
|
|
12946
|
+
return useSWRMutation4(
|
|
12947
|
+
() => buildKey7({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
|
|
12735
12948
|
({ accessToken, apiUrl, businessId: businessId2, data: data2 }) => Promise.allSettled(
|
|
12736
12949
|
data2.map(
|
|
12737
12950
|
({ accountId, openingDate, openingBalance }) => {
|
|
@@ -12876,7 +13089,7 @@ function LinkedAccountsOpeningBalanceModalContent({
|
|
|
12876
13089
|
};
|
|
12877
13090
|
}),
|
|
12878
13091
|
{
|
|
12879
|
-
onSuccess: (responses) => __async(
|
|
13092
|
+
onSuccess: (responses) => __async(null, null, function* () {
|
|
12880
13093
|
const newResults = __spreadValues({}, results);
|
|
12881
13094
|
responses.forEach((r) => {
|
|
12882
13095
|
newResults[r.accountId] = r;
|
|
@@ -13559,9 +13772,9 @@ var getAssignedValue = (bankTransaction) => {
|
|
|
13559
13772
|
};
|
|
13560
13773
|
|
|
13561
13774
|
// src/hooks/categories/useCategories.ts
|
|
13562
|
-
import
|
|
13775
|
+
import useSWR5 from "swr";
|
|
13563
13776
|
var CATEGORIES_TAG_KEY = "#categories";
|
|
13564
|
-
function
|
|
13777
|
+
function buildKey8({
|
|
13565
13778
|
access_token: accessToken,
|
|
13566
13779
|
apiUrl,
|
|
13567
13780
|
businessId,
|
|
@@ -13580,8 +13793,8 @@ function buildKey4({
|
|
|
13580
13793
|
function useCategories({ mode } = {}) {
|
|
13581
13794
|
const { data: auth } = useAuth();
|
|
13582
13795
|
const { businessId } = useLayerContext();
|
|
13583
|
-
return
|
|
13584
|
-
() =>
|
|
13796
|
+
return useSWR5(
|
|
13797
|
+
() => buildKey8(__spreadProps(__spreadValues({}, auth), {
|
|
13585
13798
|
businessId,
|
|
13586
13799
|
mode
|
|
13587
13800
|
})),
|
|
@@ -13948,7 +14161,7 @@ import {
|
|
|
13948
14161
|
forwardRef as forwardRef12,
|
|
13949
14162
|
useImperativeHandle as useImperativeHandle2,
|
|
13950
14163
|
useState as useState23,
|
|
13951
|
-
useCallback as
|
|
14164
|
+
useCallback as useCallback6,
|
|
13952
14165
|
useEffect as useEffect13,
|
|
13953
14166
|
useRef as useRef9
|
|
13954
14167
|
} from "react";
|
|
@@ -14112,7 +14325,7 @@ var useReceipts = ({
|
|
|
14112
14325
|
void fetchDocuments();
|
|
14113
14326
|
}
|
|
14114
14327
|
}, [isActive]);
|
|
14115
|
-
const fetchDocuments = () => __async(
|
|
14328
|
+
const fetchDocuments = () => __async(null, null, function* () {
|
|
14116
14329
|
const listBankTransactionDocuments2 = Layer.listBankTransactionDocuments(
|
|
14117
14330
|
apiUrl,
|
|
14118
14331
|
auth == null ? void 0 : auth.access_token,
|
|
@@ -14134,7 +14347,7 @@ var useReceipts = ({
|
|
|
14134
14347
|
}));
|
|
14135
14348
|
setReceiptUrls(retrievedDocs);
|
|
14136
14349
|
});
|
|
14137
|
-
const uploadReceipt = (file) => __async(
|
|
14350
|
+
const uploadReceipt = (file) => __async(null, null, function* () {
|
|
14138
14351
|
var _a;
|
|
14139
14352
|
const id = (/* @__PURE__ */ new Date()).valueOf().toString();
|
|
14140
14353
|
const receipts = [
|
|
@@ -14179,7 +14392,7 @@ var useReceipts = ({
|
|
|
14179
14392
|
setReceiptUrls(newReceiptUrls);
|
|
14180
14393
|
}
|
|
14181
14394
|
});
|
|
14182
|
-
const archiveDocument = (document2) => __async(
|
|
14395
|
+
const archiveDocument = (document2) => __async(null, null, function* () {
|
|
14183
14396
|
if (!document2.id) return;
|
|
14184
14397
|
try {
|
|
14185
14398
|
if (document2.error) {
|
|
@@ -14454,7 +14667,7 @@ var BankTransactionReceipts = forwardRef11(
|
|
|
14454
14667
|
BankTransactionReceipts.displayName = "BankTransactionReceipts";
|
|
14455
14668
|
|
|
14456
14669
|
// src/hooks/bookkeeping/useBookkeepingStatus.ts
|
|
14457
|
-
import
|
|
14670
|
+
import useSWR6 from "swr";
|
|
14458
14671
|
|
|
14459
14672
|
// src/providers/LegacyModeProvider/LegacyModeProvider.tsx
|
|
14460
14673
|
import { createContext as createContext11, useContext as useContext18, useMemo as useMemo11 } from "react";
|
|
@@ -14491,7 +14704,7 @@ var getBookkeepingStatus = get(({ businessId }) => {
|
|
|
14491
14704
|
});
|
|
14492
14705
|
var BOOKKEEPING_TAG_KEY = "#bookkeeping";
|
|
14493
14706
|
var BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
|
|
14494
|
-
function
|
|
14707
|
+
function buildKey9({
|
|
14495
14708
|
access_token: accessToken,
|
|
14496
14709
|
apiUrl,
|
|
14497
14710
|
businessId
|
|
@@ -14508,8 +14721,8 @@ function buildKey5({
|
|
|
14508
14721
|
function useBookkeepingStatus() {
|
|
14509
14722
|
const { data: auth } = useAuth();
|
|
14510
14723
|
const { businessId } = useLayerContext();
|
|
14511
|
-
return
|
|
14512
|
-
() =>
|
|
14724
|
+
return useSWR6(
|
|
14725
|
+
() => buildKey9(__spreadProps(__spreadValues({}, auth), {
|
|
14513
14726
|
businessId
|
|
14514
14727
|
})),
|
|
14515
14728
|
({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingStatus(
|
|
@@ -15080,9 +15293,9 @@ var Textarea = (_a) => {
|
|
|
15080
15293
|
import { useForm } from "@tanstack/react-form";
|
|
15081
15294
|
|
|
15082
15295
|
// src/hooks/useBankTransactions/useBankTransactionsMetadata.ts
|
|
15083
|
-
import
|
|
15296
|
+
import useSWR7 from "swr";
|
|
15084
15297
|
var GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
|
|
15085
|
-
function
|
|
15298
|
+
function buildKey10({
|
|
15086
15299
|
access_token: accessToken,
|
|
15087
15300
|
apiUrl,
|
|
15088
15301
|
businessId,
|
|
@@ -15101,8 +15314,8 @@ function buildKey6({
|
|
|
15101
15314
|
function useBankTransactionMetadata({ bankTransactionId }) {
|
|
15102
15315
|
const { data: auth } = useAuth();
|
|
15103
15316
|
const { businessId } = useLayerContext();
|
|
15104
|
-
return
|
|
15105
|
-
() =>
|
|
15317
|
+
return useSWR7(
|
|
15318
|
+
() => buildKey10(__spreadProps(__spreadValues({}, auth), {
|
|
15106
15319
|
businessId,
|
|
15107
15320
|
bankTransactionId
|
|
15108
15321
|
})),
|
|
@@ -15115,21 +15328,11 @@ function useBankTransactionMetadata({ bankTransactionId }) {
|
|
|
15115
15328
|
}
|
|
15116
15329
|
|
|
15117
15330
|
// src/hooks/useBankTransactions/useUpdateBankTransactionMetadata.ts
|
|
15118
|
-
import
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
function withSWRKeyTags(key, predicate) {
|
|
15122
|
-
if (typeof key !== "object" || key === null || !("tags" in key)) {
|
|
15123
|
-
return false;
|
|
15124
|
-
}
|
|
15125
|
-
return isStringArray(key.tags) ? predicate(key.tags) : false;
|
|
15126
|
-
}
|
|
15127
|
-
|
|
15128
|
-
// src/hooks/useBankTransactions/useUpdateBankTransactionMetadata.ts
|
|
15129
|
-
import { useSWRConfig } from "swr";
|
|
15130
|
-
import { useCallback as useCallback3 } from "react";
|
|
15331
|
+
import useSWRMutation5 from "swr/mutation";
|
|
15332
|
+
import { useSWRConfig as useSWRConfig3 } from "swr";
|
|
15333
|
+
import { useCallback as useCallback5 } from "react";
|
|
15131
15334
|
var UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
|
|
15132
|
-
function
|
|
15335
|
+
function buildKey11({
|
|
15133
15336
|
access_token: accessToken,
|
|
15134
15337
|
apiUrl,
|
|
15135
15338
|
businessId,
|
|
@@ -15148,9 +15351,9 @@ function buildKey7({
|
|
|
15148
15351
|
function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
|
|
15149
15352
|
const { data: auth } = useAuth();
|
|
15150
15353
|
const { businessId } = useLayerContext();
|
|
15151
|
-
const { mutate } =
|
|
15152
|
-
const mutationResponse =
|
|
15153
|
-
() =>
|
|
15354
|
+
const { mutate } = useSWRConfig3();
|
|
15355
|
+
const mutationResponse = useSWRMutation5(
|
|
15356
|
+
() => buildKey11({
|
|
15154
15357
|
access_token: auth == null ? void 0 : auth.access_token,
|
|
15155
15358
|
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
15156
15359
|
businessId,
|
|
@@ -15176,18 +15379,19 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
|
|
|
15176
15379
|
}
|
|
15177
15380
|
);
|
|
15178
15381
|
const { trigger: originalTrigger } = mutationResponse;
|
|
15179
|
-
const stableProxiedTrigger =
|
|
15180
|
-
(...triggerParameters) => __async(
|
|
15181
|
-
const
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
}
|
|
15188
|
-
return result;
|
|
15382
|
+
const stableProxiedTrigger = useCallback5(
|
|
15383
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
15384
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
15385
|
+
void mutate((key) => withSWRKeyTags(
|
|
15386
|
+
key,
|
|
15387
|
+
(tags) => tags.includes(GET_BANK_TRANSACTION_METADATA_TAG_KEY)
|
|
15388
|
+
));
|
|
15389
|
+
return triggerResult;
|
|
15189
15390
|
}),
|
|
15190
|
-
[
|
|
15391
|
+
[
|
|
15392
|
+
originalTrigger,
|
|
15393
|
+
mutate
|
|
15394
|
+
]
|
|
15191
15395
|
);
|
|
15192
15396
|
return new Proxy(mutationResponse, {
|
|
15193
15397
|
get(target, prop) {
|
|
@@ -15207,7 +15411,7 @@ var useBankTransactionMemo = ({ bankTransactionId }) => {
|
|
|
15207
15411
|
defaultValues: {
|
|
15208
15412
|
memo: bankTransactionMetadata == null ? void 0 : bankTransactionMetadata.memo
|
|
15209
15413
|
},
|
|
15210
|
-
onSubmit: (_0) => __async(
|
|
15414
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
15211
15415
|
var _a;
|
|
15212
15416
|
if (value.memo !== void 0 && form.state.isDirty) {
|
|
15213
15417
|
yield updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" });
|
|
@@ -15394,7 +15598,7 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15394
15598
|
updateRowState(__spreadValues({}, rowState));
|
|
15395
15599
|
setSplitFormError(void 0);
|
|
15396
15600
|
};
|
|
15397
|
-
const save = () => __async(
|
|
15601
|
+
const save = () => __async(null, null, function* () {
|
|
15398
15602
|
if (purpose === "match" /* match */) {
|
|
15399
15603
|
if (!selectedMatchId) {
|
|
15400
15604
|
setMatchFormError("Select an option to match the transaction");
|
|
@@ -15434,7 +15638,7 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15434
15638
|
useImperativeHandle2(ref, () => ({
|
|
15435
15639
|
save
|
|
15436
15640
|
}));
|
|
15437
|
-
const onMatchSubmit = (matchId) => __async(
|
|
15641
|
+
const onMatchSubmit = (matchId) => __async(null, null, function* () {
|
|
15438
15642
|
var _a2;
|
|
15439
15643
|
const foundMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
|
|
15440
15644
|
(x) => x.id === matchId
|
|
@@ -15445,11 +15649,11 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15445
15649
|
yield matchBankTransaction2(bankTransaction.id, foundMatch.id);
|
|
15446
15650
|
close2();
|
|
15447
15651
|
});
|
|
15448
|
-
const getDivHeight =
|
|
15652
|
+
const getDivHeight = useCallback6(() => {
|
|
15449
15653
|
const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
|
|
15450
15654
|
return height2 || 0;
|
|
15451
15655
|
}, []);
|
|
15452
|
-
const handleTransitionEnd =
|
|
15656
|
+
const handleTransitionEnd = useCallback6(
|
|
15453
15657
|
(e) => {
|
|
15454
15658
|
if (e.propertyName === "height") {
|
|
15455
15659
|
setHeight(isOpen ? "auto" : 0);
|
|
@@ -15947,7 +16151,7 @@ var BankTransactionRow = ({
|
|
|
15947
16151
|
}, 300);
|
|
15948
16152
|
}
|
|
15949
16153
|
}, [bankTransaction.recently_categorized]);
|
|
15950
|
-
const save = () => __async(
|
|
16154
|
+
const save = () => __async(null, null, function* () {
|
|
15951
16155
|
var _a2;
|
|
15952
16156
|
if (open2 && (expandedRowRef == null ? void 0 : expandedRowRef.current)) {
|
|
15953
16157
|
(_a2 = expandedRowRef == null ? void 0 : expandedRowRef.current) == null ? void 0 : _a2.save();
|
|
@@ -16762,7 +16966,7 @@ var MatchForm2 = ({
|
|
|
16762
16966
|
setShowRetry(false);
|
|
16763
16967
|
}
|
|
16764
16968
|
}, [bankTransaction.error]);
|
|
16765
|
-
const onMatchSubmit = (matchId) => __async(
|
|
16969
|
+
const onMatchSubmit = (matchId) => __async(null, null, function* () {
|
|
16766
16970
|
var _a2;
|
|
16767
16971
|
const foundMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
|
|
16768
16972
|
(x) => x.id === matchId
|
|
@@ -16772,7 +16976,7 @@ var MatchForm2 = ({
|
|
|
16772
16976
|
}
|
|
16773
16977
|
yield matchBankTransaction2(bankTransaction.id, foundMatch.id, true);
|
|
16774
16978
|
});
|
|
16775
|
-
const save = () => __async(
|
|
16979
|
+
const save = () => __async(null, null, function* () {
|
|
16776
16980
|
if (!showCategorization) {
|
|
16777
16981
|
return;
|
|
16778
16982
|
}
|
|
@@ -16962,7 +17166,7 @@ var SplitForm = ({
|
|
|
16962
17166
|
});
|
|
16963
17167
|
return valid;
|
|
16964
17168
|
};
|
|
16965
|
-
const save = () => __async(
|
|
17169
|
+
const save = () => __async(null, null, function* () {
|
|
16966
17170
|
if (!validateSplit2(rowState)) {
|
|
16967
17171
|
if (rowState.splits.length > 1) {
|
|
16968
17172
|
setFormError(
|
|
@@ -17877,7 +18081,7 @@ var PaginationContent = ({
|
|
|
17877
18081
|
};
|
|
17878
18082
|
|
|
17879
18083
|
// src/components/BankTransactions/BankTransactionsHeader.tsx
|
|
17880
|
-
import { useCallback as
|
|
18084
|
+
import { useCallback as useCallback8, useState as useState34 } from "react";
|
|
17881
18085
|
import classNames50 from "classnames";
|
|
17882
18086
|
import { endOfMonth as endOfMonth5, startOfMonth as startOfMonth5 } from "date-fns";
|
|
17883
18087
|
|
|
@@ -17953,8 +18157,8 @@ function TransactionsActions({ children }) {
|
|
|
17953
18157
|
}
|
|
17954
18158
|
|
|
17955
18159
|
// src/hooks/useBankTransactions/useBankTransactionsDownload.ts
|
|
17956
|
-
import
|
|
17957
|
-
function
|
|
18160
|
+
import useSWRMutation6 from "swr/mutation";
|
|
18161
|
+
function buildKey12({
|
|
17958
18162
|
access_token: accessToken,
|
|
17959
18163
|
apiUrl,
|
|
17960
18164
|
businessId
|
|
@@ -17971,8 +18175,8 @@ function buildKey8({
|
|
|
17971
18175
|
function useBankTransactionsDownload() {
|
|
17972
18176
|
const { data } = useAuth();
|
|
17973
18177
|
const { businessId } = useLayerContext();
|
|
17974
|
-
return
|
|
17975
|
-
() =>
|
|
18178
|
+
return useSWRMutation6(
|
|
18179
|
+
() => buildKey12(__spreadProps(__spreadValues({}, data), {
|
|
17976
18180
|
businessId
|
|
17977
18181
|
})),
|
|
17978
18182
|
({
|
|
@@ -18013,7 +18217,7 @@ function useBankTransactionsDownload() {
|
|
|
18013
18217
|
}
|
|
18014
18218
|
|
|
18015
18219
|
// src/components/utility/InvisibleDownload.tsx
|
|
18016
|
-
import { forwardRef as forwardRef13, useCallback as
|
|
18220
|
+
import { forwardRef as forwardRef13, useCallback as useCallback7, useImperativeHandle as useImperativeHandle3, useRef as useRef18 } from "react";
|
|
18017
18221
|
|
|
18018
18222
|
// src/utils/delay/runDelayed.ts
|
|
18019
18223
|
var DEFAULT_DELAY_MS = 50;
|
|
@@ -18027,7 +18231,7 @@ function runDelayedSync(block, delayMs = DEFAULT_DELAY_MS) {
|
|
|
18027
18231
|
import { jsx as jsx148 } from "react/jsx-runtime";
|
|
18028
18232
|
function useInvisibleDownload() {
|
|
18029
18233
|
const invisibleDownloadRef = useRef18(null);
|
|
18030
|
-
const triggerInvisibleDownload =
|
|
18234
|
+
const triggerInvisibleDownload = useCallback7((options) => {
|
|
18031
18235
|
var _a;
|
|
18032
18236
|
void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options));
|
|
18033
18237
|
}, []);
|
|
@@ -18037,7 +18241,7 @@ var CLASS_NAME9 = "Layer__InvisibleDownload";
|
|
|
18037
18241
|
var InvisibleDownload = forwardRef13((_props, ref) => {
|
|
18038
18242
|
const internalRef = useRef18(null);
|
|
18039
18243
|
useImperativeHandle3(ref, () => ({
|
|
18040
|
-
trigger: (_0) => __async(
|
|
18244
|
+
trigger: (_0) => __async(null, [_0], function* ({ url }) {
|
|
18041
18245
|
var _a;
|
|
18042
18246
|
(_a = internalRef.current) == null ? void 0 : _a.setAttribute("href", url);
|
|
18043
18247
|
return runDelayedSync(() => {
|
|
@@ -18046,7 +18250,7 @@ var InvisibleDownload = forwardRef13((_props, ref) => {
|
|
|
18046
18250
|
});
|
|
18047
18251
|
})
|
|
18048
18252
|
}));
|
|
18049
|
-
const handleContainClick =
|
|
18253
|
+
const handleContainClick = useCallback7((event) => {
|
|
18050
18254
|
event.stopPropagation();
|
|
18051
18255
|
}, []);
|
|
18052
18256
|
return /* @__PURE__ */ jsx148("a", { download: true, className: CLASS_NAME9, ref: internalRef, onClick: handleContainClick });
|
|
@@ -18065,7 +18269,7 @@ function TransactionsSearch({ slot }) {
|
|
|
18065
18269
|
const debouncedSetDescription = useDebounce((value) => {
|
|
18066
18270
|
setFilters({ descriptionFilter: value });
|
|
18067
18271
|
});
|
|
18068
|
-
const handleSearch =
|
|
18272
|
+
const handleSearch = useCallback8((value) => {
|
|
18069
18273
|
setLocalSearch(value);
|
|
18070
18274
|
void debouncedSetDescription(value);
|
|
18071
18275
|
}, [debouncedSetDescription]);
|
|
@@ -18731,7 +18935,7 @@ var IntegrationsContent = () => {
|
|
|
18731
18935
|
};
|
|
18732
18936
|
|
|
18733
18937
|
// src/hooks/useQuickbooks/useQuickbooks.ts
|
|
18734
|
-
import { useCallback as
|
|
18938
|
+
import { useCallback as useCallback9, useEffect as useEffect24, useRef as useRef20, useState as useState36 } from "react";
|
|
18735
18939
|
var useQuickbooks = () => {
|
|
18736
18940
|
const { businessId } = useLayerContext();
|
|
18737
18941
|
const { apiUrl } = useEnvironment();
|
|
@@ -18740,13 +18944,13 @@ var useQuickbooks = () => {
|
|
|
18740
18944
|
const [quickbooksConnectionStatus, setQuickbooksConnectionStatus] = useState36(void 0);
|
|
18741
18945
|
const syncStatusIntervalRef = useRef20(null);
|
|
18742
18946
|
const wasSyncingFromQuickbooksRef = useRef20(false);
|
|
18743
|
-
const fetchQuickbooksConnectionStatus =
|
|
18947
|
+
const fetchQuickbooksConnectionStatus = useCallback9(() => __async(null, null, function* () {
|
|
18744
18948
|
const newQuickbooksConnectionStatus = (yield Layer.statusOfQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18745
18949
|
params: { businessId }
|
|
18746
18950
|
})()).data;
|
|
18747
18951
|
setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
|
|
18748
18952
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setQuickbooksConnectionStatus]);
|
|
18749
|
-
const fetchIsSyncingFromQuickbooks =
|
|
18953
|
+
const fetchIsSyncingFromQuickbooks = useCallback9(() => __async(null, null, function* () {
|
|
18750
18954
|
const isSyncing = (yield Layer.statusOfSyncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18751
18955
|
params: { businessId }
|
|
18752
18956
|
})()).data.is_syncing;
|
|
@@ -18772,20 +18976,20 @@ var useQuickbooks = () => {
|
|
|
18772
18976
|
void fetchQuickbooksConnectionStatus();
|
|
18773
18977
|
}
|
|
18774
18978
|
}, [auth == null ? void 0 : auth.access_token, fetchQuickbooksConnectionStatus]);
|
|
18775
|
-
const syncFromQuickbooks2 =
|
|
18979
|
+
const syncFromQuickbooks2 = useCallback9(() => {
|
|
18776
18980
|
setIsSyncingFromQuickbooks(true);
|
|
18777
18981
|
wasSyncingFromQuickbooksRef.current = true;
|
|
18778
18982
|
void Layer.syncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18779
18983
|
params: { businessId }
|
|
18780
18984
|
});
|
|
18781
18985
|
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks]);
|
|
18782
|
-
const linkQuickbooks =
|
|
18986
|
+
const linkQuickbooks = useCallback9(() => __async(null, null, function* () {
|
|
18783
18987
|
const res = yield Layer.initQuickbooksOAuth(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18784
18988
|
params: { businessId }
|
|
18785
18989
|
});
|
|
18786
18990
|
return res.data.redirect_url;
|
|
18787
18991
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId]);
|
|
18788
|
-
const unlinkQuickbooks =
|
|
18992
|
+
const unlinkQuickbooks = useCallback9(() => {
|
|
18789
18993
|
void Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18790
18994
|
params: { businessId }
|
|
18791
18995
|
}).then(() => fetchQuickbooksConnectionStatus());
|
|
@@ -18808,7 +19012,7 @@ function QuickbooksContextProvider({ children }) {
|
|
|
18808
19012
|
}
|
|
18809
19013
|
|
|
18810
19014
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
18811
|
-
import { useCallback as
|
|
19015
|
+
import { useCallback as useCallback10, useContext as useContext24 } from "react";
|
|
18812
19016
|
|
|
18813
19017
|
// src/components/ui/DropdownMenu/DropdownMenu.tsx
|
|
18814
19018
|
import { Menu as Menu3, MenuItem as AriaMenuItem, MenuTrigger as MenuTrigger2, Popover as Popover2, Separator as AriaSeparator, Header as Header2, Dialog as Dialog2 } from "react-aria-components";
|
|
@@ -18864,7 +19068,7 @@ var IntegrationsConnectMenu = () => {
|
|
|
18864
19068
|
quickbooksIsConnected,
|
|
18865
19069
|
linkQuickbooks
|
|
18866
19070
|
} = useContext24(QuickbooksContext);
|
|
18867
|
-
const initiateQuickbooksOAuth =
|
|
19071
|
+
const initiateQuickbooksOAuth = useCallback10(() => __async(null, null, function* () {
|
|
18868
19072
|
const authorizationUrl = yield linkQuickbooks();
|
|
18869
19073
|
window.location.href = authorizationUrl;
|
|
18870
19074
|
}), [linkQuickbooks]);
|
|
@@ -18895,7 +19099,7 @@ var IntegrationsConnectMenu = () => {
|
|
|
18895
19099
|
// src/components/Integrations/Integrations.tsx
|
|
18896
19100
|
import { jsx as jsx164, jsxs as jsxs104 } from "react/jsx-runtime";
|
|
18897
19101
|
var COMPONENT_NAME3 = "integrations";
|
|
18898
|
-
var
|
|
19102
|
+
var unstable_Integrations = (props) => {
|
|
18899
19103
|
return /* @__PURE__ */ jsx164(QuickbooksContextProvider, { children: /* @__PURE__ */ jsx164(IntegrationsComponent, __spreadValues({}, props)) });
|
|
18900
19104
|
};
|
|
18901
19105
|
var IntegrationsComponent = ({
|
|
@@ -18949,7 +19153,7 @@ var Quickbooks = () => {
|
|
|
18949
19153
|
quickbooksIsConnected === false && /* @__PURE__ */ jsx165(
|
|
18950
19154
|
"button",
|
|
18951
19155
|
{
|
|
18952
|
-
onClick: () => __async(
|
|
19156
|
+
onClick: () => __async(null, null, function* () {
|
|
18953
19157
|
const authorizationUrl = yield linkQuickbooks();
|
|
18954
19158
|
window.location.href = authorizationUrl;
|
|
18955
19159
|
}),
|
|
@@ -18989,7 +19193,7 @@ var PNLComparisonContext = createContext14({
|
|
|
18989
19193
|
});
|
|
18990
19194
|
|
|
18991
19195
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
18992
|
-
import { useCallback as
|
|
19196
|
+
import { useCallback as useCallback11, useMemo as useMemo22, useState as useState38 } from "react";
|
|
18993
19197
|
|
|
18994
19198
|
// src/utils/profitAndLossUtils.ts
|
|
18995
19199
|
var doesLineItemQualifies = (item) => {
|
|
@@ -19047,7 +19251,7 @@ var applyShare = (items, total) => {
|
|
|
19047
19251
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
19048
19252
|
import { useEffect as useEffect25, useMemo as useMemo21, useState as useState37 } from "react";
|
|
19049
19253
|
import { startOfMonth as startOfMonth7, sub } from "date-fns";
|
|
19050
|
-
import
|
|
19254
|
+
import useSWR8 from "swr";
|
|
19051
19255
|
var buildDates = ({ currentDate }) => {
|
|
19052
19256
|
return {
|
|
19053
19257
|
startYear: startOfMonth7(currentDate).getFullYear() - 1,
|
|
@@ -19088,7 +19292,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19088
19292
|
isValidating,
|
|
19089
19293
|
error,
|
|
19090
19294
|
mutate
|
|
19091
|
-
} =
|
|
19295
|
+
} = useSWR8(
|
|
19092
19296
|
queryKey,
|
|
19093
19297
|
Layer.getProfitAndLossSummaries(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19094
19298
|
params: {
|
|
@@ -19201,7 +19405,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19201
19405
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
19202
19406
|
import { useEffect as useEffect26 } from "react";
|
|
19203
19407
|
import { startOfMonth as startOfMonth8, endOfMonth as endOfMonth7 } from "date-fns";
|
|
19204
|
-
import
|
|
19408
|
+
import useSWR9 from "swr";
|
|
19205
19409
|
var useProfitAndLossQuery = ({
|
|
19206
19410
|
startDate,
|
|
19207
19411
|
endDate,
|
|
@@ -19224,7 +19428,7 @@ var useProfitAndLossQuery = ({
|
|
|
19224
19428
|
isValidating,
|
|
19225
19429
|
error: rawError,
|
|
19226
19430
|
mutate
|
|
19227
|
-
} =
|
|
19431
|
+
} = useSWR9(
|
|
19228
19432
|
queryKey,
|
|
19229
19433
|
Layer.getProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19230
19434
|
businessId,
|
|
@@ -19267,7 +19471,7 @@ var useProfitAndLoss = ({
|
|
|
19267
19471
|
const { start, end } = useGlobalDateRange();
|
|
19268
19472
|
const { setRange } = useGlobalDateRangeActions();
|
|
19269
19473
|
const dateRange = useMemo22(() => ({ startDate: start, endDate: end }), [start, end]);
|
|
19270
|
-
const changeDateRange =
|
|
19474
|
+
const changeDateRange = useCallback11(
|
|
19271
19475
|
({ startDate: start2, endDate: end2 }) => setRange({ start: start2, end: end2 }),
|
|
19272
19476
|
[setRange]
|
|
19273
19477
|
);
|
|
@@ -19551,14 +19755,14 @@ function preparePeriodsBody(dateRange, comparePeriods, rangeDisplayMode) {
|
|
|
19551
19755
|
}
|
|
19552
19756
|
|
|
19553
19757
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19554
|
-
import
|
|
19758
|
+
import useSWR10 from "swr";
|
|
19555
19759
|
var COMPARE_MODES_SUPPORTING_MULTI_PERIOD = ["monthPicker", "yearPicker"];
|
|
19556
19760
|
var isNotOnlyNoneTag = (compareOptions) => {
|
|
19557
19761
|
return Boolean(
|
|
19558
19762
|
compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
|
|
19559
19763
|
);
|
|
19560
19764
|
};
|
|
19561
|
-
function
|
|
19765
|
+
function buildKey13({
|
|
19562
19766
|
access_token: accessToken,
|
|
19563
19767
|
apiUrl,
|
|
19564
19768
|
businessId,
|
|
@@ -19608,16 +19812,16 @@ function useProfitAndLossComparison({
|
|
|
19608
19812
|
const { data: auth } = useAuth();
|
|
19609
19813
|
const periods = preparePeriodsBody(dateRange, effectiveComparePeriods, rangeDisplayMode);
|
|
19610
19814
|
const tagFilters = prepareFiltersBody(selectedCompareOptions);
|
|
19611
|
-
const queryKey =
|
|
19815
|
+
const queryKey = buildKey13(__spreadProps(__spreadValues({}, auth), {
|
|
19612
19816
|
businessId,
|
|
19613
19817
|
periods,
|
|
19614
19818
|
tagFilters,
|
|
19615
19819
|
reportingBasis,
|
|
19616
19820
|
compareModeActive
|
|
19617
19821
|
}));
|
|
19618
|
-
const { data, isLoading, isValidating } =
|
|
19822
|
+
const { data, isLoading, isValidating } = useSWR10(
|
|
19619
19823
|
queryKey,
|
|
19620
|
-
() => __async(
|
|
19824
|
+
() => __async(null, null, function* () {
|
|
19621
19825
|
const response = yield Layer.compareProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19622
19826
|
params: {
|
|
19623
19827
|
businessId
|
|
@@ -21512,7 +21716,7 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21512
21716
|
const { data: auth } = useAuth();
|
|
21513
21717
|
const [requestFailed, setRequestFailed] = useState42(false);
|
|
21514
21718
|
const [isDownloading, setIsDownloading] = useState42(false);
|
|
21515
|
-
const handleClick = () => __async(
|
|
21719
|
+
const handleClick = () => __async(null, null, function* () {
|
|
21516
21720
|
var _a;
|
|
21517
21721
|
setIsDownloading(true);
|
|
21518
21722
|
const getProfitAndLossExcel2 = Layer.getProfitAndLossExcel(
|
|
@@ -21575,7 +21779,7 @@ var SyncingBadge = () => {
|
|
|
21575
21779
|
import { useMemo as useMemo28 } from "react";
|
|
21576
21780
|
|
|
21577
21781
|
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21578
|
-
import
|
|
21782
|
+
import useSWR11 from "swr";
|
|
21579
21783
|
|
|
21580
21784
|
// src/utils/bookkeeping/bookkeepingStatusFilters.ts
|
|
21581
21785
|
function isActiveBookkeepingStatus(status) {
|
|
@@ -21633,7 +21837,7 @@ var getBookkeepingPeriods = get(({ businessId }) => {
|
|
|
21633
21837
|
return `/v1/businesses/${businessId}/bookkeeping/periods`;
|
|
21634
21838
|
});
|
|
21635
21839
|
var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
|
|
21636
|
-
function
|
|
21840
|
+
function buildKey14({
|
|
21637
21841
|
access_token: accessToken,
|
|
21638
21842
|
apiUrl,
|
|
21639
21843
|
businessId,
|
|
@@ -21653,8 +21857,8 @@ function useBookkeepingPeriods() {
|
|
|
21653
21857
|
const { businessId } = useLayerContext();
|
|
21654
21858
|
const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
|
|
21655
21859
|
const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
|
|
21656
|
-
const swrResponse =
|
|
21657
|
-
() =>
|
|
21860
|
+
const swrResponse = useSWR11(
|
|
21861
|
+
() => buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
21658
21862
|
businessId,
|
|
21659
21863
|
isActiveOrPaused
|
|
21660
21864
|
})),
|
|
@@ -23089,9 +23293,9 @@ ProfitAndLoss.Report = ProfitAndLossReport;
|
|
|
23089
23293
|
ProfitAndLoss.DownloadButton = ProfitAndLossDownloadButton;
|
|
23090
23294
|
|
|
23091
23295
|
// src/hooks/balanceSheet/useBalanceSheet.ts
|
|
23092
|
-
import
|
|
23296
|
+
import useSWR12 from "swr";
|
|
23093
23297
|
import { endOfDay as endOfDay3 } from "date-fns";
|
|
23094
|
-
function
|
|
23298
|
+
function buildKey15({
|
|
23095
23299
|
access_token: accessToken,
|
|
23096
23300
|
apiUrl,
|
|
23097
23301
|
businessId,
|
|
@@ -23113,8 +23317,8 @@ function useBalanceSheet({
|
|
|
23113
23317
|
const { data: auth } = useAuth();
|
|
23114
23318
|
const { apiUrl } = useEnvironment();
|
|
23115
23319
|
const { businessId } = useLayerContext();
|
|
23116
|
-
return
|
|
23117
|
-
() =>
|
|
23320
|
+
return useSWR12(
|
|
23321
|
+
() => buildKey15(__spreadProps(__spreadValues({}, auth), {
|
|
23118
23322
|
apiUrl,
|
|
23119
23323
|
businessId,
|
|
23120
23324
|
effectiveDate
|
|
@@ -23306,8 +23510,8 @@ var BALANCE_SHEET_ROWS = [
|
|
|
23306
23510
|
];
|
|
23307
23511
|
|
|
23308
23512
|
// src/components/BalanceSheet/download/useBalanceSheetDownload.ts
|
|
23309
|
-
import
|
|
23310
|
-
function
|
|
23513
|
+
import useSWRMutation7 from "swr/mutation";
|
|
23514
|
+
function buildKey16({
|
|
23311
23515
|
access_token: accessToken,
|
|
23312
23516
|
apiUrl,
|
|
23313
23517
|
businessId,
|
|
@@ -23329,8 +23533,8 @@ function useBalanceSheetDownload({
|
|
|
23329
23533
|
}) {
|
|
23330
23534
|
const { data: auth } = useAuth();
|
|
23331
23535
|
const { businessId } = useLayerContext();
|
|
23332
|
-
return
|
|
23333
|
-
() =>
|
|
23536
|
+
return useSWRMutation7(
|
|
23537
|
+
() => buildKey16(__spreadProps(__spreadValues({}, auth), {
|
|
23334
23538
|
businessId,
|
|
23335
23539
|
effectiveDate
|
|
23336
23540
|
})),
|
|
@@ -23590,8 +23794,8 @@ var STATEMENT_OF_CASH_FLOW_ROWS = [
|
|
|
23590
23794
|
];
|
|
23591
23795
|
|
|
23592
23796
|
// src/components/StatementOfCashFlow/download/useCashflowStatementDownload.ts
|
|
23593
|
-
import
|
|
23594
|
-
function
|
|
23797
|
+
import useSWRMutation8 from "swr/mutation";
|
|
23798
|
+
function buildKey17({
|
|
23595
23799
|
access_token: accessToken,
|
|
23596
23800
|
apiUrl,
|
|
23597
23801
|
businessId,
|
|
@@ -23616,8 +23820,8 @@ function useCashflowStatementDownload({
|
|
|
23616
23820
|
}) {
|
|
23617
23821
|
const { data: auth } = useAuth();
|
|
23618
23822
|
const { businessId } = useLayerContext();
|
|
23619
|
-
return
|
|
23620
|
-
() =>
|
|
23823
|
+
return useSWRMutation8(
|
|
23824
|
+
() => buildKey17(__spreadProps(__spreadValues({}, auth), {
|
|
23621
23825
|
businessId,
|
|
23622
23826
|
startDate,
|
|
23623
23827
|
endDate
|
|
@@ -23724,9 +23928,9 @@ function StatementOfCashFlowDatePicker({
|
|
|
23724
23928
|
}
|
|
23725
23929
|
|
|
23726
23930
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
23727
|
-
import
|
|
23931
|
+
import useSWR13 from "swr";
|
|
23728
23932
|
import { endOfMonth as endOfMonth10, startOfMonth as startOfMonth13 } from "date-fns";
|
|
23729
|
-
function
|
|
23933
|
+
function buildKey18({
|
|
23730
23934
|
access_token: accessToken,
|
|
23731
23935
|
apiUrl,
|
|
23732
23936
|
businessId,
|
|
@@ -23751,8 +23955,8 @@ function useStatementOfCashFlow({
|
|
|
23751
23955
|
const { data: auth } = useAuth();
|
|
23752
23956
|
const { apiUrl } = useEnvironment();
|
|
23753
23957
|
const { businessId } = useLayerContext();
|
|
23754
|
-
return
|
|
23755
|
-
|
|
23958
|
+
return useSWR13(
|
|
23959
|
+
buildKey18(__spreadProps(__spreadValues({}, auth), {
|
|
23756
23960
|
apiUrl,
|
|
23757
23961
|
businessId,
|
|
23758
23962
|
startDate,
|
|
@@ -24085,7 +24289,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
24085
24289
|
|
|
24086
24290
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24087
24291
|
import { endOfMonth as endOfMonth12, formatISO as formatISO3, startOfMonth as startOfMonth15 } from "date-fns";
|
|
24088
|
-
import
|
|
24292
|
+
import useSWR14 from "swr";
|
|
24089
24293
|
var validate = (formData) => {
|
|
24090
24294
|
const errors = [];
|
|
24091
24295
|
const nameError = validateName(formData);
|
|
@@ -24190,7 +24394,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24190
24394
|
initialEndDate != null ? initialEndDate : endOfMonth12(Date.now())
|
|
24191
24395
|
);
|
|
24192
24396
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `chart-of-accounts-${businessId}-${startDate == null ? void 0 : startDate.valueOf()}-${endDate == null ? void 0 : endDate.valueOf()}`;
|
|
24193
|
-
const { data, isLoading, isValidating, error, mutate } =
|
|
24397
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR14(
|
|
24194
24398
|
queryKey,
|
|
24195
24399
|
Layer.getLedgerAccountBalances(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24196
24400
|
params: {
|
|
@@ -24200,7 +24404,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24200
24404
|
}
|
|
24201
24405
|
})
|
|
24202
24406
|
);
|
|
24203
|
-
const create = (newAccount) => __async(
|
|
24407
|
+
const create = (newAccount) => __async(null, null, function* () {
|
|
24204
24408
|
setSendingForm(true);
|
|
24205
24409
|
setApiError(void 0);
|
|
24206
24410
|
try {
|
|
@@ -24217,7 +24421,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24217
24421
|
touch("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */);
|
|
24218
24422
|
}
|
|
24219
24423
|
});
|
|
24220
|
-
const update = (accountData, accountId) => __async(
|
|
24424
|
+
const update = (accountData, accountId) => __async(null, null, function* () {
|
|
24221
24425
|
setSendingForm(true);
|
|
24222
24426
|
setApiError(void 0);
|
|
24223
24427
|
const newAccountData = __spreadValues({}, accountData);
|
|
@@ -24399,13 +24603,13 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24399
24603
|
};
|
|
24400
24604
|
|
|
24401
24605
|
// src/hooks/useChartOfAccounts/useCreateChildAccount.tsx
|
|
24402
|
-
import
|
|
24403
|
-
import { useSWRConfig as
|
|
24404
|
-
import { useCallback as
|
|
24606
|
+
import useSWRMutation9 from "swr/mutation";
|
|
24607
|
+
import { useSWRConfig as useSWRConfig4 } from "swr";
|
|
24608
|
+
import { useCallback as useCallback12 } from "react";
|
|
24405
24609
|
|
|
24406
24610
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
24407
24611
|
import { useEffect as useEffect35, useState as useState48 } from "react";
|
|
24408
|
-
import
|
|
24612
|
+
import useSWR15 from "swr";
|
|
24409
24613
|
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
24410
24614
|
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
24411
24615
|
const { apiUrl } = useEnvironment();
|
|
@@ -24413,7 +24617,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24413
24617
|
const [accountId, setAccountId] = useState48();
|
|
24414
24618
|
const [selectedEntryId, setSelectedEntryId] = useState48();
|
|
24415
24619
|
const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
24416
|
-
const { data, isLoading, isValidating, error, mutate } =
|
|
24620
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR15(
|
|
24417
24621
|
queryKey,
|
|
24418
24622
|
Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24419
24623
|
params: {
|
|
@@ -24429,7 +24633,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24429
24633
|
isLoading: isLoadingEntry,
|
|
24430
24634
|
isValidating: isValdiatingEntry,
|
|
24431
24635
|
error: errorEntry
|
|
24432
|
-
} =
|
|
24636
|
+
} = useSWR15(
|
|
24433
24637
|
businessId && selectedEntryId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
|
|
24434
24638
|
Layer.getLedgerAccountsEntry(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24435
24639
|
params: { businessId, entryId: selectedEntryId }
|
|
@@ -24946,8 +25150,8 @@ var ChartOfAccountsTableContent = ({
|
|
|
24946
25150
|
};
|
|
24947
25151
|
|
|
24948
25152
|
// src/components/ChartOfAccounts/download/useAccountBalancesDownload.ts
|
|
24949
|
-
import
|
|
24950
|
-
function
|
|
25153
|
+
import useSWRMutation10 from "swr/mutation";
|
|
25154
|
+
function buildKey19({
|
|
24951
25155
|
access_token: accessToken,
|
|
24952
25156
|
apiUrl,
|
|
24953
25157
|
businessId,
|
|
@@ -24972,8 +25176,8 @@ function useAccountBalancesDownload({
|
|
|
24972
25176
|
}) {
|
|
24973
25177
|
const { data: auth } = useAuth();
|
|
24974
25178
|
const { businessId } = useLayerContext();
|
|
24975
|
-
return
|
|
24976
|
-
() =>
|
|
25179
|
+
return useSWRMutation10(
|
|
25180
|
+
() => buildKey19(__spreadProps(__spreadValues({}, auth), {
|
|
24977
25181
|
businessId,
|
|
24978
25182
|
startCutoff,
|
|
24979
25183
|
endCutoff
|
|
@@ -25937,7 +26141,7 @@ var JournalContext = createContext19({
|
|
|
25937
26141
|
|
|
25938
26142
|
// src/hooks/useJournal/useJournal.tsx
|
|
25939
26143
|
import { useEffect as useEffect39, useState as useState53 } from "react";
|
|
25940
|
-
import
|
|
26144
|
+
import useSWR16 from "swr";
|
|
25941
26145
|
var useJournal = () => {
|
|
25942
26146
|
const {
|
|
25943
26147
|
businessId,
|
|
@@ -25954,7 +26158,7 @@ var useJournal = () => {
|
|
|
25954
26158
|
const [sendingForm, setSendingForm] = useState53(false);
|
|
25955
26159
|
const [apiError, setApiError] = useState53(void 0);
|
|
25956
26160
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `journal-lines-${businessId}`;
|
|
25957
|
-
const { data, isLoading, isValidating, error, mutate } =
|
|
26161
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR16(
|
|
25958
26162
|
queryKey,
|
|
25959
26163
|
Layer.getJournal(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
25960
26164
|
params: { businessId }
|
|
@@ -25964,7 +26168,7 @@ var useJournal = () => {
|
|
|
25964
26168
|
const closeSelectedEntry = () => {
|
|
25965
26169
|
setSelectedEntryId(void 0);
|
|
25966
26170
|
};
|
|
25967
|
-
const create = (newJournalEntry) => __async(
|
|
26171
|
+
const create = (newJournalEntry) => __async(null, null, function* () {
|
|
25968
26172
|
setSendingForm(true);
|
|
25969
26173
|
setApiError(void 0);
|
|
25970
26174
|
try {
|
|
@@ -26163,7 +26367,7 @@ var useJournal = () => {
|
|
|
26163
26367
|
})
|
|
26164
26368
|
}));
|
|
26165
26369
|
};
|
|
26166
|
-
const reverseEntry = (entryId) => __async(
|
|
26370
|
+
const reverseEntry = (entryId) => __async(null, null, function* () {
|
|
26167
26371
|
return Layer.reverseJournalEntry(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
26168
26372
|
params: { businessId, entryId }
|
|
26169
26373
|
});
|
|
@@ -26241,7 +26445,7 @@ var JournalEntryDetails = () => {
|
|
|
26241
26445
|
},
|
|
26242
26446
|
[entry == null ? void 0 : entry.line_items]
|
|
26243
26447
|
);
|
|
26244
|
-
const onReverseEntry = () => __async(
|
|
26448
|
+
const onReverseEntry = () => __async(null, null, function* () {
|
|
26245
26449
|
if (!entry) {
|
|
26246
26450
|
return;
|
|
26247
26451
|
}
|
|
@@ -26922,8 +27126,8 @@ var JournalTableContent = ({
|
|
|
26922
27126
|
};
|
|
26923
27127
|
|
|
26924
27128
|
// src/components/Journal/download/useJournalEntriesDownload.ts
|
|
26925
|
-
import
|
|
26926
|
-
function
|
|
27129
|
+
import useSWRMutation11 from "swr/mutation";
|
|
27130
|
+
function buildKey20({
|
|
26927
27131
|
access_token: accessToken,
|
|
26928
27132
|
apiUrl,
|
|
26929
27133
|
businessId,
|
|
@@ -26948,8 +27152,8 @@ function useJournalEntriesDownload({
|
|
|
26948
27152
|
}) {
|
|
26949
27153
|
const { data: auth } = useAuth();
|
|
26950
27154
|
const { businessId } = useLayerContext();
|
|
26951
|
-
return
|
|
26952
|
-
() =>
|
|
27155
|
+
return useSWRMutation11(
|
|
27156
|
+
() => buildKey20(__spreadProps(__spreadValues({}, auth), {
|
|
26953
27157
|
businessId,
|
|
26954
27158
|
startCutoff,
|
|
26955
27159
|
endCutoff
|
|
@@ -27247,8 +27451,8 @@ function getIconForTask(task) {
|
|
|
27247
27451
|
}
|
|
27248
27452
|
|
|
27249
27453
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27250
|
-
import { useSWRConfig as
|
|
27251
|
-
import
|
|
27454
|
+
import { useSWRConfig as useSWRConfig5 } from "swr";
|
|
27455
|
+
import useSWRMutation12 from "swr/mutation";
|
|
27252
27456
|
|
|
27253
27457
|
// src/api/layer/tasks.ts
|
|
27254
27458
|
var submitUserResponseForTask = post(
|
|
@@ -27281,8 +27485,8 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
27281
27485
|
}
|
|
27282
27486
|
|
|
27283
27487
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27284
|
-
import { useCallback as
|
|
27285
|
-
function
|
|
27488
|
+
import { useCallback as useCallback13 } from "react";
|
|
27489
|
+
function buildKey21({
|
|
27286
27490
|
access_token: accessToken,
|
|
27287
27491
|
apiUrl,
|
|
27288
27492
|
businessId
|
|
@@ -27299,9 +27503,9 @@ function buildKey17({
|
|
|
27299
27503
|
function useSubmitUserResponseForTask() {
|
|
27300
27504
|
const { data: auth } = useAuth();
|
|
27301
27505
|
const { businessId } = useLayerContext();
|
|
27302
|
-
const { mutate } =
|
|
27303
|
-
const mutationResponse =
|
|
27304
|
-
() =>
|
|
27506
|
+
const { mutate } = useSWRConfig5();
|
|
27507
|
+
const mutationResponse = useSWRMutation12(
|
|
27508
|
+
() => buildKey21(__spreadProps(__spreadValues({}, auth), {
|
|
27305
27509
|
businessId
|
|
27306
27510
|
})),
|
|
27307
27511
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, userResponse } }) => submitUserResponseForTask(
|
|
@@ -27324,18 +27528,19 @@ function useSubmitUserResponseForTask() {
|
|
|
27324
27528
|
}
|
|
27325
27529
|
);
|
|
27326
27530
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27327
|
-
const stableProxiedTrigger =
|
|
27328
|
-
(...triggerParameters) => __async(
|
|
27329
|
-
const
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27333
|
-
|
|
27334
|
-
|
|
27335
|
-
}
|
|
27336
|
-
return result;
|
|
27531
|
+
const stableProxiedTrigger = useCallback13(
|
|
27532
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27533
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27534
|
+
void mutate((key) => withSWRKeyTags(
|
|
27535
|
+
key,
|
|
27536
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27537
|
+
));
|
|
27538
|
+
return triggerResult;
|
|
27337
27539
|
}),
|
|
27338
|
-
[
|
|
27540
|
+
[
|
|
27541
|
+
originalTrigger,
|
|
27542
|
+
mutate
|
|
27543
|
+
]
|
|
27339
27544
|
);
|
|
27340
27545
|
return new Proxy(mutationResponse, {
|
|
27341
27546
|
get(target, prop) {
|
|
@@ -27348,10 +27553,10 @@ function useSubmitUserResponseForTask() {
|
|
|
27348
27553
|
}
|
|
27349
27554
|
|
|
27350
27555
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
27351
|
-
import { useSWRConfig as
|
|
27352
|
-
import
|
|
27353
|
-
import { useCallback as
|
|
27354
|
-
function
|
|
27556
|
+
import { useSWRConfig as useSWRConfig6 } from "swr";
|
|
27557
|
+
import useSWRMutation13 from "swr/mutation";
|
|
27558
|
+
import { useCallback as useCallback14 } from "react";
|
|
27559
|
+
function buildKey22({
|
|
27355
27560
|
access_token: accessToken,
|
|
27356
27561
|
apiUrl,
|
|
27357
27562
|
businessId
|
|
@@ -27368,9 +27573,9 @@ function buildKey18({
|
|
|
27368
27573
|
function useUploadDocumentsForTask() {
|
|
27369
27574
|
const { data: auth } = useAuth();
|
|
27370
27575
|
const { businessId } = useLayerContext();
|
|
27371
|
-
const { mutate } =
|
|
27372
|
-
const mutationResponse =
|
|
27373
|
-
() =>
|
|
27576
|
+
const { mutate } = useSWRConfig6();
|
|
27577
|
+
const mutationResponse = useSWRMutation13(
|
|
27578
|
+
() => buildKey22(__spreadProps(__spreadValues({}, auth), {
|
|
27374
27579
|
businessId
|
|
27375
27580
|
})),
|
|
27376
27581
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, files, description } }) => completeTaskWithUpload(
|
|
@@ -27389,18 +27594,19 @@ function useUploadDocumentsForTask() {
|
|
|
27389
27594
|
}
|
|
27390
27595
|
);
|
|
27391
27596
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27392
|
-
const stableProxiedTrigger =
|
|
27393
|
-
(...triggerParameters) => __async(
|
|
27394
|
-
const
|
|
27395
|
-
|
|
27396
|
-
|
|
27397
|
-
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
}
|
|
27401
|
-
return result;
|
|
27597
|
+
const stableProxiedTrigger = useCallback14(
|
|
27598
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27599
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27600
|
+
void mutate((key) => withSWRKeyTags(
|
|
27601
|
+
key,
|
|
27602
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27603
|
+
));
|
|
27604
|
+
return triggerResult;
|
|
27402
27605
|
}),
|
|
27403
|
-
[
|
|
27606
|
+
[
|
|
27607
|
+
originalTrigger,
|
|
27608
|
+
mutate
|
|
27609
|
+
]
|
|
27404
27610
|
);
|
|
27405
27611
|
return new Proxy(mutationResponse, {
|
|
27406
27612
|
get(target, prop) {
|
|
@@ -27413,10 +27619,10 @@ function useUploadDocumentsForTask() {
|
|
|
27413
27619
|
}
|
|
27414
27620
|
|
|
27415
27621
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
27416
|
-
import { useSWRConfig as
|
|
27417
|
-
import
|
|
27418
|
-
import { useCallback as
|
|
27419
|
-
function
|
|
27622
|
+
import { useSWRConfig as useSWRConfig7 } from "swr";
|
|
27623
|
+
import useSWRMutation14 from "swr/mutation";
|
|
27624
|
+
import { useCallback as useCallback15 } from "react";
|
|
27625
|
+
function buildKey23({
|
|
27420
27626
|
access_token: accessToken,
|
|
27421
27627
|
apiUrl,
|
|
27422
27628
|
businessId
|
|
@@ -27433,9 +27639,9 @@ function buildKey19({
|
|
|
27433
27639
|
function useDeleteUploadsOnTask() {
|
|
27434
27640
|
const { data: auth } = useAuth();
|
|
27435
27641
|
const { businessId } = useLayerContext();
|
|
27436
|
-
const { mutate } =
|
|
27437
|
-
const mutationResponse =
|
|
27438
|
-
() =>
|
|
27642
|
+
const { mutate } = useSWRConfig7();
|
|
27643
|
+
const mutationResponse = useSWRMutation14(
|
|
27644
|
+
() => buildKey23(__spreadProps(__spreadValues({}, auth), {
|
|
27439
27645
|
businessId
|
|
27440
27646
|
})),
|
|
27441
27647
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId } }) => deleteUploadsOnTask(
|
|
@@ -27451,18 +27657,19 @@ function useDeleteUploadsOnTask() {
|
|
|
27451
27657
|
}
|
|
27452
27658
|
);
|
|
27453
27659
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27454
|
-
const stableProxiedTrigger =
|
|
27455
|
-
(...triggerParameters) => __async(
|
|
27456
|
-
const
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
}
|
|
27463
|
-
return result;
|
|
27660
|
+
const stableProxiedTrigger = useCallback15(
|
|
27661
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27662
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27663
|
+
void mutate((key) => withSWRKeyTags(
|
|
27664
|
+
key,
|
|
27665
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27666
|
+
));
|
|
27667
|
+
return triggerResult;
|
|
27464
27668
|
}),
|
|
27465
|
-
[
|
|
27669
|
+
[
|
|
27670
|
+
originalTrigger,
|
|
27671
|
+
mutate
|
|
27672
|
+
]
|
|
27466
27673
|
);
|
|
27467
27674
|
return new Proxy(mutationResponse, {
|
|
27468
27675
|
get(target, prop) {
|
|
@@ -27475,10 +27682,10 @@ function useDeleteUploadsOnTask() {
|
|
|
27475
27682
|
}
|
|
27476
27683
|
|
|
27477
27684
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
27478
|
-
import { useSWRConfig as
|
|
27479
|
-
import
|
|
27480
|
-
import { useCallback as
|
|
27481
|
-
function
|
|
27685
|
+
import { useSWRConfig as useSWRConfig8 } from "swr";
|
|
27686
|
+
import useSWRMutation15 from "swr/mutation";
|
|
27687
|
+
import { useCallback as useCallback16 } from "react";
|
|
27688
|
+
function buildKey24({
|
|
27482
27689
|
access_token: accessToken,
|
|
27483
27690
|
apiUrl,
|
|
27484
27691
|
businessId
|
|
@@ -27495,9 +27702,9 @@ function buildKey20({
|
|
|
27495
27702
|
function useUpdateTaskUploadDescription() {
|
|
27496
27703
|
const { data: auth } = useAuth();
|
|
27497
27704
|
const { businessId } = useLayerContext();
|
|
27498
|
-
const { mutate } =
|
|
27499
|
-
const mutationResponse =
|
|
27500
|
-
() =>
|
|
27705
|
+
const { mutate } = useSWRConfig8();
|
|
27706
|
+
const mutationResponse = useSWRMutation15(
|
|
27707
|
+
() => buildKey24(__spreadProps(__spreadValues({}, auth), {
|
|
27501
27708
|
businessId
|
|
27502
27709
|
})),
|
|
27503
27710
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, description } }) => updateTaskUploadsDescription(
|
|
@@ -27517,18 +27724,19 @@ function useUpdateTaskUploadDescription() {
|
|
|
27517
27724
|
}
|
|
27518
27725
|
);
|
|
27519
27726
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27520
|
-
const stableProxiedTrigger =
|
|
27521
|
-
(...triggerParameters) => __async(
|
|
27522
|
-
const
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
|
|
27526
|
-
|
|
27527
|
-
|
|
27528
|
-
}
|
|
27529
|
-
return result;
|
|
27727
|
+
const stableProxiedTrigger = useCallback16(
|
|
27728
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27729
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27730
|
+
void mutate((key) => withSWRKeyTags(
|
|
27731
|
+
key,
|
|
27732
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27733
|
+
));
|
|
27734
|
+
return triggerResult;
|
|
27530
27735
|
}),
|
|
27531
|
-
[
|
|
27736
|
+
[
|
|
27737
|
+
originalTrigger,
|
|
27738
|
+
mutate
|
|
27739
|
+
]
|
|
27532
27740
|
);
|
|
27533
27741
|
return new Proxy(mutationResponse, {
|
|
27534
27742
|
get(target, prop) {
|
|
@@ -27570,7 +27778,7 @@ var TasksListItem = ({
|
|
|
27570
27778
|
useEffect41(() => {
|
|
27571
27779
|
setIsOpen(defaultOpen);
|
|
27572
27780
|
}, [defaultOpen]);
|
|
27573
|
-
const submit = () => __async(
|
|
27781
|
+
const submit = () => __async(null, null, function* () {
|
|
27574
27782
|
if (!selectedFiles) {
|
|
27575
27783
|
return;
|
|
27576
27784
|
}
|
|
@@ -27786,7 +27994,7 @@ var TasksListMobile = ({
|
|
|
27786
27994
|
};
|
|
27787
27995
|
|
|
27788
27996
|
// src/hooks/array/usePaginatedList.ts
|
|
27789
|
-
import { useCallback as
|
|
27997
|
+
import { useCallback as useCallback17, useMemo as useMemo40, useState as useState58 } from "react";
|
|
27790
27998
|
function usePaginatedList(list, pageSize) {
|
|
27791
27999
|
const [internalPageIndex, setInternalPageIndex] = useState58(0);
|
|
27792
28000
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
@@ -27797,16 +28005,16 @@ function usePaginatedList(list, pageSize) {
|
|
|
27797
28005
|
(effectivePageIndex + 1) * pageSize
|
|
27798
28006
|
);
|
|
27799
28007
|
}, [list, effectivePageIndex, pageSize]);
|
|
27800
|
-
const next =
|
|
28008
|
+
const next = useCallback17(() => {
|
|
27801
28009
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
27802
28010
|
}, [effectivePageIndex, pageCount]);
|
|
27803
|
-
const set2 =
|
|
28011
|
+
const set2 = useCallback17((pageIndex) => {
|
|
27804
28012
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
27805
28013
|
}, [pageCount]);
|
|
27806
|
-
const previous =
|
|
28014
|
+
const previous = useCallback17(() => {
|
|
27807
28015
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
27808
28016
|
}, [effectivePageIndex]);
|
|
27809
|
-
const reset =
|
|
28017
|
+
const reset = useCallback17(() => {
|
|
27810
28018
|
setInternalPageIndex(0);
|
|
27811
28019
|
}, []);
|
|
27812
28020
|
return {
|
|
@@ -28225,50 +28433,6 @@ var ArrowRightCircle = (_a) => {
|
|
|
28225
28433
|
};
|
|
28226
28434
|
var ArrowRightCircle_default = ArrowRightCircle;
|
|
28227
28435
|
|
|
28228
|
-
// src/hooks/bookkeeping/useBankAccounts.ts
|
|
28229
|
-
import useSWR16 from "swr";
|
|
28230
|
-
var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
|
|
28231
|
-
var getBankAccounts = get(
|
|
28232
|
-
({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
|
|
28233
|
-
);
|
|
28234
|
-
function buildKey21({
|
|
28235
|
-
access_token: accessToken,
|
|
28236
|
-
apiUrl,
|
|
28237
|
-
businessId
|
|
28238
|
-
}) {
|
|
28239
|
-
if (accessToken && apiUrl) {
|
|
28240
|
-
return {
|
|
28241
|
-
accessToken,
|
|
28242
|
-
apiUrl,
|
|
28243
|
-
businessId,
|
|
28244
|
-
tags: [BANK_ACCOUNTS_TAG_KEY]
|
|
28245
|
-
};
|
|
28246
|
-
}
|
|
28247
|
-
}
|
|
28248
|
-
var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
|
|
28249
|
-
var useBankAccounts = () => {
|
|
28250
|
-
var _a, _b;
|
|
28251
|
-
const { businessId } = useLayerContext();
|
|
28252
|
-
const { apiUrl } = useEnvironment();
|
|
28253
|
-
const { data: auth } = useAuth();
|
|
28254
|
-
const { data, error, isLoading } = useSWR16(
|
|
28255
|
-
() => buildKey21(__spreadProps(__spreadValues({}, auth), {
|
|
28256
|
-
apiUrl,
|
|
28257
|
-
businessId
|
|
28258
|
-
})),
|
|
28259
|
-
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getBankAccounts(apiUrl2, accessToken, { params: { businessId: businessId2 } })()
|
|
28260
|
-
);
|
|
28261
|
-
const disconnectedAccountsRequiringNotification = ((_a = data == null ? void 0 : data.data) != null ? _a : []).filter(
|
|
28262
|
-
(account) => requiresNotification(account)
|
|
28263
|
-
).length;
|
|
28264
|
-
return {
|
|
28265
|
-
bankAccounts: (_b = data == null ? void 0 : data.data) != null ? _b : [],
|
|
28266
|
-
isLoading,
|
|
28267
|
-
error,
|
|
28268
|
-
disconnectedAccountsRequiringNotification
|
|
28269
|
-
};
|
|
28270
|
-
};
|
|
28271
|
-
|
|
28272
28436
|
// src/components/Tasks/TasksPanelNotification.tsx
|
|
28273
28437
|
import { jsx as jsx251, jsxs as jsxs160 } from "react/jsx-runtime";
|
|
28274
28438
|
var TasksPanelNotification = ({
|
|
@@ -28622,7 +28786,7 @@ import { useForm as useForm2 } from "@tanstack/react-form";
|
|
|
28622
28786
|
import {
|
|
28623
28787
|
Children,
|
|
28624
28788
|
createContext as createContext20,
|
|
28625
|
-
useCallback as
|
|
28789
|
+
useCallback as useCallback18,
|
|
28626
28790
|
useContext as useContext50,
|
|
28627
28791
|
useMemo as useMemo45,
|
|
28628
28792
|
useState as useState60
|
|
@@ -28634,13 +28798,13 @@ function useWizardStep({
|
|
|
28634
28798
|
}) {
|
|
28635
28799
|
const stepCount = steps.length;
|
|
28636
28800
|
const [activeStepIndex, setActiveStepIndex] = useState60(0);
|
|
28637
|
-
const next =
|
|
28801
|
+
const next = useCallback18(() => __async(null, null, function* () {
|
|
28638
28802
|
setActiveStepIndex((stepIndex) => Math.min(stepIndex + 1, stepCount - 1));
|
|
28639
28803
|
if (activeStepIndex === stepCount - 1 && onComplete) {
|
|
28640
28804
|
yield onComplete == null ? void 0 : onComplete();
|
|
28641
28805
|
}
|
|
28642
28806
|
}), [stepCount, activeStepIndex, onComplete]);
|
|
28643
|
-
const previous =
|
|
28807
|
+
const previous = useCallback18(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
|
|
28644
28808
|
const effectiveStepIndex = Math.min(activeStepIndex, stepCount - 1);
|
|
28645
28809
|
const currentStep = steps.at(effectiveStepIndex);
|
|
28646
28810
|
return { currentStep, next, previous };
|
|
@@ -28719,7 +28883,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28719
28883
|
defaultValues: {
|
|
28720
28884
|
accounts: effectiveLinkedAccounts.map((account) => ({ account, isSelected: true }))
|
|
28721
28885
|
},
|
|
28722
|
-
onSubmit: (_0) => __async(
|
|
28886
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
28723
28887
|
const formattedArg = Object.fromEntries(
|
|
28724
28888
|
value.accounts.map(({ account, isSelected }) => [account.id, isSelected])
|
|
28725
28889
|
);
|
|
@@ -29233,7 +29397,7 @@ function isPersonnelRole(role) {
|
|
|
29233
29397
|
|
|
29234
29398
|
// src/hooks/businessPersonnel/useBusinessPersonnel.ts
|
|
29235
29399
|
var BUSINESS_PERSONNEL_TAG_KEY = "#business-personnel";
|
|
29236
|
-
function
|
|
29400
|
+
function buildKey25({
|
|
29237
29401
|
access_token: accessToken,
|
|
29238
29402
|
apiUrl,
|
|
29239
29403
|
businessId
|
|
@@ -29252,7 +29416,7 @@ function useBusinessPersonnel() {
|
|
|
29252
29416
|
const { data } = useAuth();
|
|
29253
29417
|
const { businessId } = useLayerContext();
|
|
29254
29418
|
return useSWR17(
|
|
29255
|
-
() =>
|
|
29419
|
+
() => buildKey25(__spreadProps(__spreadValues({}, data), {
|
|
29256
29420
|
businessId
|
|
29257
29421
|
})),
|
|
29258
29422
|
({ accessToken, apiUrl, businessId: businessId2 }) => getBusinessPersonnel(
|
|
@@ -29291,11 +29455,11 @@ function useBusinessPersonnel() {
|
|
|
29291
29455
|
}
|
|
29292
29456
|
|
|
29293
29457
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
29294
|
-
import
|
|
29295
|
-
import { useSWRConfig as
|
|
29296
|
-
import { useCallback as
|
|
29458
|
+
import useSWRMutation16 from "swr/mutation";
|
|
29459
|
+
import { useSWRConfig as useSWRConfig9 } from "swr";
|
|
29460
|
+
import { useCallback as useCallback19 } from "react";
|
|
29297
29461
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
29298
|
-
function
|
|
29462
|
+
function buildKey26({
|
|
29299
29463
|
access_token: accessToken,
|
|
29300
29464
|
apiUrl,
|
|
29301
29465
|
businessId
|
|
@@ -29312,9 +29476,9 @@ function buildKey23({
|
|
|
29312
29476
|
function useCreateBusinessPersonnel() {
|
|
29313
29477
|
const { data } = useAuth();
|
|
29314
29478
|
const { businessId } = useLayerContext();
|
|
29315
|
-
const { mutate } =
|
|
29316
|
-
const mutationResponse =
|
|
29317
|
-
() =>
|
|
29479
|
+
const { mutate } = useSWRConfig9();
|
|
29480
|
+
const mutationResponse = useSWRMutation16(
|
|
29481
|
+
() => buildKey26(__spreadProps(__spreadValues({}, data), {
|
|
29318
29482
|
businessId
|
|
29319
29483
|
})),
|
|
29320
29484
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createBusinessPersonnel(
|
|
@@ -29331,18 +29495,19 @@ function useCreateBusinessPersonnel() {
|
|
|
29331
29495
|
}
|
|
29332
29496
|
);
|
|
29333
29497
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29334
|
-
const stableProxiedTrigger =
|
|
29335
|
-
(...triggerParameters) => __async(
|
|
29336
|
-
const
|
|
29337
|
-
|
|
29338
|
-
|
|
29339
|
-
|
|
29340
|
-
|
|
29341
|
-
|
|
29342
|
-
}
|
|
29343
|
-
return result;
|
|
29498
|
+
const stableProxiedTrigger = useCallback19(
|
|
29499
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29500
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29501
|
+
void mutate((key) => withSWRKeyTags(
|
|
29502
|
+
key,
|
|
29503
|
+
(tags) => tags.includes(BUSINESS_PERSONNEL_TAG_KEY)
|
|
29504
|
+
));
|
|
29505
|
+
return triggerResult;
|
|
29344
29506
|
}),
|
|
29345
|
-
[
|
|
29507
|
+
[
|
|
29508
|
+
originalTrigger,
|
|
29509
|
+
mutate
|
|
29510
|
+
]
|
|
29346
29511
|
);
|
|
29347
29512
|
return new Proxy(mutationResponse, {
|
|
29348
29513
|
get(target, prop) {
|
|
@@ -29355,8 +29520,8 @@ function useCreateBusinessPersonnel() {
|
|
|
29355
29520
|
}
|
|
29356
29521
|
|
|
29357
29522
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29358
|
-
import
|
|
29359
|
-
import { useSWRConfig as
|
|
29523
|
+
import useSWRMutation17 from "swr/mutation";
|
|
29524
|
+
import { useSWRConfig as useSWRConfig10 } from "swr";
|
|
29360
29525
|
|
|
29361
29526
|
// src/api/layer/businessPersonnel/updateBusinessPersonnel.ts
|
|
29362
29527
|
var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
@@ -29364,8 +29529,8 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
29364
29529
|
});
|
|
29365
29530
|
|
|
29366
29531
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29367
|
-
import { useCallback as
|
|
29368
|
-
function
|
|
29532
|
+
import { useCallback as useCallback20 } from "react";
|
|
29533
|
+
function buildKey27({
|
|
29369
29534
|
access_token: accessToken,
|
|
29370
29535
|
apiUrl,
|
|
29371
29536
|
businessId,
|
|
@@ -29384,9 +29549,9 @@ function buildKey24({
|
|
|
29384
29549
|
function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
29385
29550
|
const { data } = useAuth();
|
|
29386
29551
|
const { businessId } = useLayerContext();
|
|
29387
|
-
const { mutate } =
|
|
29388
|
-
const mutationResponse =
|
|
29389
|
-
() =>
|
|
29552
|
+
const { mutate } = useSWRConfig10();
|
|
29553
|
+
const mutationResponse = useSWRMutation17(
|
|
29554
|
+
() => buildKey27(__spreadProps(__spreadValues({}, data), {
|
|
29390
29555
|
businessId,
|
|
29391
29556
|
businessPersonnelId
|
|
29392
29557
|
})),
|
|
@@ -29407,18 +29572,19 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29407
29572
|
}
|
|
29408
29573
|
);
|
|
29409
29574
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29410
|
-
const stableProxiedTrigger =
|
|
29411
|
-
(...triggerParameters) => __async(
|
|
29412
|
-
const
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
}
|
|
29419
|
-
return result;
|
|
29575
|
+
const stableProxiedTrigger = useCallback20(
|
|
29576
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29577
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29578
|
+
void mutate((key) => withSWRKeyTags(
|
|
29579
|
+
key,
|
|
29580
|
+
(tags) => tags.includes(BUSINESS_PERSONNEL_TAG_KEY)
|
|
29581
|
+
));
|
|
29582
|
+
return triggerResult;
|
|
29420
29583
|
}),
|
|
29421
|
-
[
|
|
29584
|
+
[
|
|
29585
|
+
originalTrigger,
|
|
29586
|
+
mutate
|
|
29587
|
+
]
|
|
29422
29588
|
);
|
|
29423
29589
|
return new Proxy(mutationResponse, {
|
|
29424
29590
|
get(target, prop) {
|
|
@@ -29431,11 +29597,11 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29431
29597
|
}
|
|
29432
29598
|
|
|
29433
29599
|
// src/hooks/business/useUpdateBusiness.ts
|
|
29434
|
-
import
|
|
29435
|
-
import { useSWRConfig as
|
|
29436
|
-
import { useCallback as
|
|
29600
|
+
import useSWRMutation18 from "swr/mutation";
|
|
29601
|
+
import { useSWRConfig as useSWRConfig11 } from "swr";
|
|
29602
|
+
import { useCallback as useCallback21 } from "react";
|
|
29437
29603
|
var BUSINESS_TAG_KEY = "business";
|
|
29438
|
-
function
|
|
29604
|
+
function buildKey28({
|
|
29439
29605
|
access_token: accessToken,
|
|
29440
29606
|
apiUrl,
|
|
29441
29607
|
businessId
|
|
@@ -29452,9 +29618,9 @@ function buildKey25({
|
|
|
29452
29618
|
function useUpdateBusiness() {
|
|
29453
29619
|
const { data } = useAuth();
|
|
29454
29620
|
const { businessId } = useLayerContext();
|
|
29455
|
-
const { mutate } =
|
|
29456
|
-
const mutationResponse =
|
|
29457
|
-
() =>
|
|
29621
|
+
const { mutate } = useSWRConfig11();
|
|
29622
|
+
const mutationResponse = useSWRMutation18(
|
|
29623
|
+
() => buildKey28(__spreadProps(__spreadValues({}, data), {
|
|
29458
29624
|
businessId
|
|
29459
29625
|
})),
|
|
29460
29626
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => updateBusiness(
|
|
@@ -29471,18 +29637,19 @@ function useUpdateBusiness() {
|
|
|
29471
29637
|
}
|
|
29472
29638
|
);
|
|
29473
29639
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29474
|
-
const stableProxiedTrigger =
|
|
29475
|
-
(...triggerParameters) => __async(
|
|
29476
|
-
const
|
|
29477
|
-
|
|
29478
|
-
|
|
29479
|
-
|
|
29480
|
-
|
|
29481
|
-
|
|
29482
|
-
}
|
|
29483
|
-
return result;
|
|
29640
|
+
const stableProxiedTrigger = useCallback21(
|
|
29641
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29642
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29643
|
+
void mutate((key) => withSWRKeyTags(
|
|
29644
|
+
key,
|
|
29645
|
+
(tags) => tags.includes(BUSINESS_TAG_KEY)
|
|
29646
|
+
));
|
|
29647
|
+
return triggerResult;
|
|
29484
29648
|
}),
|
|
29485
|
-
[
|
|
29649
|
+
[
|
|
29650
|
+
originalTrigger,
|
|
29651
|
+
mutate
|
|
29652
|
+
]
|
|
29486
29653
|
);
|
|
29487
29654
|
return new Proxy(mutationResponse, {
|
|
29488
29655
|
get(target, prop) {
|
|
@@ -29523,7 +29690,7 @@ var useBusinessForm = ({ onSuccess }) => {
|
|
|
29523
29690
|
us_state: (_i = business == null ? void 0 : business.us_state) != null ? _i : void 0,
|
|
29524
29691
|
tin: business == null ? void 0 : business.tin
|
|
29525
29692
|
},
|
|
29526
|
-
onSubmit: (_0) => __async(
|
|
29693
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
29527
29694
|
var _a2;
|
|
29528
29695
|
try {
|
|
29529
29696
|
setSubmitError(void 0);
|
|
@@ -30837,7 +31004,6 @@ export {
|
|
|
30837
31004
|
Direction,
|
|
30838
31005
|
DisplayState,
|
|
30839
31006
|
GeneralLedgerView,
|
|
30840
|
-
Integrations,
|
|
30841
31007
|
Journal,
|
|
30842
31008
|
LayerProvider,
|
|
30843
31009
|
LinkAccounts,
|
|
@@ -30851,6 +31017,7 @@ export {
|
|
|
30851
31017
|
Reports,
|
|
30852
31018
|
StatementOfCashFlow,
|
|
30853
31019
|
Tasks,
|
|
31020
|
+
unstable_Integrations,
|
|
30854
31021
|
useBankTransactionsContext,
|
|
30855
31022
|
useDataSync,
|
|
30856
31023
|
useLayerContext
|