@shipengine/elements 2.21.0 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/grid-controller/grid-controller.cjs +49 -17
- package/cjs/components/grid-controller/grid-controller.styles.cjs +7 -2
- package/cjs/components/grid-controller/grid-footer.cjs +30 -15
- package/cjs/components/grid-controller/grid-footer.styles.cjs +24 -0
- package/cjs/components/grid-controller/index.cjs +1 -1
- package/cjs/components/grid-controller/sortable-header/index.cjs +9 -0
- package/cjs/components/grid-controller/{sortable-header.cjs → sortable-header/sortable-header.cjs} +3 -5
- package/cjs/components/grid-controller/sortable-header/sortable-header.styles.cjs +18 -0
- package/cjs/components/grid-filters/components/created-date-filter/created-date-filter.cjs +3 -0
- package/cjs/components/grid-filters/components/index.cjs +2 -0
- package/cjs/components/grid-filters/components/label-id-filter/label-id-filter.cjs +2 -0
- package/cjs/components/grid-filters/components/label-status-filter/index.cjs +9 -0
- package/cjs/components/grid-filters/components/label-status-filter/label-status-filter-schema.cjs +12 -0
- package/cjs/components/grid-filters/components/label-status-filter/label-status-filter.cjs +174 -0
- package/cjs/components/grid-filters/components/label-status-filter/label-status-filter.styles.cjs +21 -0
- package/cjs/components/grid-filters/components/shipment-id-filter/shipment-id-filter.cjs +2 -0
- package/cjs/components/grid-filters/components/tracking-status-filter/tracking-status-filter.cjs +23 -12
- package/cjs/components/grid-filters/grid-filters.cjs +12 -1
- package/cjs/elements/labels-grid/hooks/use-labels-grid.cjs +78 -31
- package/cjs/elements/labels-grid/hooks/use-tracking-status-filter.cjs +109 -0
- package/cjs/elements/labels-grid/labels-grid.cjs +56 -30
- package/cjs/elements/purchase-label/components/customs-forms/customs-forms.cjs +10 -3
- package/cjs/elements/purchase-label/components/fund-and-purchase/fund-and-purchase.cjs +22 -14
- package/cjs/elements/purchase-label/components/rate-form/rate-form.cjs +1 -1
- package/cjs/elements/purchase-label/components/rate-form/rate-view.cjs +4 -9
- package/cjs/elements/purchase-label/components/shipment-form/shipment-form.cjs +11 -5
- package/cjs/elements/purchase-label/configure-shipment.cjs +3 -1
- package/cjs/elements/purchase-label/hooks/use-rates-form.cjs +38 -16
- package/cjs/elements/purchase-label/purchase-label.cjs +0 -1
- package/cjs/elements/shipments-grid/hooks/use-shipments-grid.cjs +11 -6
- package/cjs/elements/shipments-grid/shipments-grid.cjs +67 -28
- package/cjs/hooks/index.cjs +3 -0
- package/cjs/hooks/use-configure-shipment.cjs +1 -34
- package/cjs/hooks/use-sortable-query.cjs +36 -0
- package/cjs/index.cjs +5 -0
- package/cjs/locales/en/common.cjs +3 -1
- package/cjs/locales/en/purchase-label.cjs +2 -1
- package/cjs/package.cjs +1 -1
- package/cjs/utilities/feature-flags/feature-flags.cjs +1 -1
- package/cjs/workflows/label-workflow/label-workflow.cjs +0 -1
- package/esm/components/grid-controller/grid-controller.js +51 -19
- package/esm/components/grid-controller/grid-controller.styles.js +7 -2
- package/esm/components/grid-controller/grid-footer.js +32 -17
- package/esm/components/grid-controller/grid-footer.styles.js +20 -0
- package/esm/components/grid-controller/index.js +1 -1
- package/esm/components/grid-controller/sortable-header/index.js +1 -0
- package/esm/components/grid-controller/{sortable-header.js → sortable-header/sortable-header.js} +3 -5
- package/esm/components/grid-controller/sortable-header/sortable-header.styles.js +14 -0
- package/esm/components/grid-filters/components/created-date-filter/created-date-filter.js +3 -0
- package/esm/components/grid-filters/components/index.js +1 -0
- package/esm/components/grid-filters/components/label-id-filter/label-id-filter.js +2 -0
- package/esm/components/grid-filters/components/label-status-filter/index.js +1 -0
- package/esm/components/grid-filters/components/label-status-filter/label-status-filter-schema.js +8 -0
- package/esm/components/grid-filters/components/label-status-filter/label-status-filter.js +170 -0
- package/esm/components/grid-filters/components/label-status-filter/label-status-filter.styles.js +17 -0
- package/esm/components/grid-filters/components/shipment-id-filter/shipment-id-filter.js +2 -0
- package/esm/components/grid-filters/components/tracking-status-filter/tracking-status-filter.js +23 -12
- package/esm/components/grid-filters/grid-filters.js +12 -1
- package/esm/elements/labels-grid/hooks/use-labels-grid.js +79 -32
- package/esm/elements/labels-grid/hooks/use-tracking-status-filter.js +105 -0
- package/esm/elements/labels-grid/labels-grid.js +57 -31
- package/esm/elements/purchase-label/components/customs-forms/customs-forms.js +10 -3
- package/esm/elements/purchase-label/components/fund-and-purchase/fund-and-purchase.js +22 -14
- package/esm/elements/purchase-label/components/rate-form/rate-form.js +1 -1
- package/esm/elements/purchase-label/components/rate-form/rate-view.js +4 -9
- package/esm/elements/purchase-label/components/shipment-form/shipment-form.js +11 -5
- package/esm/elements/purchase-label/configure-shipment.js +3 -1
- package/esm/elements/purchase-label/hooks/use-rates-form.js +38 -16
- package/esm/elements/purchase-label/purchase-label.js +0 -1
- package/esm/elements/shipments-grid/hooks/use-shipments-grid.js +11 -6
- package/esm/elements/shipments-grid/shipments-grid.js +68 -29
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/use-configure-shipment.js +3 -36
- package/esm/hooks/use-sortable-query.js +32 -0
- package/esm/index.js +2 -0
- package/esm/locales/en/common.js +3 -1
- package/esm/locales/en/purchase-label.js +2 -1
- package/esm/package.js +1 -1
- package/esm/utilities/feature-flags/feature-flags.js +1 -1
- package/esm/workflows/label-workflow/label-workflow.js +0 -1
- package/package.json +15 -4
- package/types/src/components/grid-controller/grid-controller.d.ts +4 -1
- package/types/src/components/grid-controller/grid-controller.styles.d.ts +6 -1
- package/types/src/components/grid-controller/grid-footer.d.ts +9 -1
- package/types/src/components/grid-controller/grid-footer.styles.d.ts +16 -0
- package/types/src/components/grid-controller/sortable-header/index.d.ts +1 -0
- package/types/src/components/grid-controller/{sortable-header.d.ts → sortable-header/sortable-header.d.ts} +2 -2
- package/types/src/components/grid-controller/sortable-header/sortable-header.styles.d.ts +10 -0
- package/types/src/components/grid-filters/components/created-date-filter/created-date-filter.d.ts +2 -1
- package/types/src/components/grid-filters/components/index.d.ts +1 -0
- package/types/src/components/grid-filters/components/label-id-filter/label-id-filter.d.ts +2 -1
- package/types/src/components/grid-filters/components/label-status-filter/index.d.ts +1 -0
- package/types/src/components/grid-filters/components/label-status-filter/label-status-filter-schema.d.ts +12 -0
- package/types/src/components/grid-filters/components/label-status-filter/label-status-filter.d.ts +24 -0
- package/types/src/components/grid-filters/components/label-status-filter/label-status-filter.styles.d.ts +13 -0
- package/types/src/components/grid-filters/components/shipment-id-filter/shipment-id-filter.d.ts +2 -1
- package/types/src/components/grid-filters/components/tracking-status-filter/tracking-status-filter.d.ts +2 -1
- package/types/src/components/grid-filters/grid-filters.d.ts +4 -1
- package/types/src/elements/labels-grid/hooks/use-labels-grid.d.ts +5 -3
- package/types/src/elements/labels-grid/hooks/use-tracking-status-filter.d.ts +25 -0
- package/types/src/elements/labels-grid/labels-grid.d.ts +34 -20
- package/types/src/elements/manage-carriers/manage-carriers.d.ts +3 -0
- package/types/src/elements/manage-external-carriers/manage-external-carriers.d.ts +3 -0
- package/types/src/elements/manage-funding/manage-funding-element.d.ts +3 -0
- package/types/src/elements/manage-warehouses/manage-warehouses.d.ts +3 -0
- package/types/src/elements/payment-method-settings/payment-method-settings-element.d.ts +3 -0
- package/types/src/elements/purchase-label/components/fund-and-purchase/fund-and-purchase.d.ts +2 -2
- package/types/src/elements/purchase-label/hooks/use-rates-form.d.ts +1 -0
- package/types/src/elements/purchase-label/purchase-label.d.ts +12 -9
- package/types/src/elements/select-label-layout/select-label-layout-element.d.ts +3 -0
- package/types/src/elements/shipment-summary/shipment-summary.d.ts +3 -0
- package/types/src/elements/shipments-grid/hooks/use-shipments-grid.d.ts +13 -2
- package/types/src/elements/shipments-grid/shipments-grid.d.ts +41 -6
- package/types/src/elements/theme-creator/theme-creator.d.ts +3 -0
- package/types/src/elements/transaction-history/transaction-history-element.d.ts +3 -0
- package/types/src/elements/unit-settings/unit-settings-element.d.ts +3 -0
- package/types/src/elements/vat-settings/vat-settings-element.d.ts +3 -0
- package/types/src/elements/void-label/void-label.d.ts +34 -0
- package/types/src/hooks/index.d.ts +1 -0
- package/types/src/hooks/use-configure-shipment.d.ts +1 -2
- package/types/src/hooks/use-sortable-query.d.ts +13 -0
- package/types/src/index.d.ts +5 -0
- package/types/src/locales/en/index.d.ts +3 -0
- package/types/src/utilities/feature-flags/types.d.ts +5 -1
- package/types/src/workflows/account-settings/account-settings.d.ts +3 -0
- package/types/src/workflows/carrier-services/carrier-services.d.ts +3 -0
- package/types/src/workflows/connect-external-carrier/connect-external-carrier.d.ts +3 -0
- package/types/src/workflows/label-workflow/label-workflow.d.ts +11 -1
- package/types/src/workflows/onboarding/onboarding.d.ts +3 -0
package/esm/components/grid-filters/components/tracking-status-filter/tracking-status-filter.js
CHANGED
|
@@ -21,10 +21,11 @@ import { Spacer } from '../../../spacer/spacer.js';
|
|
|
21
21
|
* @see {@link TrackingStatusFilterProps | The props for the `<TrackingStatusFilter />` component}
|
|
22
22
|
*/
|
|
23
23
|
const TrackingStatusFilter = ({
|
|
24
|
+
disabled: _disabled = false,
|
|
24
25
|
filters,
|
|
25
26
|
onFiltersUpdated
|
|
26
27
|
}) => {
|
|
27
|
-
var _a;
|
|
28
|
+
var _a, _b, _c, _d;
|
|
28
29
|
const {
|
|
29
30
|
t
|
|
30
31
|
} = useTranslation();
|
|
@@ -41,21 +42,24 @@ const TrackingStatusFilter = ({
|
|
|
41
42
|
},
|
|
42
43
|
resolver: validationResolver(trackingStatusFormSchema)
|
|
43
44
|
});
|
|
44
|
-
const determineButtonText = useCallback(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const determineButtonText = useCallback(statuses => {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
if (statuses.length === 0) {
|
|
48
|
+
return ((_a = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.nickname) || t("list-labels:headers.trackingStatus");
|
|
49
|
+
} else if (statuses.length === 1) {
|
|
48
50
|
return t("common:grid.filteredTrackingStatus", {
|
|
49
|
-
filter: t(`list-labels:trackingStatus.${
|
|
51
|
+
filter: t(`list-labels:trackingStatus.${statuses[0]}`),
|
|
52
|
+
name: ((_b = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.nickname) || t("list-labels:headers.trackingStatus")
|
|
50
53
|
});
|
|
51
54
|
} else {
|
|
52
55
|
return t("common:grid.filteredTrackingStatus", {
|
|
53
|
-
filter: t(`list-labels:trackingStatus.${
|
|
56
|
+
filter: t(`list-labels:trackingStatus.${statuses[0]}`),
|
|
57
|
+
name: ((_c = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.nickname) || t("list-labels:headers.trackingStatus")
|
|
54
58
|
}) + t("common:grid.more", {
|
|
55
|
-
count:
|
|
59
|
+
count: statuses.length - 1
|
|
56
60
|
});
|
|
57
61
|
}
|
|
58
|
-
}, [t]);
|
|
62
|
+
}, [t, (_a = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.nickname]);
|
|
59
63
|
const getUpdatedKeys = useCallback(updatedFields => {
|
|
60
64
|
return Object.keys(updatedFields).filter(key => updatedFields[key]);
|
|
61
65
|
}, []);
|
|
@@ -75,9 +79,13 @@ const TrackingStatusFilter = ({
|
|
|
75
79
|
unknown: filters.trackingStatus.value.includes("unknown")
|
|
76
80
|
};
|
|
77
81
|
form.reset(updatedFields);
|
|
78
|
-
|
|
82
|
+
// Only set buttonText when filters are applied
|
|
83
|
+
const updatedKeys = getUpdatedKeys(updatedFields);
|
|
84
|
+
if (updatedKeys.length > 0) {
|
|
85
|
+
setButtonText(determineButtonText(updatedKeys));
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
|
-
}, [determineButtonText, (
|
|
88
|
+
}, [determineButtonText, (_b = filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.value, form, getUpdatedKeys]);
|
|
81
89
|
const onClearFilters = useCallback(() => {
|
|
82
90
|
onFiltersUpdated(Object.assign(Object.assign({}, filters), {
|
|
83
91
|
trackingStatus: Object.assign(Object.assign({}, filters.trackingStatus), {
|
|
@@ -105,12 +113,15 @@ const TrackingStatusFilter = ({
|
|
|
105
113
|
}, [watchedValues]);
|
|
106
114
|
return jsxs(Fragment, {
|
|
107
115
|
children: [jsxs(Button, Object.assign({
|
|
116
|
+
disabled: _disabled,
|
|
108
117
|
onClick: toggleTrackingStatusFilter,
|
|
109
118
|
ref: buttonRef,
|
|
110
119
|
variant: ButtonVariant.TEXT
|
|
111
120
|
}, {
|
|
112
|
-
children: [jsx("span", {
|
|
121
|
+
children: [isAnyCheckboxChecked ? jsx("span", {
|
|
113
122
|
children: buttonText
|
|
123
|
+
}) : jsx("span", {
|
|
124
|
+
children: (_d = (_c = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.nickname) !== null && _d !== void 0 ? _d : t("list-labels:headers.trackingStatus")
|
|
114
125
|
}), isAnyCheckboxChecked ?
|
|
115
126
|
// Show Close Icon
|
|
116
127
|
jsx(Icon, {
|
|
@@ -5,6 +5,7 @@ import { ShipmentIdFilter } from './components/shipment-id-filter/shipment-id-fi
|
|
|
5
5
|
import { LabelIdFilter } from './components/label-id-filter/label-id-filter.js';
|
|
6
6
|
import { CreatedDateFilter } from './components/created-date-filter/created-date-filter.js';
|
|
7
7
|
import { TrackingStatusFilter } from './components/tracking-status-filter/tracking-status-filter.js';
|
|
8
|
+
import { LabelStatusFilter } from './components/label-status-filter/label-status-filter.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
@@ -18,9 +19,10 @@ import { TrackingStatusFilter } from './components/tracking-status-filter/tracki
|
|
|
18
19
|
const GridFilters = ({
|
|
19
20
|
filters,
|
|
20
21
|
onFiltersUpdated,
|
|
22
|
+
filtersDisabled: _filtersDisabled = false,
|
|
21
23
|
onClearAllFilters
|
|
22
24
|
}) => {
|
|
23
|
-
var _a, _b, _c;
|
|
25
|
+
var _a, _b, _c, _d;
|
|
24
26
|
const {
|
|
25
27
|
t
|
|
26
28
|
} = useTranslation(["common"]);
|
|
@@ -37,18 +39,27 @@ const GridFilters = ({
|
|
|
37
39
|
});
|
|
38
40
|
return jsxs("section", {
|
|
39
41
|
children: [filters.shipmentId.enabled && jsx(ShipmentIdFilter, {
|
|
42
|
+
disabled: _filtersDisabled,
|
|
40
43
|
filters: filters,
|
|
41
44
|
onFiltersUpdated: onFiltersUpdated
|
|
42
45
|
}), ((_a = filters.labelId) === null || _a === void 0 ? void 0 : _a.enabled) && jsx(LabelIdFilter, {
|
|
46
|
+
disabled: _filtersDisabled,
|
|
43
47
|
filters: filters,
|
|
44
48
|
onFiltersUpdated: onFiltersUpdated
|
|
45
49
|
}), ((_b = filters.createdDate) === null || _b === void 0 ? void 0 : _b.enabled) && jsx(CreatedDateFilter, {
|
|
50
|
+
disabled: _filtersDisabled,
|
|
46
51
|
filters: filters,
|
|
47
52
|
onFiltersUpdated: onFiltersUpdated
|
|
48
53
|
}), ((_c = filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.enabled) && jsx(TrackingStatusFilter, {
|
|
54
|
+
disabled: _filtersDisabled,
|
|
55
|
+
filters: filters,
|
|
56
|
+
onFiltersUpdated: onFiltersUpdated
|
|
57
|
+
}), ((_d = filters.status) === null || _d === void 0 ? void 0 : _d.enabled) && jsx(LabelStatusFilter, {
|
|
58
|
+
disabled: _filtersDisabled,
|
|
49
59
|
filters: filters,
|
|
50
60
|
onFiltersUpdated: onFiltersUpdated
|
|
51
61
|
}), shouldShowClearAll && jsx(Button, Object.assign({
|
|
62
|
+
disabled: _filtersDisabled,
|
|
52
63
|
onClick: () => {
|
|
53
64
|
onClearAllFilters();
|
|
54
65
|
},
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
2
|
import { useGetServiceName } from '../../../hooks/use-get-service-name.js';
|
|
3
|
-
import { useState, useEffect, useMemo } from 'react';
|
|
3
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
4
4
|
import { useListLabels, useListSalesOrderShipments, useGetLabel } from '@shipengine/react-api';
|
|
5
|
+
import { useTrackingStatusFilter } from './use-tracking-status-filter.js';
|
|
5
6
|
import { usePager } from '../../../components/pager/usePager.js';
|
|
6
7
|
|
|
7
8
|
const PAGE_SIZE = 20;
|
|
8
9
|
const useLabelsGrid = ({
|
|
9
|
-
createdDateSortBy,
|
|
10
10
|
labelStatus,
|
|
11
11
|
showShipmentIdFilter,
|
|
12
12
|
showLabelIdFilter,
|
|
13
|
+
showStatusFilter,
|
|
13
14
|
showTrackingStatusFilter,
|
|
14
|
-
fetchShipments
|
|
15
|
+
fetchShipments,
|
|
16
|
+
sortDir
|
|
15
17
|
}) => {
|
|
16
|
-
var _a, _b, _c;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17
19
|
const initialFilters = {
|
|
18
20
|
labelId: {
|
|
19
21
|
enabled: !!showLabelIdFilter,
|
|
@@ -23,6 +25,10 @@ const useLabelsGrid = ({
|
|
|
23
25
|
enabled: !!showShipmentIdFilter,
|
|
24
26
|
value: ""
|
|
25
27
|
},
|
|
28
|
+
status: {
|
|
29
|
+
enabled: !!showStatusFilter,
|
|
30
|
+
value: ""
|
|
31
|
+
},
|
|
26
32
|
trackingStatus: {
|
|
27
33
|
enabled: !!showTrackingStatusFilter,
|
|
28
34
|
value: []
|
|
@@ -46,7 +52,7 @@ const useLabelsGrid = ({
|
|
|
46
52
|
pagerProps.onPageSelect(1);
|
|
47
53
|
setFilters(newFilters);
|
|
48
54
|
};
|
|
49
|
-
const hasActiveFilterValue = value => {
|
|
55
|
+
const hasActiveFilterValue = useCallback(value => {
|
|
50
56
|
if (value === null || value === undefined) {
|
|
51
57
|
return false;
|
|
52
58
|
}
|
|
@@ -60,7 +66,7 @@ const useLabelsGrid = ({
|
|
|
60
66
|
return value.trim() !== "";
|
|
61
67
|
}
|
|
62
68
|
return Boolean(value);
|
|
63
|
-
};
|
|
69
|
+
}, []);
|
|
64
70
|
const isAnyFilterActive = Object.keys(filters).some(key => {
|
|
65
71
|
const filter = filters[key];
|
|
66
72
|
return (filter === null || filter === void 0 ? void 0 : filter.enabled) && hasActiveFilterValue(filter === null || filter === void 0 ? void 0 : filter.value);
|
|
@@ -79,45 +85,75 @@ const useLabelsGrid = ({
|
|
|
79
85
|
enabled: !!showShipmentIdFilter,
|
|
80
86
|
value: ""
|
|
81
87
|
},
|
|
88
|
+
status: {
|
|
89
|
+
enabled: !!showStatusFilter,
|
|
90
|
+
value: ""
|
|
91
|
+
},
|
|
82
92
|
trackingStatus: {
|
|
83
93
|
enabled: !!showTrackingStatusFilter,
|
|
84
94
|
value: []
|
|
85
95
|
}
|
|
86
96
|
};
|
|
87
97
|
setFilters(updatedFilters);
|
|
88
|
-
}, [showLabelIdFilter, showShipmentIdFilter, showTrackingStatusFilter]);
|
|
98
|
+
}, [showLabelIdFilter, showShipmentIdFilter, showStatusFilter, showTrackingStatusFilter]);
|
|
99
|
+
const isTrackingStatusFilterActive = useMemo(() => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
return !!(((_a = filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.enabled) && hasActiveFilterValue((_b = filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.value));
|
|
102
|
+
}, [(_a = filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.enabled, (_b = filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.value, hasActiveFilterValue]);
|
|
103
|
+
// Use tracking status filter hook when the filter is active
|
|
104
|
+
const {
|
|
105
|
+
labels: trackingFilteredLabels,
|
|
106
|
+
isLoading: isTrackingFilterLoading,
|
|
107
|
+
isFetchingNextPage,
|
|
108
|
+
hasMoreUnfetchedResults,
|
|
109
|
+
paginationInfo: statusFilteredPaginationInfo
|
|
110
|
+
} = useTrackingStatusFilter({
|
|
111
|
+
currentPage: page,
|
|
112
|
+
isActive: isTrackingStatusFilterActive,
|
|
113
|
+
labelStatus: ((_c = filters.status) === null || _c === void 0 ? void 0 : _c.value) || labelStatus,
|
|
114
|
+
pageSize,
|
|
115
|
+
shipmentId: ((_d = filters.shipmentId) === null || _d === void 0 ? void 0 : _d.value) || undefined,
|
|
116
|
+
sortDir: sortDir !== null && sortDir !== void 0 ? sortDir : "desc",
|
|
117
|
+
trackingStatusFilters: ((_e = filters.trackingStatus) === null || _e === void 0 ? void 0 : _e.value) || []
|
|
118
|
+
});
|
|
119
|
+
// Use regular API pagination when tracking status filter is not active
|
|
89
120
|
const {
|
|
90
121
|
data: listLabelsData,
|
|
91
122
|
isLoading: isListLabelsLoading,
|
|
92
123
|
isError: isListLabelsError
|
|
93
124
|
} = useListLabels({
|
|
125
|
+
enabled: !isTrackingStatusFilterActive,
|
|
94
126
|
queryFnParams: {
|
|
95
|
-
labelStatus,
|
|
127
|
+
labelStatus: ((_f = filters.status) === null || _f === void 0 ? void 0 : _f.value) || labelStatus,
|
|
96
128
|
page,
|
|
97
129
|
pageSize,
|
|
98
130
|
shipmentId: filters.shipmentId.value || undefined,
|
|
99
|
-
sortDir:
|
|
131
|
+
sortDir: sortDir !== null && sortDir !== void 0 ? sortDir : "desc"
|
|
100
132
|
}
|
|
101
133
|
});
|
|
102
134
|
const labels = useMemo(() => {
|
|
135
|
+
// If tracking status filter is active, use the filtered labels from the hook
|
|
136
|
+
if (isTrackingStatusFilterActive) {
|
|
137
|
+
return trackingFilteredLabels.map(label => Object.assign(Object.assign({}, label), {
|
|
138
|
+
bodyCellStyles: {
|
|
139
|
+
color: label.status === "voided" ? theme.palette.gray[400] : undefined
|
|
140
|
+
},
|
|
141
|
+
serviceName: getServiceName(label)
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
// Otherwise, use the regular API pagination
|
|
103
145
|
if (!(listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels)) {
|
|
104
146
|
return [];
|
|
105
147
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return !((_b = (_a = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) ||
|
|
110
|
-
// Voided labels still have an in_transit tracking status, exclude them if the in_transit filter is selected
|
|
111
|
-
label.status !== "voided" && ((_c = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.value.includes(label.trackingStatus)) ||
|
|
112
|
-
// We show voided labels under tracking status also, include them if the voided filter is selected
|
|
113
|
-
label.status === "voided" && ((_d = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _d === void 0 ? void 0 : _d.value.includes(label.status));
|
|
114
|
-
}).map(label => Object.assign(Object.assign({}, label), {
|
|
148
|
+
// No need to filter by tracking status here since that's handled by useTrackingStatusFilter
|
|
149
|
+
// when the tracking status filter is active
|
|
150
|
+
return listLabelsData.labels.map(label => Object.assign(Object.assign({}, label), {
|
|
115
151
|
bodyCellStyles: {
|
|
116
152
|
color: label.status === "voided" ? theme.palette.gray[400] : undefined
|
|
117
153
|
},
|
|
118
154
|
serviceName: getServiceName(label)
|
|
119
155
|
}));
|
|
120
|
-
}, [listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels,
|
|
156
|
+
}, [isTrackingStatusFilterActive, trackingFilteredLabels, listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels, theme.palette.gray, getServiceName]);
|
|
121
157
|
const {
|
|
122
158
|
data: listShipmentsData,
|
|
123
159
|
isFetching: isListShipmentsLoading,
|
|
@@ -126,18 +162,17 @@ const useLabelsGrid = ({
|
|
|
126
162
|
// An empty array here should disable the query
|
|
127
163
|
shipmentIds: fetchShipments ? labels === null || labels === void 0 ? void 0 : labels.map(label => label.shipmentId) : []
|
|
128
164
|
});
|
|
129
|
-
const shouldShowFilters = isAnyFilterEnabled && (isAnyFilterActive || Boolean(labels === null || labels === void 0 ? void 0 : labels.length));
|
|
130
165
|
const {
|
|
131
166
|
data: labelFilterData,
|
|
132
167
|
isError: isLabelFilterError,
|
|
133
168
|
isInitialLoading: isLabelFilterLoading
|
|
134
|
-
} = useGetLabel(((
|
|
135
|
-
const isLabelFilterActive = (
|
|
169
|
+
} = useGetLabel(((_g = filters.labelId) === null || _g === void 0 ? void 0 : _g.value) || undefined);
|
|
170
|
+
const isLabelFilterActive = (_h = filters.labelId) === null || _h === void 0 ? void 0 : _h.value;
|
|
136
171
|
const isStatusFilteredOut = (status, filter) => {
|
|
137
172
|
return (filter === null || filter === void 0 ? void 0 : filter.length) && !filter.includes(status);
|
|
138
173
|
};
|
|
139
174
|
const getLabelById = labelById => {
|
|
140
|
-
var _a, _b;
|
|
175
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
141
176
|
// Check if filter by label id is active and there are no errors
|
|
142
177
|
if (isLabelFilterActive && !isLabelFilterError) {
|
|
143
178
|
let labelPassFilters = true;
|
|
@@ -145,15 +180,19 @@ const useLabelsGrid = ({
|
|
|
145
180
|
if (labelStatus && labelStatus !== (labelById === null || labelById === void 0 ? void 0 : labelById.status)) {
|
|
146
181
|
labelPassFilters = false;
|
|
147
182
|
}
|
|
183
|
+
// Check if status filter is active and if the label has the same status
|
|
184
|
+
if (((_a = filters === null || filters === void 0 ? void 0 : filters.status) === null || _a === void 0 ? void 0 : _a.enabled) && ((_b = filters === null || filters === void 0 ? void 0 : filters.status) === null || _b === void 0 ? void 0 : _b.value) && ((_c = filters === null || filters === void 0 ? void 0 : filters.status) === null || _c === void 0 ? void 0 : _c.value) !== (labelById === null || labelById === void 0 ? void 0 : labelById.status)) {
|
|
185
|
+
labelPassFilters = false;
|
|
186
|
+
}
|
|
148
187
|
// Check if shipment filter has the same value if defined
|
|
149
|
-
if ((filters === null || filters === void 0 ? void 0 : filters.shipmentId.value) !== "" && (filters === null || filters === void 0 ? void 0 : filters.shipmentId.value) !== (labelById === null || labelById === void 0 ? void 0 : labelById.shipmentId)) {
|
|
188
|
+
if (((_d = filters === null || filters === void 0 ? void 0 : filters.shipmentId) === null || _d === void 0 ? void 0 : _d.value) !== "" && ((_e = filters === null || filters === void 0 ? void 0 : filters.shipmentId) === null || _e === void 0 ? void 0 : _e.value) !== (labelById === null || labelById === void 0 ? void 0 : labelById.shipmentId)) {
|
|
150
189
|
labelPassFilters = false;
|
|
151
190
|
}
|
|
152
191
|
if (
|
|
153
192
|
// If Label status is voided and voided status is filtered out, don't show the label
|
|
154
|
-
(labelById === null || labelById === void 0 ? void 0 : labelById.status) === "voided" && isStatusFilteredOut("voided", (
|
|
193
|
+
(labelById === null || labelById === void 0 ? void 0 : labelById.status) === "voided" && isStatusFilteredOut("voided", (_f = filters.trackingStatus) === null || _f === void 0 ? void 0 : _f.value) ||
|
|
155
194
|
// If Label status is not voided and tracking status is filtered out, don't show the label
|
|
156
|
-
(labelById === null || labelById === void 0 ? void 0 : labelById.status) !== "voided" && (labelById === null || labelById === void 0 ? void 0 : labelById.trackingStatus) && isStatusFilteredOut(labelById.trackingStatus, (
|
|
195
|
+
(labelById === null || labelById === void 0 ? void 0 : labelById.status) !== "voided" && (labelById === null || labelById === void 0 ? void 0 : labelById.trackingStatus) && isStatusFilteredOut(labelById.trackingStatus, (_g = filters.trackingStatus) === null || _g === void 0 ? void 0 : _g.value)) {
|
|
157
196
|
labelPassFilters = false;
|
|
158
197
|
}
|
|
159
198
|
return labelPassFilters ? labelById : undefined;
|
|
@@ -188,20 +227,28 @@ const useLabelsGrid = ({
|
|
|
188
227
|
clearAllFilters,
|
|
189
228
|
filters,
|
|
190
229
|
getGridData,
|
|
230
|
+
hasMoreUnfetchedResults: isTrackingStatusFilterActive ? hasMoreUnfetchedResults : false,
|
|
191
231
|
isAnyFilterActive,
|
|
192
232
|
isError: isListLabelsError || isListShipmentsError && fetchShipments,
|
|
193
|
-
|
|
233
|
+
isFetchingNextPage: isTrackingStatusFilterActive ? isFetchingNextPage : false,
|
|
234
|
+
// Calculate isLoading based on which query should be active
|
|
235
|
+
isLoading:
|
|
236
|
+
// Always include label filter loading when label ID filter is active
|
|
237
|
+
isLabelFilterActive && isLabelFilterLoading || (
|
|
238
|
+
// For tracking status filter
|
|
239
|
+
isTrackingStatusFilterActive ? isTrackingFilterLoading // Use tracking filter loading when active
|
|
240
|
+
: isListLabelsLoading || isListShipmentsLoading && fetchShipments),
|
|
194
241
|
labels,
|
|
195
242
|
pageConfig: {
|
|
196
|
-
currentPage: labelFilteredById ? 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.page) || 0,
|
|
243
|
+
currentPage: labelFilteredById ? 1 : isTrackingStatusFilterActive ? statusFilteredPaginationInfo.currentPage : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.page) || 0,
|
|
197
244
|
pagerProps,
|
|
198
|
-
pagesAmount: (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.pages) || 0,
|
|
245
|
+
pagesAmount: labelFilteredById ? 1 : isTrackingStatusFilterActive ? (statusFilteredPaginationInfo === null || statusFilteredPaginationInfo === void 0 ? void 0 : statusFilteredPaginationInfo.totalPages) || 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.pages) || 0,
|
|
199
246
|
pageSize,
|
|
200
|
-
showPagination: labelFilteredById ? false : ((listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0) > pageSize,
|
|
201
|
-
totalElements: labelFilteredById ? 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0
|
|
247
|
+
showPagination: labelFilteredById ? false : isTrackingStatusFilterActive ? ((statusFilteredPaginationInfo === null || statusFilteredPaginationInfo === void 0 ? void 0 : statusFilteredPaginationInfo.totalCount) || 0) > pageSize : ((listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0) > pageSize,
|
|
248
|
+
totalElements: labelFilteredById ? 1 : isTrackingStatusFilterActive ? (statusFilteredPaginationInfo === null || statusFilteredPaginationInfo === void 0 ? void 0 : statusFilteredPaginationInfo.totalCount) || 0 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0
|
|
202
249
|
},
|
|
203
250
|
setFilters: onSetFilters,
|
|
204
|
-
shouldShowFilters
|
|
251
|
+
shouldShowFilters: isAnyFilterEnabled
|
|
205
252
|
};
|
|
206
253
|
};
|
|
207
254
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { useListLabelsInfinite } from '@shipengine/react-api';
|
|
3
|
+
|
|
4
|
+
const MIN_RESULTS = 20; // Minimum number of filtered results needed to stop fetching
|
|
5
|
+
const MAX_PAGES = 5; // Maximum number of pages to fetch if we have enough results
|
|
6
|
+
const useTrackingStatusFilter = ({
|
|
7
|
+
isActive,
|
|
8
|
+
labelStatus,
|
|
9
|
+
shipmentId,
|
|
10
|
+
trackingStatusFilters,
|
|
11
|
+
sortDir,
|
|
12
|
+
currentPage,
|
|
13
|
+
pageSize
|
|
14
|
+
}) => {
|
|
15
|
+
const [allLabels, setAllLabels] = useState([]);
|
|
16
|
+
const {
|
|
17
|
+
data: infiniteData,
|
|
18
|
+
fetchNextPage,
|
|
19
|
+
hasNextPage,
|
|
20
|
+
isLoading,
|
|
21
|
+
isFetchingNextPage
|
|
22
|
+
} = useListLabelsInfinite({
|
|
23
|
+
enabled: isActive,
|
|
24
|
+
queryFnParams: {
|
|
25
|
+
labelStatus,
|
|
26
|
+
pageSize: 100,
|
|
27
|
+
shipmentId,
|
|
28
|
+
sortDir
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isActive && (infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages)) {
|
|
33
|
+
const allLabelsFromPages = infiniteData.pages.flatMap(page => page.labels || []);
|
|
34
|
+
setAllLabels(allLabelsFromPages);
|
|
35
|
+
}
|
|
36
|
+
}, [isActive, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages]);
|
|
37
|
+
const filteredLabels = useMemo(() => {
|
|
38
|
+
if (!isActive || !trackingStatusFilters.length) {
|
|
39
|
+
return allLabels;
|
|
40
|
+
}
|
|
41
|
+
return allLabels.filter(label => {
|
|
42
|
+
if (label.status === "voided") {
|
|
43
|
+
return trackingStatusFilters.includes("voided");
|
|
44
|
+
}
|
|
45
|
+
return trackingStatusFilters.includes(label.trackingStatus);
|
|
46
|
+
});
|
|
47
|
+
}, [isActive, allLabels, trackingStatusFilters]);
|
|
48
|
+
const totalCount = filteredLabels.length;
|
|
49
|
+
const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
50
|
+
const paginatedLabels = useMemo(() => {
|
|
51
|
+
const startIndex = (currentPage - 1) * pageSize;
|
|
52
|
+
const endIndex = Math.min(startIndex + pageSize, filteredLabels.length);
|
|
53
|
+
return filteredLabels.slice(startIndex, endIndex);
|
|
54
|
+
}, [filteredLabels, currentPage, pageSize]);
|
|
55
|
+
// Check if we have enough data for the next page
|
|
56
|
+
const hasDataForNextPage = useMemo(() => {
|
|
57
|
+
const nextPageStart = currentPage * pageSize;
|
|
58
|
+
return nextPageStart < filteredLabels.length;
|
|
59
|
+
}, [currentPage, pageSize, filteredLabels.length]);
|
|
60
|
+
// Check if we have more unfetched results
|
|
61
|
+
const hasMoreUnfetchedResults = useMemo(() => {
|
|
62
|
+
return hasNextPage && (infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages) && infiniteData.pages.length >= MAX_PAGES && filteredLabels.length >= MIN_RESULTS;
|
|
63
|
+
}, [hasNextPage, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages, filteredLabels.length]);
|
|
64
|
+
// Trigger fetchNextPage
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
// Don't fetch if not active or already fetching
|
|
67
|
+
if (!isActive || isFetchingNextPage) return;
|
|
68
|
+
// Continue fetching if we don't have minimum results yet
|
|
69
|
+
if (filteredLabels.length < MIN_RESULTS && hasNextPage) {
|
|
70
|
+
fetchNextPage();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Continue fetching if we don't have data for the next page
|
|
74
|
+
if (!hasDataForNextPage && hasNextPage) {
|
|
75
|
+
fetchNextPage();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Stop fetching if we've reached max pages and have enough results
|
|
79
|
+
if ((infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages) && infiniteData.pages.length >= MAX_PAGES && filteredLabels.length >= MIN_RESULTS && hasDataForNextPage) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Otherwise, fetch next page if available
|
|
83
|
+
if (hasNextPage) {
|
|
84
|
+
fetchNextPage();
|
|
85
|
+
}
|
|
86
|
+
}, [isActive, currentPage, pageSize, filteredLabels.length, hasNextPage, isFetchingNextPage, fetchNextPage, hasDataForNextPage, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages]);
|
|
87
|
+
return {
|
|
88
|
+
allLabelsCount: totalCount,
|
|
89
|
+
fetchNextPage,
|
|
90
|
+
filteredLabelsCount: totalCount,
|
|
91
|
+
hasMorePages: hasNextPage,
|
|
92
|
+
hasMoreUnfetchedResults,
|
|
93
|
+
isFetchingNextPage,
|
|
94
|
+
isLoading: isLoading || filteredLabels.length === 0 && isFetchingNextPage,
|
|
95
|
+
labels: paginatedLabels,
|
|
96
|
+
paginationInfo: {
|
|
97
|
+
currentPage,
|
|
98
|
+
pageSize,
|
|
99
|
+
totalCount,
|
|
100
|
+
totalPages
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { useTrackingStatusFilter };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useSortableQuery } from '../../hooks/use-sortable-query.js';
|
|
3
|
+
import { useRef, useMemo, useEffect, useCallback } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { TagColor, Next, Typography, Tag, TagVariant, EmptyState, Button } from '@shipengine/giger';
|
|
5
6
|
import { useLabelsGrid } from './hooks/use-labels-grid.js';
|
|
6
7
|
import { styles } from './labels-grid.styles.js';
|
|
7
|
-
import { SortableHeader } from '../../components/grid-controller/sortable-header.js';
|
|
8
|
+
import { SortableHeader } from '../../components/grid-controller/sortable-header/sortable-header.js';
|
|
8
9
|
import { CellFormattedDate } from '../../components/grid-controller/cell-formatted-date.js';
|
|
9
10
|
import { ActionsMenu, Actions } from '../../components/actions-menu/actions-menu.js';
|
|
10
11
|
import { ErrorState } from '../../components/error-state/error-state.js';
|
|
@@ -13,7 +14,6 @@ import { GridFilters } from '../../components/grid-filters/grid-filters.js';
|
|
|
13
14
|
import { GridFooter } from '../../components/grid-controller/grid-footer.js';
|
|
14
15
|
import en from '../../locales/en/index.js';
|
|
15
16
|
import { useElements } from '../../elements-provider/elements-context-provider.js';
|
|
16
|
-
import { Loader } from '../../components/loader/loader.js';
|
|
17
17
|
import { Spacer } from '../../components/spacer/spacer.js';
|
|
18
18
|
import { PoweredByShipEngine } from '../../components/powered-by-shipengine/powered-by-shipengine.js';
|
|
19
19
|
import { createElement } from '../../create-element/create-element.js';
|
|
@@ -41,7 +41,13 @@ const Component = ({
|
|
|
41
41
|
} = useElements();
|
|
42
42
|
const defaultFeatures = getFeatures("labelsGridFeatures");
|
|
43
43
|
const prevStatus = useRef(labelStatus);
|
|
44
|
-
const
|
|
44
|
+
const {
|
|
45
|
+
toggleSort,
|
|
46
|
+
sortState
|
|
47
|
+
} = useSortableQuery({
|
|
48
|
+
defaultSortBy: "modified_at",
|
|
49
|
+
defaultSortDir: "desc"
|
|
50
|
+
});
|
|
45
51
|
features = Object.assign(Object.assign({}, defaultFeatures), features !== null && features !== void 0 ? features : {});
|
|
46
52
|
const labelIdColumn = useMemo(() => {
|
|
47
53
|
var _a;
|
|
@@ -59,14 +65,21 @@ const Component = ({
|
|
|
59
65
|
var _a;
|
|
60
66
|
return (_a = features === null || features === void 0 ? void 0 : features.columns) === null || _a === void 0 ? void 0 : _a.find(c => c.name === "shipmentNumber");
|
|
61
67
|
}, [features]);
|
|
68
|
+
const statusColumn = useMemo(() => {
|
|
69
|
+
var _a;
|
|
70
|
+
return (_a = features === null || features === void 0 ? void 0 : features.columns) === null || _a === void 0 ? void 0 : _a.find(c => c.name === "status");
|
|
71
|
+
}, [features]);
|
|
62
72
|
const showLabelIdFilter = labelIdColumn && ((_a = labelIdColumn.allowFilter) !== null && _a !== void 0 ? _a : true);
|
|
63
73
|
const showShipmentIdFilter = shipmentIdColumn && ((_b = shipmentIdColumn.allowFilter) !== null && _b !== void 0 ? _b : true);
|
|
64
|
-
const
|
|
74
|
+
const showStatusFilter = statusColumn && ((_c = statusColumn.allowFilter) !== null && _c !== void 0 ? _c : true);
|
|
75
|
+
const showTrackingStatusFilter = trackingStatusColumn && !!trackingStatusColumn.allowFilter;
|
|
65
76
|
const {
|
|
66
77
|
labels,
|
|
67
78
|
getGridData,
|
|
68
79
|
isError,
|
|
69
80
|
isLoading,
|
|
81
|
+
isFetchingNextPage,
|
|
82
|
+
hasMoreUnfetchedResults,
|
|
70
83
|
filters,
|
|
71
84
|
setFilters,
|
|
72
85
|
pageConfig,
|
|
@@ -74,12 +87,13 @@ const Component = ({
|
|
|
74
87
|
shouldShowFilters,
|
|
75
88
|
clearAllFilters
|
|
76
89
|
} = useLabelsGrid({
|
|
77
|
-
createdDateSortBy,
|
|
78
90
|
fetchShipments: !!shipmentNumberColumn,
|
|
79
91
|
labelStatus,
|
|
80
92
|
showLabelIdFilter,
|
|
81
93
|
showShipmentIdFilter,
|
|
82
|
-
|
|
94
|
+
showStatusFilter,
|
|
95
|
+
showTrackingStatusFilter,
|
|
96
|
+
sortDir: sortState.dir
|
|
83
97
|
});
|
|
84
98
|
useEffect(() => {
|
|
85
99
|
if (prevStatus.current !== labelStatus) {
|
|
@@ -95,14 +109,17 @@ const Component = ({
|
|
|
95
109
|
shipmentId: Object.assign(Object.assign({}, filters.shipmentId), {
|
|
96
110
|
nickname: shipmentIdColumn === null || shipmentIdColumn === void 0 ? void 0 : shipmentIdColumn.nickname
|
|
97
111
|
}),
|
|
112
|
+
status: Object.assign(Object.assign({}, filters.status), {
|
|
113
|
+
nickname: statusColumn === null || statusColumn === void 0 ? void 0 : statusColumn.nickname
|
|
114
|
+
}),
|
|
98
115
|
trackingStatus: Object.assign(Object.assign({}, filters.trackingStatus), {
|
|
99
116
|
nickname: trackingStatusColumn === null || trackingStatusColumn === void 0 ? void 0 : trackingStatusColumn.nickname
|
|
100
117
|
})
|
|
101
118
|
};
|
|
102
|
-
}, [filters, labelIdColumn, shipmentIdColumn, trackingStatusColumn]);
|
|
119
|
+
}, [filters, labelIdColumn, shipmentIdColumn, statusColumn, trackingStatusColumn]);
|
|
103
120
|
const toggleCreatedDateSort = useCallback(() => {
|
|
104
|
-
|
|
105
|
-
}, [
|
|
121
|
+
toggleSort("created_at");
|
|
122
|
+
}, [toggleSort]);
|
|
106
123
|
const columns = useMemo(() => {
|
|
107
124
|
var _a;
|
|
108
125
|
const labelTags = {
|
|
@@ -146,7 +163,7 @@ const Component = ({
|
|
|
146
163
|
headerContent: jsx(SortableHeader, {
|
|
147
164
|
headerText: t("list-labels:headers.created"),
|
|
148
165
|
onToggleSort: toggleCreatedDateSort,
|
|
149
|
-
sortDirection:
|
|
166
|
+
sortDirection: sortState.createdAtDir
|
|
150
167
|
}),
|
|
151
168
|
renderCellContent: label => {
|
|
152
169
|
return jsx(CellFormattedDate, {
|
|
@@ -374,24 +391,13 @@ const Component = ({
|
|
|
374
391
|
});
|
|
375
392
|
}
|
|
376
393
|
return cols;
|
|
377
|
-
}, [t, toggleCreatedDateSort,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return jsx(ErrorState, {
|
|
385
|
-
css: styles.errorState,
|
|
386
|
-
subtitle: [t("list-labels:errorMessages.subtitle"), t("errorMessages.refreshAndTryAgain")],
|
|
387
|
-
title: t("list-labels:errorMessages.title")
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
return jsxs(Fragment, {
|
|
391
|
-
children: [jsx(GridController, {
|
|
392
|
-
columns: columns,
|
|
393
|
-
data: getGridData(),
|
|
394
|
-
emptyContent: isAnyFilterActive ? jsx(EmptyState, Object.assign({
|
|
394
|
+
}, [t, toggleCreatedDateSort, sortState.createdAtDir, features === null || features === void 0 ? void 0 : features.columns, features === null || features === void 0 ? void 0 : features.showActions, labels, onClickExternalOrderId, onClickExternalShipmentId, onClickShipmentNumber, onClickVoidLabel, onClickViewDetails, onClickPrintLabel, onClickPrintForms]);
|
|
395
|
+
const emptyContentComponent = useMemo(() => {
|
|
396
|
+
if (isLoading) {
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
if (isAnyFilterActive) {
|
|
400
|
+
return jsx(EmptyState, Object.assign({
|
|
395
401
|
isElevated: false,
|
|
396
402
|
subtitle: t("list-labels:emptyWithFilters.subtitle"),
|
|
397
403
|
title: t("list-labels:emptyWithFilters.title")
|
|
@@ -401,17 +407,36 @@ const Component = ({
|
|
|
401
407
|
}, {
|
|
402
408
|
children: t("list-labels:emptyWithFilters.button")
|
|
403
409
|
}))
|
|
404
|
-
}))
|
|
410
|
+
}));
|
|
411
|
+
} else {
|
|
412
|
+
return jsx(EmptyState, {
|
|
405
413
|
isElevated: false,
|
|
406
414
|
subtitle: t("list-labels:empty.subtitle"),
|
|
407
415
|
title: t("list-labels:empty.title")
|
|
408
|
-
})
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}, [clearAllFilters, isAnyFilterActive, isLoading, t]);
|
|
419
|
+
if (isError) {
|
|
420
|
+
return jsx(ErrorState, {
|
|
421
|
+
css: styles.errorState,
|
|
422
|
+
subtitle: [t("list-labels:errorMessages.subtitle"), t("errorMessages.refreshAndTryAgain")],
|
|
423
|
+
title: t("list-labels:errorMessages.title")
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
return jsxs(Fragment, {
|
|
427
|
+
children: [jsx(GridController, {
|
|
428
|
+
columns: columns,
|
|
429
|
+
data: getGridData(),
|
|
430
|
+
emptyContent: emptyContentComponent,
|
|
409
431
|
filters: shouldShowFilters && jsx(GridFilters, {
|
|
410
432
|
filters: gridFilters,
|
|
433
|
+
filtersDisabled: isLoading,
|
|
411
434
|
onClearAllFilters: clearAllFilters,
|
|
412
435
|
onFiltersUpdated: setFilters
|
|
413
436
|
}),
|
|
414
437
|
footerContent: jsx(GridFooter, {
|
|
438
|
+
hasMoreUnfetchedResults: hasMoreUnfetchedResults,
|
|
439
|
+
isLoadingMore: isFetchingNextPage,
|
|
415
440
|
onPageChange: pageConfig.pagerProps.onPageSelect,
|
|
416
441
|
page: pageConfig.currentPage,
|
|
417
442
|
pages: pageConfig.pagesAmount,
|
|
@@ -419,6 +444,7 @@ const Component = ({
|
|
|
419
444
|
showPagination: pageConfig.showPagination,
|
|
420
445
|
total: pageConfig.totalElements
|
|
421
446
|
}),
|
|
447
|
+
isLoading: isLoading,
|
|
422
448
|
onRowClick: onRowClick
|
|
423
449
|
}), globalFeatures.poweredByShipEngine && jsxs(Fragment, {
|
|
424
450
|
children: [jsx(Spacer, {}), jsx(PoweredByShipEngine, {})]
|