@layerfi/components 0.1.99-alpha-1 → 0.1.99-alpha.3
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 +1201 -1032
- package/dist/esm/index.mjs +633 -464
- package/dist/index.css +123 -137
- package/dist/index.d.ts +77 -52
- 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-alpha
|
|
5573
|
+
var version = "0.1.99-alpha.3";
|
|
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,214 @@ 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/useBankTransactions/useCategorizeBankTransaction.ts
|
|
7446
|
+
var CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
|
|
7447
|
+
function buildKey3({
|
|
7448
|
+
access_token: accessToken,
|
|
7449
|
+
apiUrl,
|
|
7450
|
+
businessId
|
|
7451
|
+
}) {
|
|
7452
|
+
if (accessToken && apiUrl) {
|
|
7453
|
+
return {
|
|
7454
|
+
accessToken,
|
|
7455
|
+
apiUrl,
|
|
7456
|
+
businessId,
|
|
7457
|
+
tags: [CATEGORIZE_BANK_TRANSACTION_TAG]
|
|
7458
|
+
};
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
function useCategorizeBankTransaction({
|
|
7462
|
+
mutateBankTransactions
|
|
7463
|
+
}) {
|
|
7464
|
+
const { data: auth } = useAuth();
|
|
7465
|
+
const { businessId } = useLayerContext();
|
|
7466
|
+
const { mutate } = useSWRConfig();
|
|
7467
|
+
const mutationResponse = useSWRMutation(
|
|
7468
|
+
() => buildKey3({
|
|
7469
|
+
access_token: auth == null ? void 0 : auth.access_token,
|
|
7470
|
+
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
7471
|
+
businessId
|
|
7472
|
+
}),
|
|
7473
|
+
({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
|
|
7474
|
+
var { arg: _b } = _a, _c = _b, { bankTransactionId } = _c, body = __objRest(_c, ["bankTransactionId"]);
|
|
7475
|
+
return categorizeBankTransaction(
|
|
7476
|
+
apiUrl,
|
|
7477
|
+
accessToken,
|
|
7478
|
+
{
|
|
7479
|
+
params: {
|
|
7480
|
+
businessId: businessId2,
|
|
7481
|
+
bankTransactionId
|
|
7482
|
+
},
|
|
7483
|
+
body
|
|
7484
|
+
}
|
|
7485
|
+
).then(({ data }) => data);
|
|
7486
|
+
},
|
|
7487
|
+
{
|
|
7488
|
+
revalidate: false
|
|
7489
|
+
}
|
|
7490
|
+
);
|
|
7491
|
+
const { trigger: originalTrigger } = mutationResponse;
|
|
7492
|
+
const stableProxiedTrigger = useCallback(
|
|
7493
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
7494
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
7495
|
+
void mutate((key) => withSWRKeyTags(
|
|
7496
|
+
key,
|
|
7497
|
+
(tags) => tags.includes(CATEGORIZE_BANK_TRANSACTION_TAG)
|
|
7498
|
+
));
|
|
7499
|
+
void mutateBankTransactions(void 0, { revalidate: true });
|
|
7500
|
+
return triggerResult;
|
|
7501
|
+
}),
|
|
7502
|
+
[
|
|
7503
|
+
originalTrigger,
|
|
7504
|
+
mutate,
|
|
7505
|
+
mutateBankTransactions
|
|
7506
|
+
]
|
|
7507
|
+
);
|
|
7508
|
+
return new Proxy(mutationResponse, {
|
|
7509
|
+
get(target, prop) {
|
|
7510
|
+
if (prop === "trigger") {
|
|
7511
|
+
return stableProxiedTrigger;
|
|
7512
|
+
}
|
|
7513
|
+
return Reflect.get(target, prop);
|
|
7514
|
+
}
|
|
7515
|
+
});
|
|
7516
|
+
}
|
|
7517
|
+
|
|
7518
|
+
// src/hooks/useBankTransactions/useMatchBankTransaction.ts
|
|
7519
|
+
import { useCallback as useCallback2 } from "react";
|
|
7520
|
+
import { useSWRConfig as useSWRConfig2 } from "swr";
|
|
7521
|
+
import useSWRMutation2 from "swr/mutation";
|
|
7522
|
+
|
|
7523
|
+
// src/hooks/bookkeeping/useBankAccounts.ts
|
|
7524
|
+
import useSWR3 from "swr";
|
|
7525
|
+
var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
|
|
7526
|
+
var getBankAccounts = get(
|
|
7527
|
+
({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
|
|
7528
|
+
);
|
|
7529
|
+
function buildKey4({
|
|
7530
|
+
access_token: accessToken,
|
|
7531
|
+
apiUrl,
|
|
7532
|
+
businessId
|
|
7533
|
+
}) {
|
|
7534
|
+
if (accessToken && apiUrl) {
|
|
7535
|
+
return {
|
|
7536
|
+
accessToken,
|
|
7537
|
+
apiUrl,
|
|
7538
|
+
businessId,
|
|
7539
|
+
tags: [BANK_ACCOUNTS_TAG_KEY]
|
|
7540
|
+
};
|
|
7541
|
+
}
|
|
7542
|
+
}
|
|
7543
|
+
var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
|
|
7544
|
+
var useBankAccounts = () => {
|
|
7545
|
+
var _a, _b;
|
|
7546
|
+
const { businessId } = useLayerContext();
|
|
7547
|
+
const { apiUrl } = useEnvironment();
|
|
7548
|
+
const { data: auth } = useAuth();
|
|
7549
|
+
const { data, error, isLoading } = useSWR3(
|
|
7550
|
+
() => buildKey4(__spreadProps(__spreadValues({}, auth), {
|
|
7551
|
+
apiUrl,
|
|
7552
|
+
businessId
|
|
7553
|
+
})),
|
|
7554
|
+
({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getBankAccounts(apiUrl2, accessToken, { params: { businessId: businessId2 } })()
|
|
7555
|
+
);
|
|
7556
|
+
const disconnectedAccountsRequiringNotification = ((_a = data == null ? void 0 : data.data) != null ? _a : []).filter(
|
|
7557
|
+
(account) => requiresNotification(account)
|
|
7558
|
+
).length;
|
|
7559
|
+
return {
|
|
7560
|
+
bankAccounts: (_b = data == null ? void 0 : data.data) != null ? _b : [],
|
|
7561
|
+
isLoading,
|
|
7562
|
+
error,
|
|
7563
|
+
disconnectedAccountsRequiringNotification
|
|
7564
|
+
};
|
|
7565
|
+
};
|
|
7566
|
+
|
|
7567
|
+
// src/hooks/useBankTransactions/useMatchBankTransaction.ts
|
|
7568
|
+
var MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
|
|
7569
|
+
function buildKey5({
|
|
7570
|
+
access_token: accessToken,
|
|
7571
|
+
apiUrl,
|
|
7572
|
+
businessId
|
|
7573
|
+
}) {
|
|
7574
|
+
if (accessToken && apiUrl) {
|
|
7575
|
+
return {
|
|
7576
|
+
accessToken,
|
|
7577
|
+
apiUrl,
|
|
7578
|
+
businessId,
|
|
7579
|
+
tags: [MATCH_BANK_TRANSACTION_TAG]
|
|
7580
|
+
};
|
|
7581
|
+
}
|
|
7582
|
+
}
|
|
7583
|
+
function useMatchBankTransaction({
|
|
7584
|
+
mutateBankTransactions
|
|
7585
|
+
}) {
|
|
7586
|
+
const { data: auth } = useAuth();
|
|
7587
|
+
const { businessId } = useLayerContext();
|
|
7588
|
+
const { mutate } = useSWRConfig2();
|
|
7589
|
+
const mutationResponse = useSWRMutation2(
|
|
7590
|
+
() => buildKey5({
|
|
7591
|
+
access_token: auth == null ? void 0 : auth.access_token,
|
|
7592
|
+
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
7593
|
+
businessId
|
|
7594
|
+
}),
|
|
7595
|
+
({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
|
|
7596
|
+
var { arg: _b } = _a, _c = _b, { bankTransactionId } = _c, body = __objRest(_c, ["bankTransactionId"]);
|
|
7597
|
+
return matchBankTransaction(
|
|
7598
|
+
apiUrl,
|
|
7599
|
+
accessToken,
|
|
7600
|
+
{
|
|
7601
|
+
params: {
|
|
7602
|
+
businessId: businessId2,
|
|
7603
|
+
bankTransactionId
|
|
7604
|
+
},
|
|
7605
|
+
body
|
|
7606
|
+
}
|
|
7607
|
+
).then(({ data }) => data);
|
|
7608
|
+
},
|
|
7609
|
+
{
|
|
7610
|
+
revalidate: false
|
|
7611
|
+
}
|
|
7612
|
+
);
|
|
7613
|
+
const { trigger: originalTrigger } = mutationResponse;
|
|
7614
|
+
const stableProxiedTrigger = useCallback2(
|
|
7615
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
7616
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
7617
|
+
void mutate((key) => withSWRKeyTags(
|
|
7618
|
+
key,
|
|
7619
|
+
(tags) => tags.includes(BANK_ACCOUNTS_TAG_KEY) || tags.includes(EXTERNAL_ACCOUNTS_TAG_KEY)
|
|
7620
|
+
));
|
|
7621
|
+
void mutateBankTransactions(void 0, { revalidate: true });
|
|
7622
|
+
return triggerResult;
|
|
7623
|
+
}),
|
|
7624
|
+
[
|
|
7625
|
+
originalTrigger,
|
|
7626
|
+
mutate,
|
|
7627
|
+
mutateBankTransactions
|
|
7628
|
+
]
|
|
7629
|
+
);
|
|
7630
|
+
return new Proxy(mutationResponse, {
|
|
7631
|
+
get(target, prop) {
|
|
7632
|
+
if (prop === "trigger") {
|
|
7633
|
+
return stableProxiedTrigger;
|
|
7634
|
+
}
|
|
7635
|
+
return Reflect.get(target, prop);
|
|
7636
|
+
}
|
|
7637
|
+
});
|
|
7638
|
+
}
|
|
7639
|
+
|
|
7407
7640
|
// src/hooks/useBankTransactions/useAugmentedBankTransactions.tsx
|
|
7408
7641
|
var INITIAL_POLL_INTERVAL_MS = 1e3;
|
|
7409
7642
|
var POLL_INTERVAL_AFTER_TXNS_RECEIVED_MS = 5e3;
|
|
@@ -7461,7 +7694,6 @@ function bankTransactionFiltersToHookOptions(filters) {
|
|
|
7461
7694
|
}
|
|
7462
7695
|
var useAugmentedBankTransactions = (params) => {
|
|
7463
7696
|
const {
|
|
7464
|
-
businessId,
|
|
7465
7697
|
addToast,
|
|
7466
7698
|
touch,
|
|
7467
7699
|
read,
|
|
@@ -7469,8 +7701,6 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7469
7701
|
hasBeenTouched,
|
|
7470
7702
|
eventCallbacks
|
|
7471
7703
|
} = useLayerContext();
|
|
7472
|
-
const { apiUrl } = useEnvironment();
|
|
7473
|
-
const { data: auth } = useAuth();
|
|
7474
7704
|
const [filters, setTheFilters] = useState6(
|
|
7475
7705
|
buildInitialFilters(params != null ? params : {})
|
|
7476
7706
|
);
|
|
@@ -7542,122 +7772,107 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7542
7772
|
}
|
|
7543
7773
|
return filtered;
|
|
7544
7774
|
}, [filters, data]);
|
|
7545
|
-
const
|
|
7546
|
-
const
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7775
|
+
const updateOneLocal = (newBankTransaction) => {
|
|
7776
|
+
const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
|
|
7777
|
+
var _a;
|
|
7778
|
+
return __spreadProps(__spreadValues({}, page), {
|
|
7779
|
+
data: (_a = page.data) == null ? void 0 : _a.map(
|
|
7780
|
+
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
7781
|
+
)
|
|
7782
|
+
});
|
|
7783
|
+
});
|
|
7784
|
+
void mutate(updatedData, { revalidate: false });
|
|
7785
|
+
};
|
|
7786
|
+
const { trigger: categorizeBankTransaction2 } = useCategorizeBankTransaction({
|
|
7787
|
+
mutateBankTransactions: mutate
|
|
7788
|
+
});
|
|
7789
|
+
const categorizeWithOptimisticUpdate = (bankTransactionId, newCategory, notify) => __async(null, null, function* () {
|
|
7790
|
+
const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7791
|
+
if (existingTransaction) {
|
|
7792
|
+
updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), { processing: true, error: void 0 }));
|
|
7793
|
+
}
|
|
7794
|
+
return categorizeBankTransaction2(__spreadValues({
|
|
7795
|
+
bankTransactionId
|
|
7796
|
+
}, newCategory)).then((updatedTransaction) => {
|
|
7797
|
+
updateOneLocal(__spreadProps(__spreadValues({}, updatedTransaction), {
|
|
7798
|
+
processing: false,
|
|
7799
|
+
recently_categorized: true
|
|
7800
|
+
}));
|
|
7801
|
+
if (notify) {
|
|
7565
7802
|
addToast({ content: "Transaction confirmed" });
|
|
7566
7803
|
}
|
|
7567
|
-
}).catch((
|
|
7568
|
-
const
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
updateOneLocal(__spreadProps(__spreadValues({}, newBT), {
|
|
7573
|
-
error: err.message,
|
|
7804
|
+
}).catch((error) => {
|
|
7805
|
+
const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7806
|
+
if (targetedTransaction) {
|
|
7807
|
+
updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
|
|
7808
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
7574
7809
|
processing: false
|
|
7575
7810
|
}));
|
|
7576
7811
|
}
|
|
7577
7812
|
}).finally(() => {
|
|
7578
7813
|
var _a;
|
|
7579
|
-
|
|
7580
|
-
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, id);
|
|
7814
|
+
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, bankTransactionId);
|
|
7581
7815
|
});
|
|
7582
|
-
};
|
|
7583
|
-
const
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7816
|
+
});
|
|
7817
|
+
const { trigger: matchBankTransaction2 } = useMatchBankTransaction({
|
|
7818
|
+
mutateBankTransactions: mutate
|
|
7819
|
+
});
|
|
7820
|
+
const matchWithOptimisticUpdate = (bankTransactionId, suggestedMatchId, notify) => __async(null, null, function* () {
|
|
7821
|
+
const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7822
|
+
if (existingTransaction) {
|
|
7823
|
+
updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), {
|
|
7824
|
+
processing: true,
|
|
7825
|
+
error: void 0
|
|
7826
|
+
}));
|
|
7589
7827
|
}
|
|
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
|
-
}
|
|
7828
|
+
const transferBankTransaction = data == null ? void 0 : data.find(
|
|
7829
|
+
({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
|
|
7595
7830
|
);
|
|
7596
|
-
if (
|
|
7597
|
-
updateOneLocal(__spreadProps(__spreadValues({},
|
|
7831
|
+
if (transferBankTransaction) {
|
|
7832
|
+
updateOneLocal(__spreadProps(__spreadValues({}, transferBankTransaction), {
|
|
7598
7833
|
processing: true,
|
|
7599
7834
|
error: void 0
|
|
7600
7835
|
}));
|
|
7601
7836
|
}
|
|
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);
|
|
7837
|
+
return matchBankTransaction2({
|
|
7838
|
+
bankTransactionId,
|
|
7839
|
+
match_id: suggestedMatchId,
|
|
7840
|
+
type: "Confirm_Match" /* CONFIRM_MATCH */
|
|
7841
|
+
}).then((match) => {
|
|
7842
|
+
const matchedTransaction = data == null ? void 0 : data.find(({ id }) => id === match.bank_transaction.id);
|
|
7843
|
+
if (matchedTransaction) {
|
|
7844
|
+
updateOneLocal(__spreadProps(__spreadValues({}, matchedTransaction), {
|
|
7845
|
+
categorization_status: "MATCHED" /* MATCHED */,
|
|
7846
|
+
match,
|
|
7847
|
+
processing: false,
|
|
7848
|
+
recently_categorized: true
|
|
7849
|
+
}));
|
|
7626
7850
|
}
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7851
|
+
const matchedTransferTransaction = data == null ? void 0 : data.find(
|
|
7852
|
+
({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
|
|
7853
|
+
);
|
|
7854
|
+
if (matchedTransferTransaction) {
|
|
7855
|
+
updateOneLocal(__spreadProps(__spreadValues({}, matchedTransferTransaction), {
|
|
7856
|
+
processing: false,
|
|
7857
|
+
recently_categorized: true
|
|
7858
|
+
}));
|
|
7630
7859
|
}
|
|
7631
|
-
if (
|
|
7860
|
+
if (notify) {
|
|
7632
7861
|
addToast({ content: "Transaction saved" });
|
|
7633
7862
|
}
|
|
7634
|
-
}).catch((
|
|
7635
|
-
const
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
updateOneLocal(__spreadProps(__spreadValues({}, newBT), {
|
|
7640
|
-
error: err.message,
|
|
7863
|
+
}).catch((error) => {
|
|
7864
|
+
const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
|
|
7865
|
+
if (targetedTransaction) {
|
|
7866
|
+
updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
|
|
7867
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
7641
7868
|
processing: false
|
|
7642
7869
|
}));
|
|
7643
7870
|
}
|
|
7644
7871
|
}).finally(() => {
|
|
7645
7872
|
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
|
-
});
|
|
7873
|
+
(_a = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a.call(eventCallbacks, bankTransactionId);
|
|
7658
7874
|
});
|
|
7659
|
-
|
|
7660
|
-
};
|
|
7875
|
+
});
|
|
7661
7876
|
const shouldHideAfterCategorize = () => {
|
|
7662
7877
|
return (filters == null ? void 0 : filters.categorizationStatus) === "review" /* review */;
|
|
7663
7878
|
};
|
|
@@ -7743,8 +7958,8 @@ var useAugmentedBankTransactions = (params) => {
|
|
|
7743
7958
|
isValidating,
|
|
7744
7959
|
refetch,
|
|
7745
7960
|
error: responseError,
|
|
7746
|
-
categorize,
|
|
7747
|
-
match,
|
|
7961
|
+
categorize: categorizeWithOptimisticUpdate,
|
|
7962
|
+
match: matchWithOptimisticUpdate,
|
|
7748
7963
|
updateOneLocal,
|
|
7749
7964
|
shouldHideAfterCategorize,
|
|
7750
7965
|
removeAfterCategorize,
|
|
@@ -7767,7 +7982,7 @@ var BankTransactionsProvider = ({
|
|
|
7767
7982
|
};
|
|
7768
7983
|
|
|
7769
7984
|
// src/providers/BusinessProvider/BusinessProvider.tsx
|
|
7770
|
-
import
|
|
7985
|
+
import useSWR4 from "swr";
|
|
7771
7986
|
|
|
7772
7987
|
// src/utils/swr/defaultSWRConfig.ts
|
|
7773
7988
|
var DEFAULT_SWR_CONFIG = {
|
|
@@ -7835,7 +8050,7 @@ var BusinessProvider = ({
|
|
|
7835
8050
|
} = useDataSync();
|
|
7836
8051
|
const { apiUrl } = useEnvironment();
|
|
7837
8052
|
const { data: auth } = useAuth();
|
|
7838
|
-
const { data: businessData } =
|
|
8053
|
+
const { data: businessData } = useSWR4(
|
|
7839
8054
|
businessId && (auth == null ? void 0 : auth.access_token) && `business-${businessId}`,
|
|
7840
8055
|
Layer.getBusiness(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
7841
8056
|
params: { businessId }
|
|
@@ -11026,13 +11241,13 @@ var LinkedAccountItemThumb = ({
|
|
|
11026
11241
|
config: [
|
|
11027
11242
|
{
|
|
11028
11243
|
name: "Mark as a duplicate account",
|
|
11029
|
-
action: () => __async(
|
|
11244
|
+
action: () => __async(null, null, function* () {
|
|
11030
11245
|
yield excludeAccount2(account.external_account_source, account.id);
|
|
11031
11246
|
})
|
|
11032
11247
|
},
|
|
11033
11248
|
{
|
|
11034
11249
|
name: "Mark as not a duplicate account",
|
|
11035
|
-
action: () => __async(
|
|
11250
|
+
action: () => __async(null, null, function* () {
|
|
11036
11251
|
yield confirmAccount2(account.external_account_source, account.id);
|
|
11037
11252
|
})
|
|
11038
11253
|
}
|
|
@@ -11044,7 +11259,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11044
11259
|
config: [
|
|
11045
11260
|
{
|
|
11046
11261
|
name: "Repair connection",
|
|
11047
|
-
action: () => __async(
|
|
11262
|
+
action: () => __async(null, null, function* () {
|
|
11048
11263
|
if (account.connection_external_id) {
|
|
11049
11264
|
yield repairConnection(
|
|
11050
11265
|
account.external_account_source,
|
|
@@ -11059,7 +11274,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11059
11274
|
const additionalConfigs = [
|
|
11060
11275
|
{
|
|
11061
11276
|
name: "Unlink account",
|
|
11062
|
-
action: () => __async(
|
|
11277
|
+
action: () => __async(null, null, function* () {
|
|
11063
11278
|
if (confirm("Please confirm you wish to remove this financial account")) {
|
|
11064
11279
|
yield unlinkAccount2(account.external_account_source, account.id);
|
|
11065
11280
|
}
|
|
@@ -11069,7 +11284,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11069
11284
|
if (showUnlinkItem) {
|
|
11070
11285
|
additionalConfigs.push({
|
|
11071
11286
|
name: `Unlink all accounts under this ${(_a = account.institution) == null ? void 0 : _a.name} connection`,
|
|
11072
|
-
action: () => __async(
|
|
11287
|
+
action: () => __async(null, null, function* () {
|
|
11073
11288
|
var _a2;
|
|
11074
11289
|
if (account.connection_external_id && confirm(
|
|
11075
11290
|
`Please confirm you wish to remove all accounts belonging to ${((_a2 = account.institution) == null ? void 0 : _a2.name) || "this institution"}`
|
|
@@ -11093,7 +11308,7 @@ var LinkedAccountItemThumb = ({
|
|
|
11093
11308
|
if (environment === "staging" && !account.connection_needs_repair_as_of && account.external_account_source === "PLAID" && showBreakConnection) {
|
|
11094
11309
|
additionalConfigs.push({
|
|
11095
11310
|
name: "Break connection (test utility)",
|
|
11096
|
-
action: () => __async(
|
|
11311
|
+
action: () => __async(null, null, function* () {
|
|
11097
11312
|
if (account.connection_external_id) {
|
|
11098
11313
|
yield breakConnection(
|
|
11099
11314
|
account.external_account_source,
|
|
@@ -11446,8 +11661,8 @@ function LinkedAccountToConfirm({
|
|
|
11446
11661
|
}
|
|
11447
11662
|
|
|
11448
11663
|
// src/components/LinkedAccounts/ConfirmationModal/useConfirmAndExcludeMultiple.ts
|
|
11449
|
-
import
|
|
11450
|
-
function
|
|
11664
|
+
import useSWRMutation3 from "swr/mutation";
|
|
11665
|
+
function buildKey6({
|
|
11451
11666
|
access_token: accessToken,
|
|
11452
11667
|
apiUrl,
|
|
11453
11668
|
businessId
|
|
@@ -11504,8 +11719,8 @@ function confirm2({
|
|
|
11504
11719
|
function useConfirmAndExcludeMultiple({ onSuccess }) {
|
|
11505
11720
|
const { data: auth } = useAuth();
|
|
11506
11721
|
const { businessId } = useLayerContext();
|
|
11507
|
-
return
|
|
11508
|
-
() =>
|
|
11722
|
+
return useSWRMutation3(
|
|
11723
|
+
() => buildKey6({
|
|
11509
11724
|
access_token: auth == null ? void 0 : auth.access_token,
|
|
11510
11725
|
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
11511
11726
|
businessId
|
|
@@ -11594,7 +11809,7 @@ function LinkedAccountsConfirmationModalContent({ onClose }) {
|
|
|
11594
11809
|
));
|
|
11595
11810
|
const { trigger, isMutating, error } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
|
|
11596
11811
|
const hasError = Boolean(error);
|
|
11597
|
-
const handleFinish = () => __async(
|
|
11812
|
+
const handleFinish = () => __async(null, null, function* () {
|
|
11598
11813
|
const success = yield trigger(formState);
|
|
11599
11814
|
if (success) {
|
|
11600
11815
|
onFinish();
|
|
@@ -11920,7 +12135,7 @@ var FileInput = ({
|
|
|
11920
12135
|
};
|
|
11921
12136
|
|
|
11922
12137
|
// src/components/Input/Select.tsx
|
|
11923
|
-
import { useCallback } from "react";
|
|
12138
|
+
import { useCallback as useCallback3 } from "react";
|
|
11924
12139
|
import ReactSelect, {
|
|
11925
12140
|
components
|
|
11926
12141
|
} from "react-select";
|
|
@@ -11975,7 +12190,7 @@ var Select = ({
|
|
|
11975
12190
|
isInvalid ? "Layer__select--error" : "",
|
|
11976
12191
|
className
|
|
11977
12192
|
);
|
|
11978
|
-
const DropdownIndicator2 =
|
|
12193
|
+
const DropdownIndicator2 = useCallback3((props) => /* @__PURE__ */ jsx83(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx83(ChevronDownFill_default, {}) })), []);
|
|
11979
12194
|
return /* @__PURE__ */ jsxs46(Tooltip, { disabled: !isInvalid || !errorMessage, children: [
|
|
11980
12195
|
/* @__PURE__ */ jsx83(TooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx83(
|
|
11981
12196
|
ReactSelect,
|
|
@@ -12035,7 +12250,7 @@ var InputWithBadge = (_a) => {
|
|
|
12035
12250
|
};
|
|
12036
12251
|
|
|
12037
12252
|
// src/components/Input/MultiSelect.tsx
|
|
12038
|
-
import { useCallback as
|
|
12253
|
+
import { useCallback as useCallback4 } from "react";
|
|
12039
12254
|
import ReactSelect2, {
|
|
12040
12255
|
components as components2
|
|
12041
12256
|
} from "react-select";
|
|
@@ -12060,7 +12275,7 @@ var MultiSelect = ({
|
|
|
12060
12275
|
isInvalid ? "Layer__select--error" : "",
|
|
12061
12276
|
className
|
|
12062
12277
|
);
|
|
12063
|
-
const DropdownIndicator2 =
|
|
12278
|
+
const DropdownIndicator2 = useCallback4((props) => /* @__PURE__ */ jsx85(components2.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx85(ChevronDownFill_default, {}) })), []);
|
|
12064
12279
|
return /* @__PURE__ */ jsxs48(Tooltip, { disabled: !isInvalid || !errorMessage, children: [
|
|
12065
12280
|
/* @__PURE__ */ jsx85(TooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx85(
|
|
12066
12281
|
ReactSelect2,
|
|
@@ -12677,8 +12892,8 @@ var AccountFormBox = ({
|
|
|
12677
12892
|
};
|
|
12678
12893
|
|
|
12679
12894
|
// src/components/LinkedAccounts/OpeningBalanceModal/useUpdateOpeningBalanceAndDate.ts
|
|
12680
|
-
import
|
|
12681
|
-
function
|
|
12895
|
+
import useSWRMutation4 from "swr/mutation";
|
|
12896
|
+
function buildKey7({
|
|
12682
12897
|
access_token: accessToken,
|
|
12683
12898
|
apiUrl,
|
|
12684
12899
|
businessId,
|
|
@@ -12730,8 +12945,8 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
|
|
|
12730
12945
|
}
|
|
12731
12946
|
return errors;
|
|
12732
12947
|
};
|
|
12733
|
-
return
|
|
12734
|
-
() =>
|
|
12948
|
+
return useSWRMutation4(
|
|
12949
|
+
() => buildKey7({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
|
|
12735
12950
|
({ accessToken, apiUrl, businessId: businessId2, data: data2 }) => Promise.allSettled(
|
|
12736
12951
|
data2.map(
|
|
12737
12952
|
({ accountId, openingDate, openingBalance }) => {
|
|
@@ -12876,7 +13091,7 @@ function LinkedAccountsOpeningBalanceModalContent({
|
|
|
12876
13091
|
};
|
|
12877
13092
|
}),
|
|
12878
13093
|
{
|
|
12879
|
-
onSuccess: (responses) => __async(
|
|
13094
|
+
onSuccess: (responses) => __async(null, null, function* () {
|
|
12880
13095
|
const newResults = __spreadValues({}, results);
|
|
12881
13096
|
responses.forEach((r) => {
|
|
12882
13097
|
newResults[r.accountId] = r;
|
|
@@ -13559,9 +13774,9 @@ var getAssignedValue = (bankTransaction) => {
|
|
|
13559
13774
|
};
|
|
13560
13775
|
|
|
13561
13776
|
// src/hooks/categories/useCategories.ts
|
|
13562
|
-
import
|
|
13777
|
+
import useSWR5 from "swr";
|
|
13563
13778
|
var CATEGORIES_TAG_KEY = "#categories";
|
|
13564
|
-
function
|
|
13779
|
+
function buildKey8({
|
|
13565
13780
|
access_token: accessToken,
|
|
13566
13781
|
apiUrl,
|
|
13567
13782
|
businessId,
|
|
@@ -13580,8 +13795,8 @@ function buildKey4({
|
|
|
13580
13795
|
function useCategories({ mode } = {}) {
|
|
13581
13796
|
const { data: auth } = useAuth();
|
|
13582
13797
|
const { businessId } = useLayerContext();
|
|
13583
|
-
return
|
|
13584
|
-
() =>
|
|
13798
|
+
return useSWR5(
|
|
13799
|
+
() => buildKey8(__spreadProps(__spreadValues({}, auth), {
|
|
13585
13800
|
businessId,
|
|
13586
13801
|
mode
|
|
13587
13802
|
})),
|
|
@@ -13948,7 +14163,7 @@ import {
|
|
|
13948
14163
|
forwardRef as forwardRef12,
|
|
13949
14164
|
useImperativeHandle as useImperativeHandle2,
|
|
13950
14165
|
useState as useState23,
|
|
13951
|
-
useCallback as
|
|
14166
|
+
useCallback as useCallback6,
|
|
13952
14167
|
useEffect as useEffect13,
|
|
13953
14168
|
useRef as useRef9
|
|
13954
14169
|
} from "react";
|
|
@@ -14112,7 +14327,7 @@ var useReceipts = ({
|
|
|
14112
14327
|
void fetchDocuments();
|
|
14113
14328
|
}
|
|
14114
14329
|
}, [isActive]);
|
|
14115
|
-
const fetchDocuments = () => __async(
|
|
14330
|
+
const fetchDocuments = () => __async(null, null, function* () {
|
|
14116
14331
|
const listBankTransactionDocuments2 = Layer.listBankTransactionDocuments(
|
|
14117
14332
|
apiUrl,
|
|
14118
14333
|
auth == null ? void 0 : auth.access_token,
|
|
@@ -14134,7 +14349,7 @@ var useReceipts = ({
|
|
|
14134
14349
|
}));
|
|
14135
14350
|
setReceiptUrls(retrievedDocs);
|
|
14136
14351
|
});
|
|
14137
|
-
const uploadReceipt = (file) => __async(
|
|
14352
|
+
const uploadReceipt = (file) => __async(null, null, function* () {
|
|
14138
14353
|
var _a;
|
|
14139
14354
|
const id = (/* @__PURE__ */ new Date()).valueOf().toString();
|
|
14140
14355
|
const receipts = [
|
|
@@ -14179,7 +14394,7 @@ var useReceipts = ({
|
|
|
14179
14394
|
setReceiptUrls(newReceiptUrls);
|
|
14180
14395
|
}
|
|
14181
14396
|
});
|
|
14182
|
-
const archiveDocument = (document2) => __async(
|
|
14397
|
+
const archiveDocument = (document2) => __async(null, null, function* () {
|
|
14183
14398
|
if (!document2.id) return;
|
|
14184
14399
|
try {
|
|
14185
14400
|
if (document2.error) {
|
|
@@ -14454,7 +14669,7 @@ var BankTransactionReceipts = forwardRef11(
|
|
|
14454
14669
|
BankTransactionReceipts.displayName = "BankTransactionReceipts";
|
|
14455
14670
|
|
|
14456
14671
|
// src/hooks/bookkeeping/useBookkeepingStatus.ts
|
|
14457
|
-
import
|
|
14672
|
+
import useSWR6 from "swr";
|
|
14458
14673
|
|
|
14459
14674
|
// src/providers/LegacyModeProvider/LegacyModeProvider.tsx
|
|
14460
14675
|
import { createContext as createContext11, useContext as useContext18, useMemo as useMemo11 } from "react";
|
|
@@ -14491,7 +14706,7 @@ var getBookkeepingStatus = get(({ businessId }) => {
|
|
|
14491
14706
|
});
|
|
14492
14707
|
var BOOKKEEPING_TAG_KEY = "#bookkeeping";
|
|
14493
14708
|
var BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
|
|
14494
|
-
function
|
|
14709
|
+
function buildKey9({
|
|
14495
14710
|
access_token: accessToken,
|
|
14496
14711
|
apiUrl,
|
|
14497
14712
|
businessId
|
|
@@ -14508,8 +14723,8 @@ function buildKey5({
|
|
|
14508
14723
|
function useBookkeepingStatus() {
|
|
14509
14724
|
const { data: auth } = useAuth();
|
|
14510
14725
|
const { businessId } = useLayerContext();
|
|
14511
|
-
return
|
|
14512
|
-
() =>
|
|
14726
|
+
return useSWR6(
|
|
14727
|
+
() => buildKey9(__spreadProps(__spreadValues({}, auth), {
|
|
14513
14728
|
businessId
|
|
14514
14729
|
})),
|
|
14515
14730
|
({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingStatus(
|
|
@@ -15080,9 +15295,9 @@ var Textarea = (_a) => {
|
|
|
15080
15295
|
import { useForm } from "@tanstack/react-form";
|
|
15081
15296
|
|
|
15082
15297
|
// src/hooks/useBankTransactions/useBankTransactionsMetadata.ts
|
|
15083
|
-
import
|
|
15298
|
+
import useSWR7 from "swr";
|
|
15084
15299
|
var GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
|
|
15085
|
-
function
|
|
15300
|
+
function buildKey10({
|
|
15086
15301
|
access_token: accessToken,
|
|
15087
15302
|
apiUrl,
|
|
15088
15303
|
businessId,
|
|
@@ -15101,8 +15316,8 @@ function buildKey6({
|
|
|
15101
15316
|
function useBankTransactionMetadata({ bankTransactionId }) {
|
|
15102
15317
|
const { data: auth } = useAuth();
|
|
15103
15318
|
const { businessId } = useLayerContext();
|
|
15104
|
-
return
|
|
15105
|
-
() =>
|
|
15319
|
+
return useSWR7(
|
|
15320
|
+
() => buildKey10(__spreadProps(__spreadValues({}, auth), {
|
|
15106
15321
|
businessId,
|
|
15107
15322
|
bankTransactionId
|
|
15108
15323
|
})),
|
|
@@ -15115,21 +15330,11 @@ function useBankTransactionMetadata({ bankTransactionId }) {
|
|
|
15115
15330
|
}
|
|
15116
15331
|
|
|
15117
15332
|
// 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";
|
|
15333
|
+
import useSWRMutation5 from "swr/mutation";
|
|
15334
|
+
import { useSWRConfig as useSWRConfig3 } from "swr";
|
|
15335
|
+
import { useCallback as useCallback5 } from "react";
|
|
15131
15336
|
var UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
|
|
15132
|
-
function
|
|
15337
|
+
function buildKey11({
|
|
15133
15338
|
access_token: accessToken,
|
|
15134
15339
|
apiUrl,
|
|
15135
15340
|
businessId,
|
|
@@ -15148,9 +15353,9 @@ function buildKey7({
|
|
|
15148
15353
|
function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
|
|
15149
15354
|
const { data: auth } = useAuth();
|
|
15150
15355
|
const { businessId } = useLayerContext();
|
|
15151
|
-
const { mutate } =
|
|
15152
|
-
const mutationResponse =
|
|
15153
|
-
() =>
|
|
15356
|
+
const { mutate } = useSWRConfig3();
|
|
15357
|
+
const mutationResponse = useSWRMutation5(
|
|
15358
|
+
() => buildKey11({
|
|
15154
15359
|
access_token: auth == null ? void 0 : auth.access_token,
|
|
15155
15360
|
apiUrl: auth == null ? void 0 : auth.apiUrl,
|
|
15156
15361
|
businessId,
|
|
@@ -15176,18 +15381,19 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
|
|
|
15176
15381
|
}
|
|
15177
15382
|
);
|
|
15178
15383
|
const { trigger: originalTrigger } = mutationResponse;
|
|
15179
|
-
const stableProxiedTrigger =
|
|
15180
|
-
(...triggerParameters) => __async(
|
|
15181
|
-
const
|
|
15182
|
-
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
}
|
|
15188
|
-
return result;
|
|
15384
|
+
const stableProxiedTrigger = useCallback5(
|
|
15385
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
15386
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
15387
|
+
void mutate((key) => withSWRKeyTags(
|
|
15388
|
+
key,
|
|
15389
|
+
(tags) => tags.includes(GET_BANK_TRANSACTION_METADATA_TAG_KEY)
|
|
15390
|
+
));
|
|
15391
|
+
return triggerResult;
|
|
15189
15392
|
}),
|
|
15190
|
-
[
|
|
15393
|
+
[
|
|
15394
|
+
originalTrigger,
|
|
15395
|
+
mutate
|
|
15396
|
+
]
|
|
15191
15397
|
);
|
|
15192
15398
|
return new Proxy(mutationResponse, {
|
|
15193
15399
|
get(target, prop) {
|
|
@@ -15207,7 +15413,7 @@ var useBankTransactionMemo = ({ bankTransactionId }) => {
|
|
|
15207
15413
|
defaultValues: {
|
|
15208
15414
|
memo: bankTransactionMetadata == null ? void 0 : bankTransactionMetadata.memo
|
|
15209
15415
|
},
|
|
15210
|
-
onSubmit: (_0) => __async(
|
|
15416
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
15211
15417
|
var _a;
|
|
15212
15418
|
if (value.memo !== void 0 && form.state.isDirty) {
|
|
15213
15419
|
yield updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" });
|
|
@@ -15394,7 +15600,7 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15394
15600
|
updateRowState(__spreadValues({}, rowState));
|
|
15395
15601
|
setSplitFormError(void 0);
|
|
15396
15602
|
};
|
|
15397
|
-
const save = () => __async(
|
|
15603
|
+
const save = () => __async(null, null, function* () {
|
|
15398
15604
|
if (purpose === "match" /* match */) {
|
|
15399
15605
|
if (!selectedMatchId) {
|
|
15400
15606
|
setMatchFormError("Select an option to match the transaction");
|
|
@@ -15434,7 +15640,7 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15434
15640
|
useImperativeHandle2(ref, () => ({
|
|
15435
15641
|
save
|
|
15436
15642
|
}));
|
|
15437
|
-
const onMatchSubmit = (matchId) => __async(
|
|
15643
|
+
const onMatchSubmit = (matchId) => __async(null, null, function* () {
|
|
15438
15644
|
var _a2;
|
|
15439
15645
|
const foundMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
|
|
15440
15646
|
(x) => x.id === matchId
|
|
@@ -15445,11 +15651,11 @@ var ExpandedBankTransactionRow = forwardRef12(
|
|
|
15445
15651
|
yield matchBankTransaction2(bankTransaction.id, foundMatch.id);
|
|
15446
15652
|
close2();
|
|
15447
15653
|
});
|
|
15448
|
-
const getDivHeight =
|
|
15654
|
+
const getDivHeight = useCallback6(() => {
|
|
15449
15655
|
const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
|
|
15450
15656
|
return height2 || 0;
|
|
15451
15657
|
}, []);
|
|
15452
|
-
const handleTransitionEnd =
|
|
15658
|
+
const handleTransitionEnd = useCallback6(
|
|
15453
15659
|
(e) => {
|
|
15454
15660
|
if (e.propertyName === "height") {
|
|
15455
15661
|
setHeight(isOpen ? "auto" : 0);
|
|
@@ -15947,7 +16153,7 @@ var BankTransactionRow = ({
|
|
|
15947
16153
|
}, 300);
|
|
15948
16154
|
}
|
|
15949
16155
|
}, [bankTransaction.recently_categorized]);
|
|
15950
|
-
const save = () => __async(
|
|
16156
|
+
const save = () => __async(null, null, function* () {
|
|
15951
16157
|
var _a2;
|
|
15952
16158
|
if (open2 && (expandedRowRef == null ? void 0 : expandedRowRef.current)) {
|
|
15953
16159
|
(_a2 = expandedRowRef == null ? void 0 : expandedRowRef.current) == null ? void 0 : _a2.save();
|
|
@@ -16762,7 +16968,7 @@ var MatchForm2 = ({
|
|
|
16762
16968
|
setShowRetry(false);
|
|
16763
16969
|
}
|
|
16764
16970
|
}, [bankTransaction.error]);
|
|
16765
|
-
const onMatchSubmit = (matchId) => __async(
|
|
16971
|
+
const onMatchSubmit = (matchId) => __async(null, null, function* () {
|
|
16766
16972
|
var _a2;
|
|
16767
16973
|
const foundMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
|
|
16768
16974
|
(x) => x.id === matchId
|
|
@@ -16772,7 +16978,7 @@ var MatchForm2 = ({
|
|
|
16772
16978
|
}
|
|
16773
16979
|
yield matchBankTransaction2(bankTransaction.id, foundMatch.id, true);
|
|
16774
16980
|
});
|
|
16775
|
-
const save = () => __async(
|
|
16981
|
+
const save = () => __async(null, null, function* () {
|
|
16776
16982
|
if (!showCategorization) {
|
|
16777
16983
|
return;
|
|
16778
16984
|
}
|
|
@@ -16962,7 +17168,7 @@ var SplitForm = ({
|
|
|
16962
17168
|
});
|
|
16963
17169
|
return valid;
|
|
16964
17170
|
};
|
|
16965
|
-
const save = () => __async(
|
|
17171
|
+
const save = () => __async(null, null, function* () {
|
|
16966
17172
|
if (!validateSplit2(rowState)) {
|
|
16967
17173
|
if (rowState.splits.length > 1) {
|
|
16968
17174
|
setFormError(
|
|
@@ -17877,7 +18083,7 @@ var PaginationContent = ({
|
|
|
17877
18083
|
};
|
|
17878
18084
|
|
|
17879
18085
|
// src/components/BankTransactions/BankTransactionsHeader.tsx
|
|
17880
|
-
import { useCallback as
|
|
18086
|
+
import { useCallback as useCallback8, useState as useState34 } from "react";
|
|
17881
18087
|
import classNames50 from "classnames";
|
|
17882
18088
|
import { endOfMonth as endOfMonth5, startOfMonth as startOfMonth5 } from "date-fns";
|
|
17883
18089
|
|
|
@@ -17953,8 +18159,8 @@ function TransactionsActions({ children }) {
|
|
|
17953
18159
|
}
|
|
17954
18160
|
|
|
17955
18161
|
// src/hooks/useBankTransactions/useBankTransactionsDownload.ts
|
|
17956
|
-
import
|
|
17957
|
-
function
|
|
18162
|
+
import useSWRMutation6 from "swr/mutation";
|
|
18163
|
+
function buildKey12({
|
|
17958
18164
|
access_token: accessToken,
|
|
17959
18165
|
apiUrl,
|
|
17960
18166
|
businessId
|
|
@@ -17971,8 +18177,8 @@ function buildKey8({
|
|
|
17971
18177
|
function useBankTransactionsDownload() {
|
|
17972
18178
|
const { data } = useAuth();
|
|
17973
18179
|
const { businessId } = useLayerContext();
|
|
17974
|
-
return
|
|
17975
|
-
() =>
|
|
18180
|
+
return useSWRMutation6(
|
|
18181
|
+
() => buildKey12(__spreadProps(__spreadValues({}, data), {
|
|
17976
18182
|
businessId
|
|
17977
18183
|
})),
|
|
17978
18184
|
({
|
|
@@ -18013,7 +18219,7 @@ function useBankTransactionsDownload() {
|
|
|
18013
18219
|
}
|
|
18014
18220
|
|
|
18015
18221
|
// src/components/utility/InvisibleDownload.tsx
|
|
18016
|
-
import { forwardRef as forwardRef13, useCallback as
|
|
18222
|
+
import { forwardRef as forwardRef13, useCallback as useCallback7, useImperativeHandle as useImperativeHandle3, useRef as useRef18 } from "react";
|
|
18017
18223
|
|
|
18018
18224
|
// src/utils/delay/runDelayed.ts
|
|
18019
18225
|
var DEFAULT_DELAY_MS = 50;
|
|
@@ -18027,7 +18233,7 @@ function runDelayedSync(block, delayMs = DEFAULT_DELAY_MS) {
|
|
|
18027
18233
|
import { jsx as jsx148 } from "react/jsx-runtime";
|
|
18028
18234
|
function useInvisibleDownload() {
|
|
18029
18235
|
const invisibleDownloadRef = useRef18(null);
|
|
18030
|
-
const triggerInvisibleDownload =
|
|
18236
|
+
const triggerInvisibleDownload = useCallback7((options) => {
|
|
18031
18237
|
var _a;
|
|
18032
18238
|
void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options));
|
|
18033
18239
|
}, []);
|
|
@@ -18037,7 +18243,7 @@ var CLASS_NAME9 = "Layer__InvisibleDownload";
|
|
|
18037
18243
|
var InvisibleDownload = forwardRef13((_props, ref) => {
|
|
18038
18244
|
const internalRef = useRef18(null);
|
|
18039
18245
|
useImperativeHandle3(ref, () => ({
|
|
18040
|
-
trigger: (_0) => __async(
|
|
18246
|
+
trigger: (_0) => __async(null, [_0], function* ({ url }) {
|
|
18041
18247
|
var _a;
|
|
18042
18248
|
(_a = internalRef.current) == null ? void 0 : _a.setAttribute("href", url);
|
|
18043
18249
|
return runDelayedSync(() => {
|
|
@@ -18046,7 +18252,7 @@ var InvisibleDownload = forwardRef13((_props, ref) => {
|
|
|
18046
18252
|
});
|
|
18047
18253
|
})
|
|
18048
18254
|
}));
|
|
18049
|
-
const handleContainClick =
|
|
18255
|
+
const handleContainClick = useCallback7((event) => {
|
|
18050
18256
|
event.stopPropagation();
|
|
18051
18257
|
}, []);
|
|
18052
18258
|
return /* @__PURE__ */ jsx148("a", { download: true, className: CLASS_NAME9, ref: internalRef, onClick: handleContainClick });
|
|
@@ -18065,7 +18271,7 @@ function TransactionsSearch({ slot }) {
|
|
|
18065
18271
|
const debouncedSetDescription = useDebounce((value) => {
|
|
18066
18272
|
setFilters({ descriptionFilter: value });
|
|
18067
18273
|
});
|
|
18068
|
-
const handleSearch =
|
|
18274
|
+
const handleSearch = useCallback8((value) => {
|
|
18069
18275
|
setLocalSearch(value);
|
|
18070
18276
|
void debouncedSetDescription(value);
|
|
18071
18277
|
}, [debouncedSetDescription]);
|
|
@@ -18731,7 +18937,7 @@ var IntegrationsContent = () => {
|
|
|
18731
18937
|
};
|
|
18732
18938
|
|
|
18733
18939
|
// src/hooks/useQuickbooks/useQuickbooks.ts
|
|
18734
|
-
import { useCallback as
|
|
18940
|
+
import { useCallback as useCallback9, useEffect as useEffect24, useRef as useRef20, useState as useState36 } from "react";
|
|
18735
18941
|
var useQuickbooks = () => {
|
|
18736
18942
|
const { businessId } = useLayerContext();
|
|
18737
18943
|
const { apiUrl } = useEnvironment();
|
|
@@ -18740,13 +18946,13 @@ var useQuickbooks = () => {
|
|
|
18740
18946
|
const [quickbooksConnectionStatus, setQuickbooksConnectionStatus] = useState36(void 0);
|
|
18741
18947
|
const syncStatusIntervalRef = useRef20(null);
|
|
18742
18948
|
const wasSyncingFromQuickbooksRef = useRef20(false);
|
|
18743
|
-
const fetchQuickbooksConnectionStatus =
|
|
18949
|
+
const fetchQuickbooksConnectionStatus = useCallback9(() => __async(null, null, function* () {
|
|
18744
18950
|
const newQuickbooksConnectionStatus = (yield Layer.statusOfQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18745
18951
|
params: { businessId }
|
|
18746
18952
|
})()).data;
|
|
18747
18953
|
setQuickbooksConnectionStatus(newQuickbooksConnectionStatus);
|
|
18748
18954
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setQuickbooksConnectionStatus]);
|
|
18749
|
-
const fetchIsSyncingFromQuickbooks =
|
|
18955
|
+
const fetchIsSyncingFromQuickbooks = useCallback9(() => __async(null, null, function* () {
|
|
18750
18956
|
const isSyncing = (yield Layer.statusOfSyncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18751
18957
|
params: { businessId }
|
|
18752
18958
|
})()).data.is_syncing;
|
|
@@ -18772,20 +18978,20 @@ var useQuickbooks = () => {
|
|
|
18772
18978
|
void fetchQuickbooksConnectionStatus();
|
|
18773
18979
|
}
|
|
18774
18980
|
}, [auth == null ? void 0 : auth.access_token, fetchQuickbooksConnectionStatus]);
|
|
18775
|
-
const syncFromQuickbooks2 =
|
|
18981
|
+
const syncFromQuickbooks2 = useCallback9(() => {
|
|
18776
18982
|
setIsSyncingFromQuickbooks(true);
|
|
18777
18983
|
wasSyncingFromQuickbooksRef.current = true;
|
|
18778
18984
|
void Layer.syncFromQuickbooks(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18779
18985
|
params: { businessId }
|
|
18780
18986
|
});
|
|
18781
18987
|
}, [apiUrl, auth == null ? void 0 : auth.access_token, businessId, setIsSyncingFromQuickbooks]);
|
|
18782
|
-
const linkQuickbooks =
|
|
18988
|
+
const linkQuickbooks = useCallback9(() => __async(null, null, function* () {
|
|
18783
18989
|
const res = yield Layer.initQuickbooksOAuth(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18784
18990
|
params: { businessId }
|
|
18785
18991
|
});
|
|
18786
18992
|
return res.data.redirect_url;
|
|
18787
18993
|
}), [apiUrl, auth == null ? void 0 : auth.access_token, businessId]);
|
|
18788
|
-
const unlinkQuickbooks =
|
|
18994
|
+
const unlinkQuickbooks = useCallback9(() => {
|
|
18789
18995
|
void Layer.unlinkQuickbooksConnection(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
18790
18996
|
params: { businessId }
|
|
18791
18997
|
}).then(() => fetchQuickbooksConnectionStatus());
|
|
@@ -18808,7 +19014,7 @@ function QuickbooksContextProvider({ children }) {
|
|
|
18808
19014
|
}
|
|
18809
19015
|
|
|
18810
19016
|
// src/components/Integrations/IntegrationsConnectMenu/IntegrationsConnectMenu.tsx
|
|
18811
|
-
import { useCallback as
|
|
19017
|
+
import { useCallback as useCallback10, useContext as useContext24 } from "react";
|
|
18812
19018
|
|
|
18813
19019
|
// src/components/ui/DropdownMenu/DropdownMenu.tsx
|
|
18814
19020
|
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 +19070,7 @@ var IntegrationsConnectMenu = () => {
|
|
|
18864
19070
|
quickbooksIsConnected,
|
|
18865
19071
|
linkQuickbooks
|
|
18866
19072
|
} = useContext24(QuickbooksContext);
|
|
18867
|
-
const initiateQuickbooksOAuth =
|
|
19073
|
+
const initiateQuickbooksOAuth = useCallback10(() => __async(null, null, function* () {
|
|
18868
19074
|
const authorizationUrl = yield linkQuickbooks();
|
|
18869
19075
|
window.location.href = authorizationUrl;
|
|
18870
19076
|
}), [linkQuickbooks]);
|
|
@@ -18949,7 +19155,7 @@ var Quickbooks = () => {
|
|
|
18949
19155
|
quickbooksIsConnected === false && /* @__PURE__ */ jsx165(
|
|
18950
19156
|
"button",
|
|
18951
19157
|
{
|
|
18952
|
-
onClick: () => __async(
|
|
19158
|
+
onClick: () => __async(null, null, function* () {
|
|
18953
19159
|
const authorizationUrl = yield linkQuickbooks();
|
|
18954
19160
|
window.location.href = authorizationUrl;
|
|
18955
19161
|
}),
|
|
@@ -18989,7 +19195,7 @@ var PNLComparisonContext = createContext14({
|
|
|
18989
19195
|
});
|
|
18990
19196
|
|
|
18991
19197
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
18992
|
-
import { useCallback as
|
|
19198
|
+
import { useCallback as useCallback11, useMemo as useMemo22, useState as useState38 } from "react";
|
|
18993
19199
|
|
|
18994
19200
|
// src/utils/profitAndLossUtils.ts
|
|
18995
19201
|
var doesLineItemQualifies = (item) => {
|
|
@@ -19047,7 +19253,7 @@ var applyShare = (items, total) => {
|
|
|
19047
19253
|
// src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
|
|
19048
19254
|
import { useEffect as useEffect25, useMemo as useMemo21, useState as useState37 } from "react";
|
|
19049
19255
|
import { startOfMonth as startOfMonth7, sub } from "date-fns";
|
|
19050
|
-
import
|
|
19256
|
+
import useSWR8 from "swr";
|
|
19051
19257
|
var buildDates = ({ currentDate }) => {
|
|
19052
19258
|
return {
|
|
19053
19259
|
startYear: startOfMonth7(currentDate).getFullYear() - 1,
|
|
@@ -19088,7 +19294,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19088
19294
|
isValidating,
|
|
19089
19295
|
error,
|
|
19090
19296
|
mutate
|
|
19091
|
-
} =
|
|
19297
|
+
} = useSWR8(
|
|
19092
19298
|
queryKey,
|
|
19093
19299
|
Layer.getProfitAndLossSummaries(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19094
19300
|
params: {
|
|
@@ -19201,7 +19407,7 @@ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
|
|
|
19201
19407
|
// src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
|
|
19202
19408
|
import { useEffect as useEffect26 } from "react";
|
|
19203
19409
|
import { startOfMonth as startOfMonth8, endOfMonth as endOfMonth7 } from "date-fns";
|
|
19204
|
-
import
|
|
19410
|
+
import useSWR9 from "swr";
|
|
19205
19411
|
var useProfitAndLossQuery = ({
|
|
19206
19412
|
startDate,
|
|
19207
19413
|
endDate,
|
|
@@ -19224,7 +19430,7 @@ var useProfitAndLossQuery = ({
|
|
|
19224
19430
|
isValidating,
|
|
19225
19431
|
error: rawError,
|
|
19226
19432
|
mutate
|
|
19227
|
-
} =
|
|
19433
|
+
} = useSWR9(
|
|
19228
19434
|
queryKey,
|
|
19229
19435
|
Layer.getProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19230
19436
|
businessId,
|
|
@@ -19267,7 +19473,7 @@ var useProfitAndLoss = ({
|
|
|
19267
19473
|
const { start, end } = useGlobalDateRange();
|
|
19268
19474
|
const { setRange } = useGlobalDateRangeActions();
|
|
19269
19475
|
const dateRange = useMemo22(() => ({ startDate: start, endDate: end }), [start, end]);
|
|
19270
|
-
const changeDateRange =
|
|
19476
|
+
const changeDateRange = useCallback11(
|
|
19271
19477
|
({ startDate: start2, endDate: end2 }) => setRange({ start: start2, end: end2 }),
|
|
19272
19478
|
[setRange]
|
|
19273
19479
|
);
|
|
@@ -19551,14 +19757,14 @@ function preparePeriodsBody(dateRange, comparePeriods, rangeDisplayMode) {
|
|
|
19551
19757
|
}
|
|
19552
19758
|
|
|
19553
19759
|
// src/hooks/useProfitAndLossComparison/useProfitAndLossComparison.tsx
|
|
19554
|
-
import
|
|
19760
|
+
import useSWR10 from "swr";
|
|
19555
19761
|
var COMPARE_MODES_SUPPORTING_MULTI_PERIOD = ["monthPicker", "yearPicker"];
|
|
19556
19762
|
var isNotOnlyNoneTag = (compareOptions) => {
|
|
19557
19763
|
return Boolean(
|
|
19558
19764
|
compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
|
|
19559
19765
|
);
|
|
19560
19766
|
};
|
|
19561
|
-
function
|
|
19767
|
+
function buildKey13({
|
|
19562
19768
|
access_token: accessToken,
|
|
19563
19769
|
apiUrl,
|
|
19564
19770
|
businessId,
|
|
@@ -19608,16 +19814,16 @@ function useProfitAndLossComparison({
|
|
|
19608
19814
|
const { data: auth } = useAuth();
|
|
19609
19815
|
const periods = preparePeriodsBody(dateRange, effectiveComparePeriods, rangeDisplayMode);
|
|
19610
19816
|
const tagFilters = prepareFiltersBody(selectedCompareOptions);
|
|
19611
|
-
const queryKey =
|
|
19817
|
+
const queryKey = buildKey13(__spreadProps(__spreadValues({}, auth), {
|
|
19612
19818
|
businessId,
|
|
19613
19819
|
periods,
|
|
19614
19820
|
tagFilters,
|
|
19615
19821
|
reportingBasis,
|
|
19616
19822
|
compareModeActive
|
|
19617
19823
|
}));
|
|
19618
|
-
const { data, isLoading, isValidating } =
|
|
19824
|
+
const { data, isLoading, isValidating } = useSWR10(
|
|
19619
19825
|
queryKey,
|
|
19620
|
-
() => __async(
|
|
19826
|
+
() => __async(null, null, function* () {
|
|
19621
19827
|
const response = yield Layer.compareProfitAndLoss(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
19622
19828
|
params: {
|
|
19623
19829
|
businessId
|
|
@@ -21512,7 +21718,7 @@ var ProfitAndLossDownloadButton = ({
|
|
|
21512
21718
|
const { data: auth } = useAuth();
|
|
21513
21719
|
const [requestFailed, setRequestFailed] = useState42(false);
|
|
21514
21720
|
const [isDownloading, setIsDownloading] = useState42(false);
|
|
21515
|
-
const handleClick = () => __async(
|
|
21721
|
+
const handleClick = () => __async(null, null, function* () {
|
|
21516
21722
|
var _a;
|
|
21517
21723
|
setIsDownloading(true);
|
|
21518
21724
|
const getProfitAndLossExcel2 = Layer.getProfitAndLossExcel(
|
|
@@ -21575,7 +21781,7 @@ var SyncingBadge = () => {
|
|
|
21575
21781
|
import { useMemo as useMemo28 } from "react";
|
|
21576
21782
|
|
|
21577
21783
|
// src/hooks/bookkeeping/periods/useBookkeepingPeriods.ts
|
|
21578
|
-
import
|
|
21784
|
+
import useSWR11 from "swr";
|
|
21579
21785
|
|
|
21580
21786
|
// src/utils/bookkeeping/bookkeepingStatusFilters.ts
|
|
21581
21787
|
function isActiveBookkeepingStatus(status) {
|
|
@@ -21633,7 +21839,7 @@ var getBookkeepingPeriods = get(({ businessId }) => {
|
|
|
21633
21839
|
return `/v1/businesses/${businessId}/bookkeeping/periods`;
|
|
21634
21840
|
});
|
|
21635
21841
|
var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
|
|
21636
|
-
function
|
|
21842
|
+
function buildKey14({
|
|
21637
21843
|
access_token: accessToken,
|
|
21638
21844
|
apiUrl,
|
|
21639
21845
|
businessId,
|
|
@@ -21653,8 +21859,8 @@ function useBookkeepingPeriods() {
|
|
|
21653
21859
|
const { businessId } = useLayerContext();
|
|
21654
21860
|
const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
|
|
21655
21861
|
const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
|
|
21656
|
-
const swrResponse =
|
|
21657
|
-
() =>
|
|
21862
|
+
const swrResponse = useSWR11(
|
|
21863
|
+
() => buildKey14(__spreadProps(__spreadValues({}, auth), {
|
|
21658
21864
|
businessId,
|
|
21659
21865
|
isActiveOrPaused
|
|
21660
21866
|
})),
|
|
@@ -23089,9 +23295,9 @@ ProfitAndLoss.Report = ProfitAndLossReport;
|
|
|
23089
23295
|
ProfitAndLoss.DownloadButton = ProfitAndLossDownloadButton;
|
|
23090
23296
|
|
|
23091
23297
|
// src/hooks/balanceSheet/useBalanceSheet.ts
|
|
23092
|
-
import
|
|
23298
|
+
import useSWR12 from "swr";
|
|
23093
23299
|
import { endOfDay as endOfDay3 } from "date-fns";
|
|
23094
|
-
function
|
|
23300
|
+
function buildKey15({
|
|
23095
23301
|
access_token: accessToken,
|
|
23096
23302
|
apiUrl,
|
|
23097
23303
|
businessId,
|
|
@@ -23113,8 +23319,8 @@ function useBalanceSheet({
|
|
|
23113
23319
|
const { data: auth } = useAuth();
|
|
23114
23320
|
const { apiUrl } = useEnvironment();
|
|
23115
23321
|
const { businessId } = useLayerContext();
|
|
23116
|
-
return
|
|
23117
|
-
() =>
|
|
23322
|
+
return useSWR12(
|
|
23323
|
+
() => buildKey15(__spreadProps(__spreadValues({}, auth), {
|
|
23118
23324
|
apiUrl,
|
|
23119
23325
|
businessId,
|
|
23120
23326
|
effectiveDate
|
|
@@ -23306,8 +23512,8 @@ var BALANCE_SHEET_ROWS = [
|
|
|
23306
23512
|
];
|
|
23307
23513
|
|
|
23308
23514
|
// src/components/BalanceSheet/download/useBalanceSheetDownload.ts
|
|
23309
|
-
import
|
|
23310
|
-
function
|
|
23515
|
+
import useSWRMutation7 from "swr/mutation";
|
|
23516
|
+
function buildKey16({
|
|
23311
23517
|
access_token: accessToken,
|
|
23312
23518
|
apiUrl,
|
|
23313
23519
|
businessId,
|
|
@@ -23329,8 +23535,8 @@ function useBalanceSheetDownload({
|
|
|
23329
23535
|
}) {
|
|
23330
23536
|
const { data: auth } = useAuth();
|
|
23331
23537
|
const { businessId } = useLayerContext();
|
|
23332
|
-
return
|
|
23333
|
-
() =>
|
|
23538
|
+
return useSWRMutation7(
|
|
23539
|
+
() => buildKey16(__spreadProps(__spreadValues({}, auth), {
|
|
23334
23540
|
businessId,
|
|
23335
23541
|
effectiveDate
|
|
23336
23542
|
})),
|
|
@@ -23590,8 +23796,8 @@ var STATEMENT_OF_CASH_FLOW_ROWS = [
|
|
|
23590
23796
|
];
|
|
23591
23797
|
|
|
23592
23798
|
// src/components/StatementOfCashFlow/download/useCashflowStatementDownload.ts
|
|
23593
|
-
import
|
|
23594
|
-
function
|
|
23799
|
+
import useSWRMutation8 from "swr/mutation";
|
|
23800
|
+
function buildKey17({
|
|
23595
23801
|
access_token: accessToken,
|
|
23596
23802
|
apiUrl,
|
|
23597
23803
|
businessId,
|
|
@@ -23616,8 +23822,8 @@ function useCashflowStatementDownload({
|
|
|
23616
23822
|
}) {
|
|
23617
23823
|
const { data: auth } = useAuth();
|
|
23618
23824
|
const { businessId } = useLayerContext();
|
|
23619
|
-
return
|
|
23620
|
-
() =>
|
|
23825
|
+
return useSWRMutation8(
|
|
23826
|
+
() => buildKey17(__spreadProps(__spreadValues({}, auth), {
|
|
23621
23827
|
businessId,
|
|
23622
23828
|
startDate,
|
|
23623
23829
|
endDate
|
|
@@ -23724,9 +23930,9 @@ function StatementOfCashFlowDatePicker({
|
|
|
23724
23930
|
}
|
|
23725
23931
|
|
|
23726
23932
|
// src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
|
|
23727
|
-
import
|
|
23933
|
+
import useSWR13 from "swr";
|
|
23728
23934
|
import { endOfMonth as endOfMonth10, startOfMonth as startOfMonth13 } from "date-fns";
|
|
23729
|
-
function
|
|
23935
|
+
function buildKey18({
|
|
23730
23936
|
access_token: accessToken,
|
|
23731
23937
|
apiUrl,
|
|
23732
23938
|
businessId,
|
|
@@ -23751,8 +23957,8 @@ function useStatementOfCashFlow({
|
|
|
23751
23957
|
const { data: auth } = useAuth();
|
|
23752
23958
|
const { apiUrl } = useEnvironment();
|
|
23753
23959
|
const { businessId } = useLayerContext();
|
|
23754
|
-
return
|
|
23755
|
-
|
|
23960
|
+
return useSWR13(
|
|
23961
|
+
buildKey18(__spreadProps(__spreadValues({}, auth), {
|
|
23756
23962
|
apiUrl,
|
|
23757
23963
|
businessId,
|
|
23758
23964
|
startDate,
|
|
@@ -24085,7 +24291,7 @@ var LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
|
|
|
24085
24291
|
|
|
24086
24292
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
24087
24293
|
import { endOfMonth as endOfMonth12, formatISO as formatISO3, startOfMonth as startOfMonth15 } from "date-fns";
|
|
24088
|
-
import
|
|
24294
|
+
import useSWR14 from "swr";
|
|
24089
24295
|
var validate = (formData) => {
|
|
24090
24296
|
const errors = [];
|
|
24091
24297
|
const nameError = validateName(formData);
|
|
@@ -24190,7 +24396,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24190
24396
|
initialEndDate != null ? initialEndDate : endOfMonth12(Date.now())
|
|
24191
24397
|
);
|
|
24192
24398
|
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 } =
|
|
24399
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR14(
|
|
24194
24400
|
queryKey,
|
|
24195
24401
|
Layer.getLedgerAccountBalances(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24196
24402
|
params: {
|
|
@@ -24200,7 +24406,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24200
24406
|
}
|
|
24201
24407
|
})
|
|
24202
24408
|
);
|
|
24203
|
-
const create = (newAccount) => __async(
|
|
24409
|
+
const create = (newAccount) => __async(null, null, function* () {
|
|
24204
24410
|
setSendingForm(true);
|
|
24205
24411
|
setApiError(void 0);
|
|
24206
24412
|
try {
|
|
@@ -24217,7 +24423,7 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24217
24423
|
touch("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */);
|
|
24218
24424
|
}
|
|
24219
24425
|
});
|
|
24220
|
-
const update = (accountData, accountId) => __async(
|
|
24426
|
+
const update = (accountData, accountId) => __async(null, null, function* () {
|
|
24221
24427
|
setSendingForm(true);
|
|
24222
24428
|
setApiError(void 0);
|
|
24223
24429
|
const newAccountData = __spreadValues({}, accountData);
|
|
@@ -24399,13 +24605,13 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
|
|
|
24399
24605
|
};
|
|
24400
24606
|
|
|
24401
24607
|
// src/hooks/useChartOfAccounts/useCreateChildAccount.tsx
|
|
24402
|
-
import
|
|
24403
|
-
import { useSWRConfig as
|
|
24404
|
-
import { useCallback as
|
|
24608
|
+
import useSWRMutation9 from "swr/mutation";
|
|
24609
|
+
import { useSWRConfig as useSWRConfig4 } from "swr";
|
|
24610
|
+
import { useCallback as useCallback12 } from "react";
|
|
24405
24611
|
|
|
24406
24612
|
// src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
|
|
24407
24613
|
import { useEffect as useEffect35, useState as useState48 } from "react";
|
|
24408
|
-
import
|
|
24614
|
+
import useSWR15 from "swr";
|
|
24409
24615
|
var useLedgerAccounts = (showReversalEntries = false) => {
|
|
24410
24616
|
const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
|
|
24411
24617
|
const { apiUrl } = useEnvironment();
|
|
@@ -24413,7 +24619,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24413
24619
|
const [accountId, setAccountId] = useState48();
|
|
24414
24620
|
const [selectedEntryId, setSelectedEntryId] = useState48();
|
|
24415
24621
|
const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
|
|
24416
|
-
const { data, isLoading, isValidating, error, mutate } =
|
|
24622
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR15(
|
|
24417
24623
|
queryKey,
|
|
24418
24624
|
Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24419
24625
|
params: {
|
|
@@ -24429,7 +24635,7 @@ var useLedgerAccounts = (showReversalEntries = false) => {
|
|
|
24429
24635
|
isLoading: isLoadingEntry,
|
|
24430
24636
|
isValidating: isValdiatingEntry,
|
|
24431
24637
|
error: errorEntry
|
|
24432
|
-
} =
|
|
24638
|
+
} = useSWR15(
|
|
24433
24639
|
businessId && selectedEntryId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-entry-${businessId}-${selectedEntryId}}`,
|
|
24434
24640
|
Layer.getLedgerAccountsEntry(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
24435
24641
|
params: { businessId, entryId: selectedEntryId }
|
|
@@ -24946,8 +25152,8 @@ var ChartOfAccountsTableContent = ({
|
|
|
24946
25152
|
};
|
|
24947
25153
|
|
|
24948
25154
|
// src/components/ChartOfAccounts/download/useAccountBalancesDownload.ts
|
|
24949
|
-
import
|
|
24950
|
-
function
|
|
25155
|
+
import useSWRMutation10 from "swr/mutation";
|
|
25156
|
+
function buildKey19({
|
|
24951
25157
|
access_token: accessToken,
|
|
24952
25158
|
apiUrl,
|
|
24953
25159
|
businessId,
|
|
@@ -24972,8 +25178,8 @@ function useAccountBalancesDownload({
|
|
|
24972
25178
|
}) {
|
|
24973
25179
|
const { data: auth } = useAuth();
|
|
24974
25180
|
const { businessId } = useLayerContext();
|
|
24975
|
-
return
|
|
24976
|
-
() =>
|
|
25181
|
+
return useSWRMutation10(
|
|
25182
|
+
() => buildKey19(__spreadProps(__spreadValues({}, auth), {
|
|
24977
25183
|
businessId,
|
|
24978
25184
|
startCutoff,
|
|
24979
25185
|
endCutoff
|
|
@@ -25937,7 +26143,7 @@ var JournalContext = createContext19({
|
|
|
25937
26143
|
|
|
25938
26144
|
// src/hooks/useJournal/useJournal.tsx
|
|
25939
26145
|
import { useEffect as useEffect39, useState as useState53 } from "react";
|
|
25940
|
-
import
|
|
26146
|
+
import useSWR16 from "swr";
|
|
25941
26147
|
var useJournal = () => {
|
|
25942
26148
|
const {
|
|
25943
26149
|
businessId,
|
|
@@ -25954,7 +26160,7 @@ var useJournal = () => {
|
|
|
25954
26160
|
const [sendingForm, setSendingForm] = useState53(false);
|
|
25955
26161
|
const [apiError, setApiError] = useState53(void 0);
|
|
25956
26162
|
const queryKey = businessId && (auth == null ? void 0 : auth.access_token) && `journal-lines-${businessId}`;
|
|
25957
|
-
const { data, isLoading, isValidating, error, mutate } =
|
|
26163
|
+
const { data, isLoading, isValidating, error, mutate } = useSWR16(
|
|
25958
26164
|
queryKey,
|
|
25959
26165
|
Layer.getJournal(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
25960
26166
|
params: { businessId }
|
|
@@ -25964,7 +26170,7 @@ var useJournal = () => {
|
|
|
25964
26170
|
const closeSelectedEntry = () => {
|
|
25965
26171
|
setSelectedEntryId(void 0);
|
|
25966
26172
|
};
|
|
25967
|
-
const create = (newJournalEntry) => __async(
|
|
26173
|
+
const create = (newJournalEntry) => __async(null, null, function* () {
|
|
25968
26174
|
setSendingForm(true);
|
|
25969
26175
|
setApiError(void 0);
|
|
25970
26176
|
try {
|
|
@@ -26163,7 +26369,7 @@ var useJournal = () => {
|
|
|
26163
26369
|
})
|
|
26164
26370
|
}));
|
|
26165
26371
|
};
|
|
26166
|
-
const reverseEntry = (entryId) => __async(
|
|
26372
|
+
const reverseEntry = (entryId) => __async(null, null, function* () {
|
|
26167
26373
|
return Layer.reverseJournalEntry(apiUrl, auth == null ? void 0 : auth.access_token, {
|
|
26168
26374
|
params: { businessId, entryId }
|
|
26169
26375
|
});
|
|
@@ -26241,7 +26447,7 @@ var JournalEntryDetails = () => {
|
|
|
26241
26447
|
},
|
|
26242
26448
|
[entry == null ? void 0 : entry.line_items]
|
|
26243
26449
|
);
|
|
26244
|
-
const onReverseEntry = () => __async(
|
|
26450
|
+
const onReverseEntry = () => __async(null, null, function* () {
|
|
26245
26451
|
if (!entry) {
|
|
26246
26452
|
return;
|
|
26247
26453
|
}
|
|
@@ -26922,8 +27128,8 @@ var JournalTableContent = ({
|
|
|
26922
27128
|
};
|
|
26923
27129
|
|
|
26924
27130
|
// src/components/Journal/download/useJournalEntriesDownload.ts
|
|
26925
|
-
import
|
|
26926
|
-
function
|
|
27131
|
+
import useSWRMutation11 from "swr/mutation";
|
|
27132
|
+
function buildKey20({
|
|
26927
27133
|
access_token: accessToken,
|
|
26928
27134
|
apiUrl,
|
|
26929
27135
|
businessId,
|
|
@@ -26948,8 +27154,8 @@ function useJournalEntriesDownload({
|
|
|
26948
27154
|
}) {
|
|
26949
27155
|
const { data: auth } = useAuth();
|
|
26950
27156
|
const { businessId } = useLayerContext();
|
|
26951
|
-
return
|
|
26952
|
-
() =>
|
|
27157
|
+
return useSWRMutation11(
|
|
27158
|
+
() => buildKey20(__spreadProps(__spreadValues({}, auth), {
|
|
26953
27159
|
businessId,
|
|
26954
27160
|
startCutoff,
|
|
26955
27161
|
endCutoff
|
|
@@ -27247,8 +27453,8 @@ function getIconForTask(task) {
|
|
|
27247
27453
|
}
|
|
27248
27454
|
|
|
27249
27455
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27250
|
-
import { useSWRConfig as
|
|
27251
|
-
import
|
|
27456
|
+
import { useSWRConfig as useSWRConfig5 } from "swr";
|
|
27457
|
+
import useSWRMutation12 from "swr/mutation";
|
|
27252
27458
|
|
|
27253
27459
|
// src/api/layer/tasks.ts
|
|
27254
27460
|
var submitUserResponseForTask = post(
|
|
@@ -27281,8 +27487,8 @@ function completeTaskWithUpload(baseUrl, accessToken, {
|
|
|
27281
27487
|
}
|
|
27282
27488
|
|
|
27283
27489
|
// src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
|
|
27284
|
-
import { useCallback as
|
|
27285
|
-
function
|
|
27490
|
+
import { useCallback as useCallback13 } from "react";
|
|
27491
|
+
function buildKey21({
|
|
27286
27492
|
access_token: accessToken,
|
|
27287
27493
|
apiUrl,
|
|
27288
27494
|
businessId
|
|
@@ -27299,9 +27505,9 @@ function buildKey17({
|
|
|
27299
27505
|
function useSubmitUserResponseForTask() {
|
|
27300
27506
|
const { data: auth } = useAuth();
|
|
27301
27507
|
const { businessId } = useLayerContext();
|
|
27302
|
-
const { mutate } =
|
|
27303
|
-
const mutationResponse =
|
|
27304
|
-
() =>
|
|
27508
|
+
const { mutate } = useSWRConfig5();
|
|
27509
|
+
const mutationResponse = useSWRMutation12(
|
|
27510
|
+
() => buildKey21(__spreadProps(__spreadValues({}, auth), {
|
|
27305
27511
|
businessId
|
|
27306
27512
|
})),
|
|
27307
27513
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, userResponse } }) => submitUserResponseForTask(
|
|
@@ -27324,18 +27530,19 @@ function useSubmitUserResponseForTask() {
|
|
|
27324
27530
|
}
|
|
27325
27531
|
);
|
|
27326
27532
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27327
|
-
const stableProxiedTrigger =
|
|
27328
|
-
(...triggerParameters) => __async(
|
|
27329
|
-
const
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27333
|
-
|
|
27334
|
-
|
|
27335
|
-
}
|
|
27336
|
-
return result;
|
|
27533
|
+
const stableProxiedTrigger = useCallback13(
|
|
27534
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27535
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27536
|
+
void mutate((key) => withSWRKeyTags(
|
|
27537
|
+
key,
|
|
27538
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27539
|
+
));
|
|
27540
|
+
return triggerResult;
|
|
27337
27541
|
}),
|
|
27338
|
-
[
|
|
27542
|
+
[
|
|
27543
|
+
originalTrigger,
|
|
27544
|
+
mutate
|
|
27545
|
+
]
|
|
27339
27546
|
);
|
|
27340
27547
|
return new Proxy(mutationResponse, {
|
|
27341
27548
|
get(target, prop) {
|
|
@@ -27348,10 +27555,10 @@ function useSubmitUserResponseForTask() {
|
|
|
27348
27555
|
}
|
|
27349
27556
|
|
|
27350
27557
|
// src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
|
|
27351
|
-
import { useSWRConfig as
|
|
27352
|
-
import
|
|
27353
|
-
import { useCallback as
|
|
27354
|
-
function
|
|
27558
|
+
import { useSWRConfig as useSWRConfig6 } from "swr";
|
|
27559
|
+
import useSWRMutation13 from "swr/mutation";
|
|
27560
|
+
import { useCallback as useCallback14 } from "react";
|
|
27561
|
+
function buildKey22({
|
|
27355
27562
|
access_token: accessToken,
|
|
27356
27563
|
apiUrl,
|
|
27357
27564
|
businessId
|
|
@@ -27368,9 +27575,9 @@ function buildKey18({
|
|
|
27368
27575
|
function useUploadDocumentsForTask() {
|
|
27369
27576
|
const { data: auth } = useAuth();
|
|
27370
27577
|
const { businessId } = useLayerContext();
|
|
27371
|
-
const { mutate } =
|
|
27372
|
-
const mutationResponse =
|
|
27373
|
-
() =>
|
|
27578
|
+
const { mutate } = useSWRConfig6();
|
|
27579
|
+
const mutationResponse = useSWRMutation13(
|
|
27580
|
+
() => buildKey22(__spreadProps(__spreadValues({}, auth), {
|
|
27374
27581
|
businessId
|
|
27375
27582
|
})),
|
|
27376
27583
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, files, description } }) => completeTaskWithUpload(
|
|
@@ -27389,18 +27596,19 @@ function useUploadDocumentsForTask() {
|
|
|
27389
27596
|
}
|
|
27390
27597
|
);
|
|
27391
27598
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27392
|
-
const stableProxiedTrigger =
|
|
27393
|
-
(...triggerParameters) => __async(
|
|
27394
|
-
const
|
|
27395
|
-
|
|
27396
|
-
|
|
27397
|
-
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
}
|
|
27401
|
-
return result;
|
|
27599
|
+
const stableProxiedTrigger = useCallback14(
|
|
27600
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27601
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27602
|
+
void mutate((key) => withSWRKeyTags(
|
|
27603
|
+
key,
|
|
27604
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27605
|
+
));
|
|
27606
|
+
return triggerResult;
|
|
27402
27607
|
}),
|
|
27403
|
-
[
|
|
27608
|
+
[
|
|
27609
|
+
originalTrigger,
|
|
27610
|
+
mutate
|
|
27611
|
+
]
|
|
27404
27612
|
);
|
|
27405
27613
|
return new Proxy(mutationResponse, {
|
|
27406
27614
|
get(target, prop) {
|
|
@@ -27413,10 +27621,10 @@ function useUploadDocumentsForTask() {
|
|
|
27413
27621
|
}
|
|
27414
27622
|
|
|
27415
27623
|
// src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
|
|
27416
|
-
import { useSWRConfig as
|
|
27417
|
-
import
|
|
27418
|
-
import { useCallback as
|
|
27419
|
-
function
|
|
27624
|
+
import { useSWRConfig as useSWRConfig7 } from "swr";
|
|
27625
|
+
import useSWRMutation14 from "swr/mutation";
|
|
27626
|
+
import { useCallback as useCallback15 } from "react";
|
|
27627
|
+
function buildKey23({
|
|
27420
27628
|
access_token: accessToken,
|
|
27421
27629
|
apiUrl,
|
|
27422
27630
|
businessId
|
|
@@ -27433,9 +27641,9 @@ function buildKey19({
|
|
|
27433
27641
|
function useDeleteUploadsOnTask() {
|
|
27434
27642
|
const { data: auth } = useAuth();
|
|
27435
27643
|
const { businessId } = useLayerContext();
|
|
27436
|
-
const { mutate } =
|
|
27437
|
-
const mutationResponse =
|
|
27438
|
-
() =>
|
|
27644
|
+
const { mutate } = useSWRConfig7();
|
|
27645
|
+
const mutationResponse = useSWRMutation14(
|
|
27646
|
+
() => buildKey23(__spreadProps(__spreadValues({}, auth), {
|
|
27439
27647
|
businessId
|
|
27440
27648
|
})),
|
|
27441
27649
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId } }) => deleteUploadsOnTask(
|
|
@@ -27451,18 +27659,19 @@ function useDeleteUploadsOnTask() {
|
|
|
27451
27659
|
}
|
|
27452
27660
|
);
|
|
27453
27661
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27454
|
-
const stableProxiedTrigger =
|
|
27455
|
-
(...triggerParameters) => __async(
|
|
27456
|
-
const
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
}
|
|
27463
|
-
return result;
|
|
27662
|
+
const stableProxiedTrigger = useCallback15(
|
|
27663
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27664
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27665
|
+
void mutate((key) => withSWRKeyTags(
|
|
27666
|
+
key,
|
|
27667
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27668
|
+
));
|
|
27669
|
+
return triggerResult;
|
|
27464
27670
|
}),
|
|
27465
|
-
[
|
|
27671
|
+
[
|
|
27672
|
+
originalTrigger,
|
|
27673
|
+
mutate
|
|
27674
|
+
]
|
|
27466
27675
|
);
|
|
27467
27676
|
return new Proxy(mutationResponse, {
|
|
27468
27677
|
get(target, prop) {
|
|
@@ -27475,10 +27684,10 @@ function useDeleteUploadsOnTask() {
|
|
|
27475
27684
|
}
|
|
27476
27685
|
|
|
27477
27686
|
// src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
|
|
27478
|
-
import { useSWRConfig as
|
|
27479
|
-
import
|
|
27480
|
-
import { useCallback as
|
|
27481
|
-
function
|
|
27687
|
+
import { useSWRConfig as useSWRConfig8 } from "swr";
|
|
27688
|
+
import useSWRMutation15 from "swr/mutation";
|
|
27689
|
+
import { useCallback as useCallback16 } from "react";
|
|
27690
|
+
function buildKey24({
|
|
27482
27691
|
access_token: accessToken,
|
|
27483
27692
|
apiUrl,
|
|
27484
27693
|
businessId
|
|
@@ -27495,9 +27704,9 @@ function buildKey20({
|
|
|
27495
27704
|
function useUpdateTaskUploadDescription() {
|
|
27496
27705
|
const { data: auth } = useAuth();
|
|
27497
27706
|
const { businessId } = useLayerContext();
|
|
27498
|
-
const { mutate } =
|
|
27499
|
-
const mutationResponse =
|
|
27500
|
-
() =>
|
|
27707
|
+
const { mutate } = useSWRConfig8();
|
|
27708
|
+
const mutationResponse = useSWRMutation15(
|
|
27709
|
+
() => buildKey24(__spreadProps(__spreadValues({}, auth), {
|
|
27501
27710
|
businessId
|
|
27502
27711
|
})),
|
|
27503
27712
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, description } }) => updateTaskUploadsDescription(
|
|
@@ -27517,18 +27726,19 @@ function useUpdateTaskUploadDescription() {
|
|
|
27517
27726
|
}
|
|
27518
27727
|
);
|
|
27519
27728
|
const { trigger: originalTrigger } = mutationResponse;
|
|
27520
|
-
const stableProxiedTrigger =
|
|
27521
|
-
(...triggerParameters) => __async(
|
|
27522
|
-
const
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
|
|
27526
|
-
|
|
27527
|
-
|
|
27528
|
-
}
|
|
27529
|
-
return result;
|
|
27729
|
+
const stableProxiedTrigger = useCallback16(
|
|
27730
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
27731
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
27732
|
+
void mutate((key) => withSWRKeyTags(
|
|
27733
|
+
key,
|
|
27734
|
+
(tags) => tags.includes(BOOKKEEPING_PERIODS_TAG_KEY)
|
|
27735
|
+
));
|
|
27736
|
+
return triggerResult;
|
|
27530
27737
|
}),
|
|
27531
|
-
[
|
|
27738
|
+
[
|
|
27739
|
+
originalTrigger,
|
|
27740
|
+
mutate
|
|
27741
|
+
]
|
|
27532
27742
|
);
|
|
27533
27743
|
return new Proxy(mutationResponse, {
|
|
27534
27744
|
get(target, prop) {
|
|
@@ -27570,7 +27780,7 @@ var TasksListItem = ({
|
|
|
27570
27780
|
useEffect41(() => {
|
|
27571
27781
|
setIsOpen(defaultOpen);
|
|
27572
27782
|
}, [defaultOpen]);
|
|
27573
|
-
const submit = () => __async(
|
|
27783
|
+
const submit = () => __async(null, null, function* () {
|
|
27574
27784
|
if (!selectedFiles) {
|
|
27575
27785
|
return;
|
|
27576
27786
|
}
|
|
@@ -27786,7 +27996,7 @@ var TasksListMobile = ({
|
|
|
27786
27996
|
};
|
|
27787
27997
|
|
|
27788
27998
|
// src/hooks/array/usePaginatedList.ts
|
|
27789
|
-
import { useCallback as
|
|
27999
|
+
import { useCallback as useCallback17, useMemo as useMemo40, useState as useState58 } from "react";
|
|
27790
28000
|
function usePaginatedList(list, pageSize) {
|
|
27791
28001
|
const [internalPageIndex, setInternalPageIndex] = useState58(0);
|
|
27792
28002
|
const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
|
|
@@ -27797,16 +28007,16 @@ function usePaginatedList(list, pageSize) {
|
|
|
27797
28007
|
(effectivePageIndex + 1) * pageSize
|
|
27798
28008
|
);
|
|
27799
28009
|
}, [list, effectivePageIndex, pageSize]);
|
|
27800
|
-
const next =
|
|
28010
|
+
const next = useCallback17(() => {
|
|
27801
28011
|
setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
|
|
27802
28012
|
}, [effectivePageIndex, pageCount]);
|
|
27803
|
-
const set2 =
|
|
28013
|
+
const set2 = useCallback17((pageIndex) => {
|
|
27804
28014
|
setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
|
|
27805
28015
|
}, [pageCount]);
|
|
27806
|
-
const previous =
|
|
28016
|
+
const previous = useCallback17(() => {
|
|
27807
28017
|
setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
|
|
27808
28018
|
}, [effectivePageIndex]);
|
|
27809
|
-
const reset =
|
|
28019
|
+
const reset = useCallback17(() => {
|
|
27810
28020
|
setInternalPageIndex(0);
|
|
27811
28021
|
}, []);
|
|
27812
28022
|
return {
|
|
@@ -28225,50 +28435,6 @@ var ArrowRightCircle = (_a) => {
|
|
|
28225
28435
|
};
|
|
28226
28436
|
var ArrowRightCircle_default = ArrowRightCircle;
|
|
28227
28437
|
|
|
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
28438
|
// src/components/Tasks/TasksPanelNotification.tsx
|
|
28273
28439
|
import { jsx as jsx251, jsxs as jsxs160 } from "react/jsx-runtime";
|
|
28274
28440
|
var TasksPanelNotification = ({
|
|
@@ -28622,7 +28788,7 @@ import { useForm as useForm2 } from "@tanstack/react-form";
|
|
|
28622
28788
|
import {
|
|
28623
28789
|
Children,
|
|
28624
28790
|
createContext as createContext20,
|
|
28625
|
-
useCallback as
|
|
28791
|
+
useCallback as useCallback18,
|
|
28626
28792
|
useContext as useContext50,
|
|
28627
28793
|
useMemo as useMemo45,
|
|
28628
28794
|
useState as useState60
|
|
@@ -28634,13 +28800,13 @@ function useWizardStep({
|
|
|
28634
28800
|
}) {
|
|
28635
28801
|
const stepCount = steps.length;
|
|
28636
28802
|
const [activeStepIndex, setActiveStepIndex] = useState60(0);
|
|
28637
|
-
const next =
|
|
28803
|
+
const next = useCallback18(() => __async(null, null, function* () {
|
|
28638
28804
|
setActiveStepIndex((stepIndex) => Math.min(stepIndex + 1, stepCount - 1));
|
|
28639
28805
|
if (activeStepIndex === stepCount - 1 && onComplete) {
|
|
28640
28806
|
yield onComplete == null ? void 0 : onComplete();
|
|
28641
28807
|
}
|
|
28642
28808
|
}), [stepCount, activeStepIndex, onComplete]);
|
|
28643
|
-
const previous =
|
|
28809
|
+
const previous = useCallback18(() => setActiveStepIndex((stepIndex) => Math.max(stepIndex - 1, 0)), []);
|
|
28644
28810
|
const effectiveStepIndex = Math.min(activeStepIndex, stepCount - 1);
|
|
28645
28811
|
const currentStep = steps.at(effectiveStepIndex);
|
|
28646
28812
|
return { currentStep, next, previous };
|
|
@@ -28719,7 +28885,7 @@ function LinkAccountsConfirmationStep() {
|
|
|
28719
28885
|
defaultValues: {
|
|
28720
28886
|
accounts: effectiveLinkedAccounts.map((account) => ({ account, isSelected: true }))
|
|
28721
28887
|
},
|
|
28722
|
-
onSubmit: (_0) => __async(
|
|
28888
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
28723
28889
|
const formattedArg = Object.fromEntries(
|
|
28724
28890
|
value.accounts.map(({ account, isSelected }) => [account.id, isSelected])
|
|
28725
28891
|
);
|
|
@@ -29233,7 +29399,7 @@ function isPersonnelRole(role) {
|
|
|
29233
29399
|
|
|
29234
29400
|
// src/hooks/businessPersonnel/useBusinessPersonnel.ts
|
|
29235
29401
|
var BUSINESS_PERSONNEL_TAG_KEY = "#business-personnel";
|
|
29236
|
-
function
|
|
29402
|
+
function buildKey25({
|
|
29237
29403
|
access_token: accessToken,
|
|
29238
29404
|
apiUrl,
|
|
29239
29405
|
businessId
|
|
@@ -29252,7 +29418,7 @@ function useBusinessPersonnel() {
|
|
|
29252
29418
|
const { data } = useAuth();
|
|
29253
29419
|
const { businessId } = useLayerContext();
|
|
29254
29420
|
return useSWR17(
|
|
29255
|
-
() =>
|
|
29421
|
+
() => buildKey25(__spreadProps(__spreadValues({}, data), {
|
|
29256
29422
|
businessId
|
|
29257
29423
|
})),
|
|
29258
29424
|
({ accessToken, apiUrl, businessId: businessId2 }) => getBusinessPersonnel(
|
|
@@ -29291,11 +29457,11 @@ function useBusinessPersonnel() {
|
|
|
29291
29457
|
}
|
|
29292
29458
|
|
|
29293
29459
|
// src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
|
|
29294
|
-
import
|
|
29295
|
-
import { useSWRConfig as
|
|
29296
|
-
import { useCallback as
|
|
29460
|
+
import useSWRMutation16 from "swr/mutation";
|
|
29461
|
+
import { useSWRConfig as useSWRConfig9 } from "swr";
|
|
29462
|
+
import { useCallback as useCallback19 } from "react";
|
|
29297
29463
|
var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
|
|
29298
|
-
function
|
|
29464
|
+
function buildKey26({
|
|
29299
29465
|
access_token: accessToken,
|
|
29300
29466
|
apiUrl,
|
|
29301
29467
|
businessId
|
|
@@ -29312,9 +29478,9 @@ function buildKey23({
|
|
|
29312
29478
|
function useCreateBusinessPersonnel() {
|
|
29313
29479
|
const { data } = useAuth();
|
|
29314
29480
|
const { businessId } = useLayerContext();
|
|
29315
|
-
const { mutate } =
|
|
29316
|
-
const mutationResponse =
|
|
29317
|
-
() =>
|
|
29481
|
+
const { mutate } = useSWRConfig9();
|
|
29482
|
+
const mutationResponse = useSWRMutation16(
|
|
29483
|
+
() => buildKey26(__spreadProps(__spreadValues({}, data), {
|
|
29318
29484
|
businessId
|
|
29319
29485
|
})),
|
|
29320
29486
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createBusinessPersonnel(
|
|
@@ -29331,18 +29497,19 @@ function useCreateBusinessPersonnel() {
|
|
|
29331
29497
|
}
|
|
29332
29498
|
);
|
|
29333
29499
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29334
|
-
const stableProxiedTrigger =
|
|
29335
|
-
(...triggerParameters) => __async(
|
|
29336
|
-
const
|
|
29337
|
-
|
|
29338
|
-
|
|
29339
|
-
|
|
29340
|
-
|
|
29341
|
-
|
|
29342
|
-
}
|
|
29343
|
-
return result;
|
|
29500
|
+
const stableProxiedTrigger = useCallback19(
|
|
29501
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29502
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29503
|
+
void mutate((key) => withSWRKeyTags(
|
|
29504
|
+
key,
|
|
29505
|
+
(tags) => tags.includes(BUSINESS_PERSONNEL_TAG_KEY)
|
|
29506
|
+
));
|
|
29507
|
+
return triggerResult;
|
|
29344
29508
|
}),
|
|
29345
|
-
[
|
|
29509
|
+
[
|
|
29510
|
+
originalTrigger,
|
|
29511
|
+
mutate
|
|
29512
|
+
]
|
|
29346
29513
|
);
|
|
29347
29514
|
return new Proxy(mutationResponse, {
|
|
29348
29515
|
get(target, prop) {
|
|
@@ -29355,8 +29522,8 @@ function useCreateBusinessPersonnel() {
|
|
|
29355
29522
|
}
|
|
29356
29523
|
|
|
29357
29524
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29358
|
-
import
|
|
29359
|
-
import { useSWRConfig as
|
|
29525
|
+
import useSWRMutation17 from "swr/mutation";
|
|
29526
|
+
import { useSWRConfig as useSWRConfig10 } from "swr";
|
|
29360
29527
|
|
|
29361
29528
|
// src/api/layer/businessPersonnel/updateBusinessPersonnel.ts
|
|
29362
29529
|
var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
@@ -29364,8 +29531,8 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
|
|
|
29364
29531
|
});
|
|
29365
29532
|
|
|
29366
29533
|
// src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
|
|
29367
|
-
import { useCallback as
|
|
29368
|
-
function
|
|
29534
|
+
import { useCallback as useCallback20 } from "react";
|
|
29535
|
+
function buildKey27({
|
|
29369
29536
|
access_token: accessToken,
|
|
29370
29537
|
apiUrl,
|
|
29371
29538
|
businessId,
|
|
@@ -29384,9 +29551,9 @@ function buildKey24({
|
|
|
29384
29551
|
function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
29385
29552
|
const { data } = useAuth();
|
|
29386
29553
|
const { businessId } = useLayerContext();
|
|
29387
|
-
const { mutate } =
|
|
29388
|
-
const mutationResponse =
|
|
29389
|
-
() =>
|
|
29554
|
+
const { mutate } = useSWRConfig10();
|
|
29555
|
+
const mutationResponse = useSWRMutation17(
|
|
29556
|
+
() => buildKey27(__spreadProps(__spreadValues({}, data), {
|
|
29390
29557
|
businessId,
|
|
29391
29558
|
businessPersonnelId
|
|
29392
29559
|
})),
|
|
@@ -29407,18 +29574,19 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29407
29574
|
}
|
|
29408
29575
|
);
|
|
29409
29576
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29410
|
-
const stableProxiedTrigger =
|
|
29411
|
-
(...triggerParameters) => __async(
|
|
29412
|
-
const
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
}
|
|
29419
|
-
return result;
|
|
29577
|
+
const stableProxiedTrigger = useCallback20(
|
|
29578
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29579
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29580
|
+
void mutate((key) => withSWRKeyTags(
|
|
29581
|
+
key,
|
|
29582
|
+
(tags) => tags.includes(BUSINESS_PERSONNEL_TAG_KEY)
|
|
29583
|
+
));
|
|
29584
|
+
return triggerResult;
|
|
29420
29585
|
}),
|
|
29421
|
-
[
|
|
29586
|
+
[
|
|
29587
|
+
originalTrigger,
|
|
29588
|
+
mutate
|
|
29589
|
+
]
|
|
29422
29590
|
);
|
|
29423
29591
|
return new Proxy(mutationResponse, {
|
|
29424
29592
|
get(target, prop) {
|
|
@@ -29431,11 +29599,11 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
|
|
|
29431
29599
|
}
|
|
29432
29600
|
|
|
29433
29601
|
// src/hooks/business/useUpdateBusiness.ts
|
|
29434
|
-
import
|
|
29435
|
-
import { useSWRConfig as
|
|
29436
|
-
import { useCallback as
|
|
29602
|
+
import useSWRMutation18 from "swr/mutation";
|
|
29603
|
+
import { useSWRConfig as useSWRConfig11 } from "swr";
|
|
29604
|
+
import { useCallback as useCallback21 } from "react";
|
|
29437
29605
|
var BUSINESS_TAG_KEY = "business";
|
|
29438
|
-
function
|
|
29606
|
+
function buildKey28({
|
|
29439
29607
|
access_token: accessToken,
|
|
29440
29608
|
apiUrl,
|
|
29441
29609
|
businessId
|
|
@@ -29452,9 +29620,9 @@ function buildKey25({
|
|
|
29452
29620
|
function useUpdateBusiness() {
|
|
29453
29621
|
const { data } = useAuth();
|
|
29454
29622
|
const { businessId } = useLayerContext();
|
|
29455
|
-
const { mutate } =
|
|
29456
|
-
const mutationResponse =
|
|
29457
|
-
() =>
|
|
29623
|
+
const { mutate } = useSWRConfig11();
|
|
29624
|
+
const mutationResponse = useSWRMutation18(
|
|
29625
|
+
() => buildKey28(__spreadProps(__spreadValues({}, data), {
|
|
29458
29626
|
businessId
|
|
29459
29627
|
})),
|
|
29460
29628
|
({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => updateBusiness(
|
|
@@ -29471,18 +29639,19 @@ function useUpdateBusiness() {
|
|
|
29471
29639
|
}
|
|
29472
29640
|
);
|
|
29473
29641
|
const { trigger: originalTrigger } = mutationResponse;
|
|
29474
|
-
const stableProxiedTrigger =
|
|
29475
|
-
(...triggerParameters) => __async(
|
|
29476
|
-
const
|
|
29477
|
-
|
|
29478
|
-
|
|
29479
|
-
|
|
29480
|
-
|
|
29481
|
-
|
|
29482
|
-
}
|
|
29483
|
-
return result;
|
|
29642
|
+
const stableProxiedTrigger = useCallback21(
|
|
29643
|
+
(...triggerParameters) => __async(null, null, function* () {
|
|
29644
|
+
const triggerResult = yield originalTrigger(...triggerParameters);
|
|
29645
|
+
void mutate((key) => withSWRKeyTags(
|
|
29646
|
+
key,
|
|
29647
|
+
(tags) => tags.includes(BUSINESS_TAG_KEY)
|
|
29648
|
+
));
|
|
29649
|
+
return triggerResult;
|
|
29484
29650
|
}),
|
|
29485
|
-
[
|
|
29651
|
+
[
|
|
29652
|
+
originalTrigger,
|
|
29653
|
+
mutate
|
|
29654
|
+
]
|
|
29486
29655
|
);
|
|
29487
29656
|
return new Proxy(mutationResponse, {
|
|
29488
29657
|
get(target, prop) {
|
|
@@ -29523,7 +29692,7 @@ var useBusinessForm = ({ onSuccess }) => {
|
|
|
29523
29692
|
us_state: (_i = business == null ? void 0 : business.us_state) != null ? _i : void 0,
|
|
29524
29693
|
tin: business == null ? void 0 : business.tin
|
|
29525
29694
|
},
|
|
29526
|
-
onSubmit: (_0) => __async(
|
|
29695
|
+
onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
|
|
29527
29696
|
var _a2;
|
|
29528
29697
|
try {
|
|
29529
29698
|
setSubmitError(void 0);
|