@layerfi/components 0.1.132 → 0.1.133-alpha
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 +60 -29
- package/dist/esm/index.mjs +59 -28
- package/dist/index.d.ts +4 -4
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -246,6 +246,11 @@ var APIError = class APIError extends Error {
|
|
|
246
246
|
return (_this$messages = this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.map((x) => x.description);
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
+
var isAPIErrorOfType = (error, errorType) => {
|
|
250
|
+
var _error$messages;
|
|
251
|
+
if (!(error instanceof APIError)) return false;
|
|
252
|
+
return ((_error$messages = error.messages) === null || _error$messages === void 0 ? void 0 : _error$messages.some((message) => message.error_enum === errorType)) === true;
|
|
253
|
+
};
|
|
249
254
|
//#endregion
|
|
250
255
|
//#region src/utils/api/errorHandler.tsx
|
|
251
256
|
var ErrorHandlerClass = class {
|
|
@@ -278,7 +283,7 @@ var getIntlLocale = (locale) => {
|
|
|
278
283
|
};
|
|
279
284
|
var package_default = {
|
|
280
285
|
name: "@layerfi/components",
|
|
281
|
-
version: "0.1.
|
|
286
|
+
version: "0.1.133-alpha",
|
|
282
287
|
description: "Layer React Components",
|
|
283
288
|
main: "dist/cjs/index.cjs",
|
|
284
289
|
module: "dist/esm/index.mjs",
|
|
@@ -10795,6 +10800,11 @@ function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, busi
|
|
|
10795
10800
|
};
|
|
10796
10801
|
}
|
|
10797
10802
|
}
|
|
10803
|
+
var ListCustomersSWRResponse = class extends SWRInfiniteResult {
|
|
10804
|
+
get error() {
|
|
10805
|
+
return this.swrResponse.error;
|
|
10806
|
+
}
|
|
10807
|
+
};
|
|
10798
10808
|
function useListCustomers({ query, isEnabled = true } = {}) {
|
|
10799
10809
|
const withLocale = useLocalizedKey();
|
|
10800
10810
|
const { data } = useAuth();
|
|
@@ -10814,7 +10824,7 @@ function useListCustomers({ query, isEnabled = true } = {}) {
|
|
|
10814
10824
|
initialSize: 1
|
|
10815
10825
|
});
|
|
10816
10826
|
usePreserveInfiniteSize(swrResponse);
|
|
10817
|
-
return new
|
|
10827
|
+
return new ListCustomersSWRResponse(swrResponse);
|
|
10818
10828
|
}
|
|
10819
10829
|
function usePreloadCustomers(parameters) {
|
|
10820
10830
|
useListCustomers(parameters);
|
|
@@ -41737,12 +41747,14 @@ var CustomerAsOption = class {
|
|
|
41737
41747
|
}
|
|
41738
41748
|
};
|
|
41739
41749
|
var formatCreateLabel$1 = (inputValue, t) => inputValue ? t("customerVendor:action.create_customer_input_value", "Create customer \"{{inputValue}}\"", { inputValue }) : t("customerVendor:action.create_new_customer", "Create new customer");
|
|
41740
|
-
function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, placeholder, isCreatable, onCreateCustomer, isReadOnly, inline, className, showLabel = true }) {
|
|
41750
|
+
function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, placeholder, isCreatable, onCreateCustomer, isReadOnly, inline, className, hideSpecifiedIdNotFoundError, showLabel = true }) {
|
|
41741
41751
|
const { t } = (0, react_i18next.useTranslation)();
|
|
41742
41752
|
const resolvedLabel = label !== null && label !== void 0 ? label : t("customerVendor:label.customer", "Customer");
|
|
41743
41753
|
const combinedClassName = (0, classnames.default)("Layer__CustomerSelector", inline && "Layer__CustomerSelector--inline", className);
|
|
41744
41754
|
const { searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: () => "" });
|
|
41745
|
-
const { data, isLoading, isError } = useListCustomers({ query: searchQuery === "" ? void 0 : searchQuery });
|
|
41755
|
+
const { data, isLoading, isError, error } = useListCustomers({ query: searchQuery === "" ? void 0 : searchQuery });
|
|
41756
|
+
const shouldHideError = hideSpecifiedIdNotFoundError && isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound);
|
|
41757
|
+
const shouldShowError = isError && !shouldHideError;
|
|
41746
41758
|
const options = (0, react.useMemo)(() => (data === null || data === void 0 ? void 0 : data.flatMap(({ data }) => data).map((customer) => new CustomerAsOption(customer))) || [], [data]);
|
|
41747
41759
|
const selectedCustomerId = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.id;
|
|
41748
41760
|
const handleSelectionChange = (0, react.useCallback)((selectedOption) => {
|
|
@@ -41793,7 +41805,7 @@ function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, p
|
|
|
41793
41805
|
ErrorMessage
|
|
41794
41806
|
},
|
|
41795
41807
|
isDisabled: isLoadingWithoutFallback || isError,
|
|
41796
|
-
isError,
|
|
41808
|
+
isError: shouldShowError,
|
|
41797
41809
|
isLoading: isLoadingWithoutFallback,
|
|
41798
41810
|
isReadOnly,
|
|
41799
41811
|
["aria-label"]: showLabel ? void 0 : resolvedLabel
|
|
@@ -49892,11 +49904,16 @@ function buildKey$11({ access_token: accessToken, apiUrl, businessId }) {
|
|
|
49892
49904
|
tags: [ACTIVE_TIME_TRACKER_TAG_KEY]
|
|
49893
49905
|
};
|
|
49894
49906
|
}
|
|
49907
|
+
var ActiveTimeTrackerSWRResponse = class extends SWRQueryResult {
|
|
49908
|
+
get error() {
|
|
49909
|
+
return this.swrResponse.error;
|
|
49910
|
+
}
|
|
49911
|
+
};
|
|
49895
49912
|
function useActiveTimeTracker() {
|
|
49896
49913
|
const withLocale = useLocalizedKey();
|
|
49897
49914
|
const { data } = useAuth();
|
|
49898
49915
|
const { businessId } = useLayerContext();
|
|
49899
|
-
return new
|
|
49916
|
+
return new ActiveTimeTrackerSWRResponse((0, swr.default)(() => withLocale(buildKey$11(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }) => getActiveTimeTracker(apiUrl, accessToken, { params: { businessId } })().then(effect.Schema.decodeUnknownPromise(ActiveTimeTrackerResponseSchema)).then(({ data }) => {
|
|
49900
49917
|
var _data$timeEntry;
|
|
49901
49918
|
return (_data$timeEntry = data.timeEntry) !== null && _data$timeEntry !== void 0 ? _data$timeEntry : null;
|
|
49902
49919
|
})));
|
|
@@ -49947,11 +49964,16 @@ function buildKey$10({ access_token: accessToken, apiUrl, businessId, allowArchi
|
|
|
49947
49964
|
var listCatalogServices = get$1(({ businessId, allowArchived }) => {
|
|
49948
49965
|
return `/v1/businesses/${businessId}/catalog/services?${toDefinedSearchParameters({ allowArchived })}`;
|
|
49949
49966
|
});
|
|
49967
|
+
var ListCatalogServicesSWRResponse = class extends SWRQueryResult {
|
|
49968
|
+
get error() {
|
|
49969
|
+
return this.swrResponse.error;
|
|
49970
|
+
}
|
|
49971
|
+
};
|
|
49950
49972
|
function useListCatalogServices({ allowArchived, isEnabled = true } = {}) {
|
|
49951
49973
|
const withLocale = useLocalizedKey();
|
|
49952
49974
|
const { data } = useAuth();
|
|
49953
49975
|
const { businessId } = useLayerContext();
|
|
49954
|
-
return new
|
|
49976
|
+
return new ListCatalogServicesSWRResponse((0, swr.default)(() => withLocale(buildKey$10(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
49955
49977
|
businessId,
|
|
49956
49978
|
allowArchived,
|
|
49957
49979
|
isEnabled
|
|
@@ -51255,10 +51277,12 @@ var formatCreateLabel = (inputValue, t) => /* @__PURE__ */ (0, react_jsx_runtime
|
|
|
51255
51277
|
"aria-hidden": "true"
|
|
51256
51278
|
}), inputValue ? t("timeTracking:services.create_service_input_value", "Create service \"{{inputValue}}\"", { inputValue }) : t("timeTracking:services.add_service", "Add service")]
|
|
51257
51279
|
});
|
|
51258
|
-
function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange, placeholder, isReadOnly, isClearable, inline, className, showLabel = true, allowArchived, isCreatable, onCreateService }) {
|
|
51280
|
+
function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange, placeholder, isReadOnly, isClearable, inline, className, showLabel = true, hideSpecifiedIdNotFoundError, allowArchived, isCreatable, onCreateService }) {
|
|
51259
51281
|
const { t } = (0, react_i18next.useTranslation)();
|
|
51260
|
-
const { data: servicesResponse, isLoading, isError } = useListCatalogServices({ allowArchived });
|
|
51282
|
+
const { data: servicesResponse, isLoading, isError, error } = useListCatalogServices({ allowArchived });
|
|
51261
51283
|
const isLoadingWithoutFallback = isLoading && !servicesResponse;
|
|
51284
|
+
const shouldHideError = hideSpecifiedIdNotFoundError && isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound);
|
|
51285
|
+
const shouldShowError = isError && !shouldHideError;
|
|
51262
51286
|
const shouldDisableComboBox = isLoadingWithoutFallback || isError;
|
|
51263
51287
|
const serviceOptions = (0, react.useMemo)(() => {
|
|
51264
51288
|
var _servicesResponse$dat;
|
|
@@ -51279,13 +51303,13 @@ function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange
|
|
|
51279
51303
|
children: t("timeTracking:label.no_services", "No services available")
|
|
51280
51304
|
}), [t]);
|
|
51281
51305
|
const ErrorMessage = (0, react.useMemo)(() => {
|
|
51282
|
-
if (!
|
|
51306
|
+
if (!shouldShowError) return null;
|
|
51283
51307
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(P, {
|
|
51284
51308
|
size: "xs",
|
|
51285
51309
|
status: "error",
|
|
51286
51310
|
children: t("timeTracking:error.load_services", "Failed to load services.")
|
|
51287
51311
|
});
|
|
51288
|
-
}, [
|
|
51312
|
+
}, [shouldShowError, t]);
|
|
51289
51313
|
const inputId = (0, react.useId)();
|
|
51290
51314
|
const sharedProps = {
|
|
51291
51315
|
selectedValue: selectedServiceForComboBox,
|
|
@@ -51299,7 +51323,7 @@ function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange
|
|
|
51299
51323
|
},
|
|
51300
51324
|
isClearable,
|
|
51301
51325
|
isDisabled: shouldDisableComboBox,
|
|
51302
|
-
isError,
|
|
51326
|
+
isError: shouldShowError,
|
|
51303
51327
|
isLoading: isLoadingWithoutFallback,
|
|
51304
51328
|
isReadOnly,
|
|
51305
51329
|
["aria-label"]: showLabel ? void 0 : t("timeTracking:label.service", "Service")
|
|
@@ -51640,21 +51664,24 @@ var ActiveTimeTracker = ({ isDrawerOpen, onDrawerOpenChange }) => {
|
|
|
51640
51664
|
const { t } = (0, react_i18next.useTranslation)();
|
|
51641
51665
|
const { isMobile } = useSizeClass();
|
|
51642
51666
|
const { formatSecondsAsDuration } = useIntlFormatter();
|
|
51643
|
-
const { data: activeEntry, isLoading, isError } = useActiveTimeTracker();
|
|
51667
|
+
const { data: activeEntry, isLoading, isError, error } = useActiveTimeTracker();
|
|
51644
51668
|
const elapsedSeconds = useElapsedSeconds(activeEntry === null || activeEntry === void 0 ? void 0 : activeEntry.createdAt);
|
|
51645
51669
|
const timerDisplayValue = (0, react.useMemo)(() => formatSecondsAsDuration(elapsedSeconds), [elapsedSeconds, formatSecondsAsDuration]);
|
|
51646
51670
|
if (isLoading) return null;
|
|
51647
|
-
if (isError)
|
|
51648
|
-
|
|
51649
|
-
|
|
51650
|
-
|
|
51651
|
-
|
|
51652
|
-
|
|
51653
|
-
|
|
51654
|
-
|
|
51671
|
+
if (isError) {
|
|
51672
|
+
if (isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound)) return null;
|
|
51673
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Container, {
|
|
51674
|
+
name: "ActiveTimeTracker",
|
|
51675
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VStack, {
|
|
51676
|
+
pi: "lg",
|
|
51677
|
+
pbe: "md",
|
|
51678
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataState, {
|
|
51679
|
+
status: DataStateStatus.failed,
|
|
51680
|
+
title: t("timeTracking:error.load_active_timer", "Failed to load active timer. Please check your connection and try again.")
|
|
51681
|
+
})
|
|
51655
51682
|
})
|
|
51656
|
-
})
|
|
51657
|
-
}
|
|
51683
|
+
});
|
|
51684
|
+
}
|
|
51658
51685
|
if (activeEntry) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActiveTimeTrackerBanner, {
|
|
51659
51686
|
activeEntry,
|
|
51660
51687
|
timerDisplayValue
|
|
@@ -51841,7 +51868,8 @@ var TimeEntriesTableHeader = () => {
|
|
|
51841
51868
|
placeholder: t("timeTracking:label.all_services", "All Services"),
|
|
51842
51869
|
showLabel: false,
|
|
51843
51870
|
allowArchived: true,
|
|
51844
|
-
inline: true
|
|
51871
|
+
inline: true,
|
|
51872
|
+
hideSpecifiedIdNotFoundError: true
|
|
51845
51873
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomerSelector, {
|
|
51846
51874
|
selectedCustomer,
|
|
51847
51875
|
onSelectedCustomerChange: setSelectedCustomer,
|
|
@@ -51849,7 +51877,8 @@ var TimeEntriesTableHeader = () => {
|
|
|
51849
51877
|
className: "Layer__TimeEntriesTable__FilterCustomer",
|
|
51850
51878
|
placeholder: t("timeTracking:label.all_customers", "All Customers"),
|
|
51851
51879
|
showLabel: false,
|
|
51852
|
-
inline: true
|
|
51880
|
+
inline: true,
|
|
51881
|
+
hideSpecifiedIdNotFoundError: true
|
|
51853
51882
|
})]
|
|
51854
51883
|
}), [
|
|
51855
51884
|
selectedCustomer,
|
|
@@ -52121,7 +52150,8 @@ var TimeEntryCustomerField = ({ value, entryCustomer, isReadOnly, onChange }) =>
|
|
|
52121
52150
|
inline: true,
|
|
52122
52151
|
label: t("timeTracking:label.customer_optional", "Customer (optional)"),
|
|
52123
52152
|
placeholder: t("timeTracking:label.select_customer_short", "Select a customer"),
|
|
52124
|
-
className: "Layer__TimeEntryForm__Field__Customer"
|
|
52153
|
+
className: "Layer__TimeEntryForm__Field__Customer",
|
|
52154
|
+
hideSpecifiedIdNotFoundError: true
|
|
52125
52155
|
});
|
|
52126
52156
|
};
|
|
52127
52157
|
var TimeEntryForm = ({ onSuccess, entry, isReadOnly }) => {
|
|
@@ -52189,7 +52219,8 @@ var TimeEntryForm = ({ onSuccess, entry, isReadOnly }) => {
|
|
|
52189
52219
|
inline: true,
|
|
52190
52220
|
className: "Layer__TimeEntryForm__Field__Service",
|
|
52191
52221
|
isCreatable: !isReadOnly,
|
|
52192
|
-
onCreateService: handleCreateService
|
|
52222
|
+
onCreateService: handleCreateService,
|
|
52223
|
+
hideSpecifiedIdNotFoundError: true
|
|
52193
52224
|
})
|
|
52194
52225
|
}),
|
|
52195
52226
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(form.Field, {
|
|
@@ -53107,13 +53138,13 @@ exports.ProfitAndLoss = ProfitAndLoss;
|
|
|
53107
53138
|
exports.ProfitAndLossView = ProfitAndLossView;
|
|
53108
53139
|
exports.ProjectProfitabilityView = ProjectProfitabilityView;
|
|
53109
53140
|
exports.Reports = Reports;
|
|
53141
|
+
exports.SolopreneurOverview = SolopreneurOverview;
|
|
53110
53142
|
exports.StatementOfCashFlow = StatementOfCashFlow;
|
|
53111
53143
|
exports.SupportedLocale = SupportedLocale;
|
|
53112
53144
|
exports.Tasks = Tasks;
|
|
53145
|
+
exports.TaxEstimates = TaxEstimates;
|
|
53113
53146
|
exports.TimeTracking = TimeTracking;
|
|
53114
53147
|
exports.UnifiedReports = UnifiedReports;
|
|
53115
53148
|
exports.unstable_MileageSummaryCard = MileageSummaryCard;
|
|
53116
53149
|
exports.unstable_MileageTracking = unstable_MileageTracking;
|
|
53117
|
-
exports.unstable_SolopreneurOverview = SolopreneurOverview;
|
|
53118
|
-
exports.unstable_TaxEstimates = TaxEstimates;
|
|
53119
53150
|
exports.useLayerContext = useLayerContext;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -218,6 +218,11 @@ var APIError = class APIError extends Error {
|
|
|
218
218
|
return (_this$messages = this.messages) === null || _this$messages === void 0 ? void 0 : _this$messages.map((x) => x.description);
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
|
+
var isAPIErrorOfType = (error, errorType) => {
|
|
222
|
+
var _error$messages;
|
|
223
|
+
if (!(error instanceof APIError)) return false;
|
|
224
|
+
return ((_error$messages = error.messages) === null || _error$messages === void 0 ? void 0 : _error$messages.some((message) => message.error_enum === errorType)) === true;
|
|
225
|
+
};
|
|
221
226
|
//#endregion
|
|
222
227
|
//#region src/utils/api/errorHandler.tsx
|
|
223
228
|
var ErrorHandlerClass = class {
|
|
@@ -250,7 +255,7 @@ var getIntlLocale = (locale) => {
|
|
|
250
255
|
};
|
|
251
256
|
var package_default = {
|
|
252
257
|
name: "@layerfi/components",
|
|
253
|
-
version: "0.1.
|
|
258
|
+
version: "0.1.133-alpha",
|
|
254
259
|
description: "Layer React Components",
|
|
255
260
|
main: "dist/cjs/index.cjs",
|
|
256
261
|
module: "dist/esm/index.mjs",
|
|
@@ -7461,6 +7466,11 @@ function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, busi
|
|
|
7461
7466
|
};
|
|
7462
7467
|
}
|
|
7463
7468
|
}
|
|
7469
|
+
var ListCustomersSWRResponse = class extends SWRInfiniteResult {
|
|
7470
|
+
get error() {
|
|
7471
|
+
return this.swrResponse.error;
|
|
7472
|
+
}
|
|
7473
|
+
};
|
|
7464
7474
|
function useListCustomers({ query, isEnabled = true } = {}) {
|
|
7465
7475
|
const withLocale = useLocalizedKey();
|
|
7466
7476
|
const { data } = useAuth();
|
|
@@ -7480,7 +7490,7 @@ function useListCustomers({ query, isEnabled = true } = {}) {
|
|
|
7480
7490
|
initialSize: 1
|
|
7481
7491
|
});
|
|
7482
7492
|
usePreserveInfiniteSize(swrResponse);
|
|
7483
|
-
return new
|
|
7493
|
+
return new ListCustomersSWRResponse(swrResponse);
|
|
7484
7494
|
}
|
|
7485
7495
|
function usePreloadCustomers(parameters) {
|
|
7486
7496
|
useListCustomers(parameters);
|
|
@@ -38378,12 +38388,14 @@ var CustomerAsOption = class {
|
|
|
38378
38388
|
}
|
|
38379
38389
|
};
|
|
38380
38390
|
var formatCreateLabel$1 = (inputValue, t) => inputValue ? t("customerVendor:action.create_customer_input_value", "Create customer \"{{inputValue}}\"", { inputValue }) : t("customerVendor:action.create_new_customer", "Create new customer");
|
|
38381
|
-
function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, placeholder, isCreatable, onCreateCustomer, isReadOnly, inline, className, showLabel = true }) {
|
|
38391
|
+
function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, placeholder, isCreatable, onCreateCustomer, isReadOnly, inline, className, hideSpecifiedIdNotFoundError, showLabel = true }) {
|
|
38382
38392
|
const { t } = useTranslation();
|
|
38383
38393
|
const resolvedLabel = label !== null && label !== void 0 ? label : t("customerVendor:label.customer", "Customer");
|
|
38384
38394
|
const combinedClassName = classNames("Layer__CustomerSelector", inline && "Layer__CustomerSelector--inline", className);
|
|
38385
38395
|
const { searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: () => "" });
|
|
38386
|
-
const { data, isLoading, isError } = useListCustomers({ query: searchQuery === "" ? void 0 : searchQuery });
|
|
38396
|
+
const { data, isLoading, isError, error } = useListCustomers({ query: searchQuery === "" ? void 0 : searchQuery });
|
|
38397
|
+
const shouldHideError = hideSpecifiedIdNotFoundError && isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound);
|
|
38398
|
+
const shouldShowError = isError && !shouldHideError;
|
|
38387
38399
|
const options = useMemo(() => (data === null || data === void 0 ? void 0 : data.flatMap(({ data }) => data).map((customer) => new CustomerAsOption(customer))) || [], [data]);
|
|
38388
38400
|
const selectedCustomerId = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.id;
|
|
38389
38401
|
const handleSelectionChange = useCallback((selectedOption) => {
|
|
@@ -38434,7 +38446,7 @@ function CustomerSelector({ selectedCustomer, onSelectedCustomerChange, label, p
|
|
|
38434
38446
|
ErrorMessage
|
|
38435
38447
|
},
|
|
38436
38448
|
isDisabled: isLoadingWithoutFallback || isError,
|
|
38437
|
-
isError,
|
|
38449
|
+
isError: shouldShowError,
|
|
38438
38450
|
isLoading: isLoadingWithoutFallback,
|
|
38439
38451
|
isReadOnly,
|
|
38440
38452
|
["aria-label"]: showLabel ? void 0 : resolvedLabel
|
|
@@ -46533,11 +46545,16 @@ function buildKey$11({ access_token: accessToken, apiUrl, businessId }) {
|
|
|
46533
46545
|
tags: [ACTIVE_TIME_TRACKER_TAG_KEY]
|
|
46534
46546
|
};
|
|
46535
46547
|
}
|
|
46548
|
+
var ActiveTimeTrackerSWRResponse = class extends SWRQueryResult {
|
|
46549
|
+
get error() {
|
|
46550
|
+
return this.swrResponse.error;
|
|
46551
|
+
}
|
|
46552
|
+
};
|
|
46536
46553
|
function useActiveTimeTracker() {
|
|
46537
46554
|
const withLocale = useLocalizedKey();
|
|
46538
46555
|
const { data } = useAuth();
|
|
46539
46556
|
const { businessId } = useLayerContext();
|
|
46540
|
-
return new
|
|
46557
|
+
return new ActiveTimeTrackerSWRResponse(useSWR(() => withLocale(buildKey$11(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }) => getActiveTimeTracker(apiUrl, accessToken, { params: { businessId } })().then(Schema.decodeUnknownPromise(ActiveTimeTrackerResponseSchema)).then(({ data }) => {
|
|
46541
46558
|
var _data$timeEntry;
|
|
46542
46559
|
return (_data$timeEntry = data.timeEntry) !== null && _data$timeEntry !== void 0 ? _data$timeEntry : null;
|
|
46543
46560
|
})));
|
|
@@ -46588,11 +46605,16 @@ function buildKey$10({ access_token: accessToken, apiUrl, businessId, allowArchi
|
|
|
46588
46605
|
var listCatalogServices = get(({ businessId, allowArchived }) => {
|
|
46589
46606
|
return `/v1/businesses/${businessId}/catalog/services?${toDefinedSearchParameters({ allowArchived })}`;
|
|
46590
46607
|
});
|
|
46608
|
+
var ListCatalogServicesSWRResponse = class extends SWRQueryResult {
|
|
46609
|
+
get error() {
|
|
46610
|
+
return this.swrResponse.error;
|
|
46611
|
+
}
|
|
46612
|
+
};
|
|
46591
46613
|
function useListCatalogServices({ allowArchived, isEnabled = true } = {}) {
|
|
46592
46614
|
const withLocale = useLocalizedKey();
|
|
46593
46615
|
const { data } = useAuth();
|
|
46594
46616
|
const { businessId } = useLayerContext();
|
|
46595
|
-
return new
|
|
46617
|
+
return new ListCatalogServicesSWRResponse(useSWR(() => withLocale(buildKey$10(_objectSpread2(_objectSpread2({}, data), {}, {
|
|
46596
46618
|
businessId,
|
|
46597
46619
|
allowArchived,
|
|
46598
46620
|
isEnabled
|
|
@@ -47896,10 +47918,12 @@ var formatCreateLabel = (inputValue, t) => /* @__PURE__ */ jsxs(Span, {
|
|
|
47896
47918
|
"aria-hidden": "true"
|
|
47897
47919
|
}), inputValue ? t("timeTracking:services.create_service_input_value", "Create service \"{{inputValue}}\"", { inputValue }) : t("timeTracking:services.add_service", "Add service")]
|
|
47898
47920
|
});
|
|
47899
|
-
function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange, placeholder, isReadOnly, isClearable, inline, className, showLabel = true, allowArchived, isCreatable, onCreateService }) {
|
|
47921
|
+
function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange, placeholder, isReadOnly, isClearable, inline, className, showLabel = true, hideSpecifiedIdNotFoundError, allowArchived, isCreatable, onCreateService }) {
|
|
47900
47922
|
const { t } = useTranslation();
|
|
47901
|
-
const { data: servicesResponse, isLoading, isError } = useListCatalogServices({ allowArchived });
|
|
47923
|
+
const { data: servicesResponse, isLoading, isError, error } = useListCatalogServices({ allowArchived });
|
|
47902
47924
|
const isLoadingWithoutFallback = isLoading && !servicesResponse;
|
|
47925
|
+
const shouldHideError = hideSpecifiedIdNotFoundError && isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound);
|
|
47926
|
+
const shouldShowError = isError && !shouldHideError;
|
|
47903
47927
|
const shouldDisableComboBox = isLoadingWithoutFallback || isError;
|
|
47904
47928
|
const serviceOptions = useMemo(() => {
|
|
47905
47929
|
var _servicesResponse$dat;
|
|
@@ -47920,13 +47944,13 @@ function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange
|
|
|
47920
47944
|
children: t("timeTracking:label.no_services", "No services available")
|
|
47921
47945
|
}), [t]);
|
|
47922
47946
|
const ErrorMessage = useMemo(() => {
|
|
47923
|
-
if (!
|
|
47947
|
+
if (!shouldShowError) return null;
|
|
47924
47948
|
return /* @__PURE__ */ jsx(P, {
|
|
47925
47949
|
size: "xs",
|
|
47926
47950
|
status: "error",
|
|
47927
47951
|
children: t("timeTracking:error.load_services", "Failed to load services.")
|
|
47928
47952
|
});
|
|
47929
|
-
}, [
|
|
47953
|
+
}, [shouldShowError, t]);
|
|
47930
47954
|
const inputId = useId();
|
|
47931
47955
|
const sharedProps = {
|
|
47932
47956
|
selectedValue: selectedServiceForComboBox,
|
|
@@ -47940,7 +47964,7 @@ function TimeEntryServiceSelector({ selectedServiceId, onSelectedServiceIdChange
|
|
|
47940
47964
|
},
|
|
47941
47965
|
isClearable,
|
|
47942
47966
|
isDisabled: shouldDisableComboBox,
|
|
47943
|
-
isError,
|
|
47967
|
+
isError: shouldShowError,
|
|
47944
47968
|
isLoading: isLoadingWithoutFallback,
|
|
47945
47969
|
isReadOnly,
|
|
47946
47970
|
["aria-label"]: showLabel ? void 0 : t("timeTracking:label.service", "Service")
|
|
@@ -48281,21 +48305,24 @@ var ActiveTimeTracker = ({ isDrawerOpen, onDrawerOpenChange }) => {
|
|
|
48281
48305
|
const { t } = useTranslation();
|
|
48282
48306
|
const { isMobile } = useSizeClass();
|
|
48283
48307
|
const { formatSecondsAsDuration } = useIntlFormatter();
|
|
48284
|
-
const { data: activeEntry, isLoading, isError } = useActiveTimeTracker();
|
|
48308
|
+
const { data: activeEntry, isLoading, isError, error } = useActiveTimeTracker();
|
|
48285
48309
|
const elapsedSeconds = useElapsedSeconds(activeEntry === null || activeEntry === void 0 ? void 0 : activeEntry.createdAt);
|
|
48286
48310
|
const timerDisplayValue = useMemo(() => formatSecondsAsDuration(elapsedSeconds), [elapsedSeconds, formatSecondsAsDuration]);
|
|
48287
48311
|
if (isLoading) return null;
|
|
48288
|
-
if (isError)
|
|
48289
|
-
|
|
48290
|
-
|
|
48291
|
-
|
|
48292
|
-
|
|
48293
|
-
|
|
48294
|
-
|
|
48295
|
-
|
|
48312
|
+
if (isError) {
|
|
48313
|
+
if (isAPIErrorOfType(error, ApiEnumErrorType.SpecifiedIdNotFound)) return null;
|
|
48314
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
48315
|
+
name: "ActiveTimeTracker",
|
|
48316
|
+
children: /* @__PURE__ */ jsx(VStack, {
|
|
48317
|
+
pi: "lg",
|
|
48318
|
+
pbe: "md",
|
|
48319
|
+
children: /* @__PURE__ */ jsx(DataState, {
|
|
48320
|
+
status: DataStateStatus.failed,
|
|
48321
|
+
title: t("timeTracking:error.load_active_timer", "Failed to load active timer. Please check your connection and try again.")
|
|
48322
|
+
})
|
|
48296
48323
|
})
|
|
48297
|
-
})
|
|
48298
|
-
}
|
|
48324
|
+
});
|
|
48325
|
+
}
|
|
48299
48326
|
if (activeEntry) return /* @__PURE__ */ jsx(ActiveTimeTrackerBanner, {
|
|
48300
48327
|
activeEntry,
|
|
48301
48328
|
timerDisplayValue
|
|
@@ -48482,7 +48509,8 @@ var TimeEntriesTableHeader = () => {
|
|
|
48482
48509
|
placeholder: t("timeTracking:label.all_services", "All Services"),
|
|
48483
48510
|
showLabel: false,
|
|
48484
48511
|
allowArchived: true,
|
|
48485
|
-
inline: true
|
|
48512
|
+
inline: true,
|
|
48513
|
+
hideSpecifiedIdNotFoundError: true
|
|
48486
48514
|
}), /* @__PURE__ */ jsx(CustomerSelector, {
|
|
48487
48515
|
selectedCustomer,
|
|
48488
48516
|
onSelectedCustomerChange: setSelectedCustomer,
|
|
@@ -48490,7 +48518,8 @@ var TimeEntriesTableHeader = () => {
|
|
|
48490
48518
|
className: "Layer__TimeEntriesTable__FilterCustomer",
|
|
48491
48519
|
placeholder: t("timeTracking:label.all_customers", "All Customers"),
|
|
48492
48520
|
showLabel: false,
|
|
48493
|
-
inline: true
|
|
48521
|
+
inline: true,
|
|
48522
|
+
hideSpecifiedIdNotFoundError: true
|
|
48494
48523
|
})]
|
|
48495
48524
|
}), [
|
|
48496
48525
|
selectedCustomer,
|
|
@@ -48762,7 +48791,8 @@ var TimeEntryCustomerField = ({ value, entryCustomer, isReadOnly, onChange }) =>
|
|
|
48762
48791
|
inline: true,
|
|
48763
48792
|
label: t("timeTracking:label.customer_optional", "Customer (optional)"),
|
|
48764
48793
|
placeholder: t("timeTracking:label.select_customer_short", "Select a customer"),
|
|
48765
|
-
className: "Layer__TimeEntryForm__Field__Customer"
|
|
48794
|
+
className: "Layer__TimeEntryForm__Field__Customer",
|
|
48795
|
+
hideSpecifiedIdNotFoundError: true
|
|
48766
48796
|
});
|
|
48767
48797
|
};
|
|
48768
48798
|
var TimeEntryForm = ({ onSuccess, entry, isReadOnly }) => {
|
|
@@ -48830,7 +48860,8 @@ var TimeEntryForm = ({ onSuccess, entry, isReadOnly }) => {
|
|
|
48830
48860
|
inline: true,
|
|
48831
48861
|
className: "Layer__TimeEntryForm__Field__Service",
|
|
48832
48862
|
isCreatable: !isReadOnly,
|
|
48833
|
-
onCreateService: handleCreateService
|
|
48863
|
+
onCreateService: handleCreateService,
|
|
48864
|
+
hideSpecifiedIdNotFoundError: true
|
|
48834
48865
|
})
|
|
48835
48866
|
}),
|
|
48836
48867
|
/* @__PURE__ */ jsx(form.Field, {
|
|
@@ -49723,4 +49754,4 @@ var LayerProvider = (_ref) => {
|
|
|
49723
49754
|
});
|
|
49724
49755
|
};
|
|
49725
49756
|
//#endregion
|
|
49726
|
-
export { AccountingOverview, BalanceSheet, BankTransactions, BankTransactionsWithLinkedAccounts, BookkeepingOverview, BookkeepingUpsellBar, ChartOfAccounts, Direction, DisplayState, EntityName, GeneralLedgerView, GlobalDateRangeSelection, GlobalMonthPicker, Integrations, Invoices, Journal, LandingPage, LayerProvider, LinkAccounts, LinkedAccounts, Onboarding, ProfitAndLoss, ProfitAndLossView, ProjectProfitabilityView, Reports, StatementOfCashFlow, SupportedLocale, Tasks, TimeTracking, UnifiedReports, MileageSummaryCard as unstable_MileageSummaryCard, unstable_MileageTracking,
|
|
49757
|
+
export { AccountingOverview, BalanceSheet, BankTransactions, BankTransactionsWithLinkedAccounts, BookkeepingOverview, BookkeepingUpsellBar, ChartOfAccounts, Direction, DisplayState, EntityName, GeneralLedgerView, GlobalDateRangeSelection, GlobalMonthPicker, Integrations, Invoices, Journal, LandingPage, LayerProvider, LinkAccounts, LinkedAccounts, Onboarding, ProfitAndLoss, ProfitAndLossView, ProjectProfitabilityView, Reports, SolopreneurOverview, StatementOfCashFlow, SupportedLocale, Tasks, TaxEstimates, TimeTracking, UnifiedReports, MileageSummaryCard as unstable_MileageSummaryCard, unstable_MileageTracking, useLayerContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1022,6 +1022,8 @@ declare const _SIZE_VARIANTS: readonly ["sm", "lg"];
|
|
|
1022
1022
|
|
|
1023
1023
|
declare type SizeVariant = (typeof _SIZE_VARIANTS)[number];
|
|
1024
1024
|
|
|
1025
|
+
export declare const SolopreneurOverview: ({ interactionProps, chartColorsList, stringOverrides, }: SolopreneurOverviewProps) => JSX_2.Element;
|
|
1026
|
+
|
|
1025
1027
|
declare interface SolopreneurOverviewInteractionProps {
|
|
1026
1028
|
banner?: {
|
|
1027
1029
|
onSetupTaxProfile?: () => void;
|
|
@@ -1136,6 +1138,8 @@ declare interface TasksStringOverrides {
|
|
|
1136
1138
|
header?: string;
|
|
1137
1139
|
}
|
|
1138
1140
|
|
|
1141
|
+
export declare const TaxEstimates: ({ onClickReviewTransactions: onReviewClicked }: TaxEstimatesProps) => JSX_2.Element;
|
|
1142
|
+
|
|
1139
1143
|
declare type TaxEstimatesContextProviderProps = PropsWithChildren<{
|
|
1140
1144
|
onClickReviewTransactions?: (payload: TaxEstimatesReviewTransactionsPayload) => void;
|
|
1141
1145
|
}>;
|
|
@@ -1203,10 +1207,6 @@ export declare const unstable_MileageTracking: ({ showTitle }: {
|
|
|
1203
1207
|
showTitle?: boolean;
|
|
1204
1208
|
}) => JSX_2.Element;
|
|
1205
1209
|
|
|
1206
|
-
export declare const unstable_SolopreneurOverview: ({ interactionProps, chartColorsList, stringOverrides, }: SolopreneurOverviewProps) => JSX_2.Element;
|
|
1207
|
-
|
|
1208
|
-
export declare const unstable_TaxEstimates: ({ onClickReviewTransactions: onReviewClicked }: TaxEstimatesProps) => JSX_2.Element;
|
|
1209
|
-
|
|
1210
1210
|
export declare const useLayerContext: () => LayerContextShape;
|
|
1211
1211
|
|
|
1212
1212
|
declare type Variants = Partial<{
|