@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
|
@@ -9,6 +9,7 @@ var shipmentIdFilter = require('./components/shipment-id-filter/shipment-id-filt
|
|
|
9
9
|
var labelIdFilter = require('./components/label-id-filter/label-id-filter.cjs');
|
|
10
10
|
var createdDateFilter = require('./components/created-date-filter/created-date-filter.cjs');
|
|
11
11
|
var trackingStatusFilter = require('./components/tracking-status-filter/tracking-status-filter.cjs');
|
|
12
|
+
var labelStatusFilter = require('./components/label-status-filter/label-status-filter.cjs');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @internal
|
|
@@ -22,9 +23,10 @@ var trackingStatusFilter = require('./components/tracking-status-filter/tracking
|
|
|
22
23
|
const GridFilters = ({
|
|
23
24
|
filters,
|
|
24
25
|
onFiltersUpdated,
|
|
26
|
+
filtersDisabled: _filtersDisabled = false,
|
|
25
27
|
onClearAllFilters
|
|
26
28
|
}) => {
|
|
27
|
-
var _a, _b, _c;
|
|
29
|
+
var _a, _b, _c, _d;
|
|
28
30
|
const {
|
|
29
31
|
t
|
|
30
32
|
} = reactI18next.useTranslation(["common"]);
|
|
@@ -41,18 +43,27 @@ const GridFilters = ({
|
|
|
41
43
|
});
|
|
42
44
|
return jsxRuntime.jsxs("section", {
|
|
43
45
|
children: [filters.shipmentId.enabled && jsxRuntime.jsx(shipmentIdFilter.ShipmentIdFilter, {
|
|
46
|
+
disabled: _filtersDisabled,
|
|
44
47
|
filters: filters,
|
|
45
48
|
onFiltersUpdated: onFiltersUpdated
|
|
46
49
|
}), ((_a = filters.labelId) === null || _a === void 0 ? void 0 : _a.enabled) && jsxRuntime.jsx(labelIdFilter.LabelIdFilter, {
|
|
50
|
+
disabled: _filtersDisabled,
|
|
47
51
|
filters: filters,
|
|
48
52
|
onFiltersUpdated: onFiltersUpdated
|
|
49
53
|
}), ((_b = filters.createdDate) === null || _b === void 0 ? void 0 : _b.enabled) && jsxRuntime.jsx(createdDateFilter.CreatedDateFilter, {
|
|
54
|
+
disabled: _filtersDisabled,
|
|
50
55
|
filters: filters,
|
|
51
56
|
onFiltersUpdated: onFiltersUpdated
|
|
52
57
|
}), ((_c = filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.enabled) && jsxRuntime.jsx(trackingStatusFilter.TrackingStatusFilter, {
|
|
58
|
+
disabled: _filtersDisabled,
|
|
59
|
+
filters: filters,
|
|
60
|
+
onFiltersUpdated: onFiltersUpdated
|
|
61
|
+
}), ((_d = filters.status) === null || _d === void 0 ? void 0 : _d.enabled) && jsxRuntime.jsx(labelStatusFilter.LabelStatusFilter, {
|
|
62
|
+
disabled: _filtersDisabled,
|
|
53
63
|
filters: filters,
|
|
54
64
|
onFiltersUpdated: onFiltersUpdated
|
|
55
65
|
}), shouldShowClearAll && jsxRuntime.jsx(giger.Button, Object.assign({
|
|
66
|
+
disabled: _filtersDisabled,
|
|
56
67
|
onClick: () => {
|
|
57
68
|
onClearAllFilters();
|
|
58
69
|
},
|
|
@@ -6,18 +6,20 @@ var react = require('@emotion/react');
|
|
|
6
6
|
var useGetServiceName = require('../../../hooks/use-get-service-name.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactApi = require('@shipengine/react-api');
|
|
9
|
+
var useTrackingStatusFilter = require('./use-tracking-status-filter.cjs');
|
|
9
10
|
var usePager = require('../../../components/pager/usePager.cjs');
|
|
10
11
|
|
|
11
12
|
const PAGE_SIZE = 20;
|
|
12
13
|
const useLabelsGrid = ({
|
|
13
|
-
createdDateSortBy,
|
|
14
14
|
labelStatus,
|
|
15
15
|
showShipmentIdFilter,
|
|
16
16
|
showLabelIdFilter,
|
|
17
|
+
showStatusFilter,
|
|
17
18
|
showTrackingStatusFilter,
|
|
18
|
-
fetchShipments
|
|
19
|
+
fetchShipments,
|
|
20
|
+
sortDir
|
|
19
21
|
}) => {
|
|
20
|
-
var _a, _b, _c;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
23
|
const initialFilters = {
|
|
22
24
|
labelId: {
|
|
23
25
|
enabled: !!showLabelIdFilter,
|
|
@@ -27,6 +29,10 @@ const useLabelsGrid = ({
|
|
|
27
29
|
enabled: !!showShipmentIdFilter,
|
|
28
30
|
value: ""
|
|
29
31
|
},
|
|
32
|
+
status: {
|
|
33
|
+
enabled: !!showStatusFilter,
|
|
34
|
+
value: ""
|
|
35
|
+
},
|
|
30
36
|
trackingStatus: {
|
|
31
37
|
enabled: !!showTrackingStatusFilter,
|
|
32
38
|
value: []
|
|
@@ -50,7 +56,7 @@ const useLabelsGrid = ({
|
|
|
50
56
|
pagerProps.onPageSelect(1);
|
|
51
57
|
setFilters(newFilters);
|
|
52
58
|
};
|
|
53
|
-
const hasActiveFilterValue = value => {
|
|
59
|
+
const hasActiveFilterValue = React.useCallback(value => {
|
|
54
60
|
if (value === null || value === undefined) {
|
|
55
61
|
return false;
|
|
56
62
|
}
|
|
@@ -64,7 +70,7 @@ const useLabelsGrid = ({
|
|
|
64
70
|
return value.trim() !== "";
|
|
65
71
|
}
|
|
66
72
|
return Boolean(value);
|
|
67
|
-
};
|
|
73
|
+
}, []);
|
|
68
74
|
const isAnyFilterActive = Object.keys(filters).some(key => {
|
|
69
75
|
const filter = filters[key];
|
|
70
76
|
return (filter === null || filter === void 0 ? void 0 : filter.enabled) && hasActiveFilterValue(filter === null || filter === void 0 ? void 0 : filter.value);
|
|
@@ -83,45 +89,75 @@ const useLabelsGrid = ({
|
|
|
83
89
|
enabled: !!showShipmentIdFilter,
|
|
84
90
|
value: ""
|
|
85
91
|
},
|
|
92
|
+
status: {
|
|
93
|
+
enabled: !!showStatusFilter,
|
|
94
|
+
value: ""
|
|
95
|
+
},
|
|
86
96
|
trackingStatus: {
|
|
87
97
|
enabled: !!showTrackingStatusFilter,
|
|
88
98
|
value: []
|
|
89
99
|
}
|
|
90
100
|
};
|
|
91
101
|
setFilters(updatedFilters);
|
|
92
|
-
}, [showLabelIdFilter, showShipmentIdFilter, showTrackingStatusFilter]);
|
|
102
|
+
}, [showLabelIdFilter, showShipmentIdFilter, showStatusFilter, showTrackingStatusFilter]);
|
|
103
|
+
const isTrackingStatusFilterActive = React.useMemo(() => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
return !!(((_a = filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.enabled) && hasActiveFilterValue((_b = filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.value));
|
|
106
|
+
}, [(_a = filters.trackingStatus) === null || _a === void 0 ? void 0 : _a.enabled, (_b = filters.trackingStatus) === null || _b === void 0 ? void 0 : _b.value, hasActiveFilterValue]);
|
|
107
|
+
// Use tracking status filter hook when the filter is active
|
|
108
|
+
const {
|
|
109
|
+
labels: trackingFilteredLabels,
|
|
110
|
+
isLoading: isTrackingFilterLoading,
|
|
111
|
+
isFetchingNextPage,
|
|
112
|
+
hasMoreUnfetchedResults,
|
|
113
|
+
paginationInfo: statusFilteredPaginationInfo
|
|
114
|
+
} = useTrackingStatusFilter.useTrackingStatusFilter({
|
|
115
|
+
currentPage: page,
|
|
116
|
+
isActive: isTrackingStatusFilterActive,
|
|
117
|
+
labelStatus: ((_c = filters.status) === null || _c === void 0 ? void 0 : _c.value) || labelStatus,
|
|
118
|
+
pageSize,
|
|
119
|
+
shipmentId: ((_d = filters.shipmentId) === null || _d === void 0 ? void 0 : _d.value) || undefined,
|
|
120
|
+
sortDir: sortDir !== null && sortDir !== void 0 ? sortDir : "desc",
|
|
121
|
+
trackingStatusFilters: ((_e = filters.trackingStatus) === null || _e === void 0 ? void 0 : _e.value) || []
|
|
122
|
+
});
|
|
123
|
+
// Use regular API pagination when tracking status filter is not active
|
|
93
124
|
const {
|
|
94
125
|
data: listLabelsData,
|
|
95
126
|
isLoading: isListLabelsLoading,
|
|
96
127
|
isError: isListLabelsError
|
|
97
128
|
} = reactApi.useListLabels({
|
|
129
|
+
enabled: !isTrackingStatusFilterActive,
|
|
98
130
|
queryFnParams: {
|
|
99
|
-
labelStatus,
|
|
131
|
+
labelStatus: ((_f = filters.status) === null || _f === void 0 ? void 0 : _f.value) || labelStatus,
|
|
100
132
|
page,
|
|
101
133
|
pageSize,
|
|
102
134
|
shipmentId: filters.shipmentId.value || undefined,
|
|
103
|
-
sortDir:
|
|
135
|
+
sortDir: sortDir !== null && sortDir !== void 0 ? sortDir : "desc"
|
|
104
136
|
}
|
|
105
137
|
});
|
|
106
138
|
const labels = React.useMemo(() => {
|
|
139
|
+
// If tracking status filter is active, use the filtered labels from the hook
|
|
140
|
+
if (isTrackingStatusFilterActive) {
|
|
141
|
+
return trackingFilteredLabels.map(label => Object.assign(Object.assign({}, label), {
|
|
142
|
+
bodyCellStyles: {
|
|
143
|
+
color: label.status === "voided" ? theme.palette.gray[400] : undefined
|
|
144
|
+
},
|
|
145
|
+
serviceName: getServiceName(label)
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
// Otherwise, use the regular API pagination
|
|
107
149
|
if (!(listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels)) {
|
|
108
150
|
return [];
|
|
109
151
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
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) ||
|
|
114
|
-
// Voided labels still have an in_transit tracking status, exclude them if the in_transit filter is selected
|
|
115
|
-
label.status !== "voided" && ((_c = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _c === void 0 ? void 0 : _c.value.includes(label.trackingStatus)) ||
|
|
116
|
-
// We show voided labels under tracking status also, include them if the voided filter is selected
|
|
117
|
-
label.status === "voided" && ((_d = filters === null || filters === void 0 ? void 0 : filters.trackingStatus) === null || _d === void 0 ? void 0 : _d.value.includes(label.status));
|
|
118
|
-
}).map(label => Object.assign(Object.assign({}, label), {
|
|
152
|
+
// No need to filter by tracking status here since that's handled by useTrackingStatusFilter
|
|
153
|
+
// when the tracking status filter is active
|
|
154
|
+
return listLabelsData.labels.map(label => Object.assign(Object.assign({}, label), {
|
|
119
155
|
bodyCellStyles: {
|
|
120
156
|
color: label.status === "voided" ? theme.palette.gray[400] : undefined
|
|
121
157
|
},
|
|
122
158
|
serviceName: getServiceName(label)
|
|
123
159
|
}));
|
|
124
|
-
}, [listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels,
|
|
160
|
+
}, [isTrackingStatusFilterActive, trackingFilteredLabels, listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.labels, theme.palette.gray, getServiceName]);
|
|
125
161
|
const {
|
|
126
162
|
data: listShipmentsData,
|
|
127
163
|
isFetching: isListShipmentsLoading,
|
|
@@ -130,18 +166,17 @@ const useLabelsGrid = ({
|
|
|
130
166
|
// An empty array here should disable the query
|
|
131
167
|
shipmentIds: fetchShipments ? labels === null || labels === void 0 ? void 0 : labels.map(label => label.shipmentId) : []
|
|
132
168
|
});
|
|
133
|
-
const shouldShowFilters = isAnyFilterEnabled && (isAnyFilterActive || Boolean(labels === null || labels === void 0 ? void 0 : labels.length));
|
|
134
169
|
const {
|
|
135
170
|
data: labelFilterData,
|
|
136
171
|
isError: isLabelFilterError,
|
|
137
172
|
isInitialLoading: isLabelFilterLoading
|
|
138
|
-
} = reactApi.useGetLabel(((
|
|
139
|
-
const isLabelFilterActive = (
|
|
173
|
+
} = reactApi.useGetLabel(((_g = filters.labelId) === null || _g === void 0 ? void 0 : _g.value) || undefined);
|
|
174
|
+
const isLabelFilterActive = (_h = filters.labelId) === null || _h === void 0 ? void 0 : _h.value;
|
|
140
175
|
const isStatusFilteredOut = (status, filter) => {
|
|
141
176
|
return (filter === null || filter === void 0 ? void 0 : filter.length) && !filter.includes(status);
|
|
142
177
|
};
|
|
143
178
|
const getLabelById = labelById => {
|
|
144
|
-
var _a, _b;
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
145
180
|
// Check if filter by label id is active and there are no errors
|
|
146
181
|
if (isLabelFilterActive && !isLabelFilterError) {
|
|
147
182
|
let labelPassFilters = true;
|
|
@@ -149,15 +184,19 @@ const useLabelsGrid = ({
|
|
|
149
184
|
if (labelStatus && labelStatus !== (labelById === null || labelById === void 0 ? void 0 : labelById.status)) {
|
|
150
185
|
labelPassFilters = false;
|
|
151
186
|
}
|
|
187
|
+
// Check if status filter is active and if the label has the same status
|
|
188
|
+
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)) {
|
|
189
|
+
labelPassFilters = false;
|
|
190
|
+
}
|
|
152
191
|
// Check if shipment filter has the same value if defined
|
|
153
|
-
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)) {
|
|
192
|
+
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)) {
|
|
154
193
|
labelPassFilters = false;
|
|
155
194
|
}
|
|
156
195
|
if (
|
|
157
196
|
// If Label status is voided and voided status is filtered out, don't show the label
|
|
158
|
-
(labelById === null || labelById === void 0 ? void 0 : labelById.status) === "voided" && isStatusFilteredOut("voided", (
|
|
197
|
+
(labelById === null || labelById === void 0 ? void 0 : labelById.status) === "voided" && isStatusFilteredOut("voided", (_f = filters.trackingStatus) === null || _f === void 0 ? void 0 : _f.value) ||
|
|
159
198
|
// If Label status is not voided and tracking status is filtered out, don't show the label
|
|
160
|
-
(labelById === null || labelById === void 0 ? void 0 : labelById.status) !== "voided" && (labelById === null || labelById === void 0 ? void 0 : labelById.trackingStatus) && isStatusFilteredOut(labelById.trackingStatus, (
|
|
199
|
+
(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)) {
|
|
161
200
|
labelPassFilters = false;
|
|
162
201
|
}
|
|
163
202
|
return labelPassFilters ? labelById : undefined;
|
|
@@ -192,20 +231,28 @@ const useLabelsGrid = ({
|
|
|
192
231
|
clearAllFilters,
|
|
193
232
|
filters,
|
|
194
233
|
getGridData,
|
|
234
|
+
hasMoreUnfetchedResults: isTrackingStatusFilterActive ? hasMoreUnfetchedResults : false,
|
|
195
235
|
isAnyFilterActive,
|
|
196
236
|
isError: isListLabelsError || isListShipmentsError && fetchShipments,
|
|
197
|
-
|
|
237
|
+
isFetchingNextPage: isTrackingStatusFilterActive ? isFetchingNextPage : false,
|
|
238
|
+
// Calculate isLoading based on which query should be active
|
|
239
|
+
isLoading:
|
|
240
|
+
// Always include label filter loading when label ID filter is active
|
|
241
|
+
isLabelFilterActive && isLabelFilterLoading || (
|
|
242
|
+
// For tracking status filter
|
|
243
|
+
isTrackingStatusFilterActive ? isTrackingFilterLoading // Use tracking filter loading when active
|
|
244
|
+
: isListLabelsLoading || isListShipmentsLoading && fetchShipments),
|
|
198
245
|
labels,
|
|
199
246
|
pageConfig: {
|
|
200
|
-
currentPage: labelFilteredById ? 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.page) || 0,
|
|
247
|
+
currentPage: labelFilteredById ? 1 : isTrackingStatusFilterActive ? statusFilteredPaginationInfo.currentPage : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.page) || 0,
|
|
201
248
|
pagerProps,
|
|
202
|
-
pagesAmount: (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.pages) || 0,
|
|
249
|
+
pagesAmount: labelFilteredById ? 1 : isTrackingStatusFilterActive ? (statusFilteredPaginationInfo === null || statusFilteredPaginationInfo === void 0 ? void 0 : statusFilteredPaginationInfo.totalPages) || 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.pages) || 0,
|
|
203
250
|
pageSize,
|
|
204
|
-
showPagination: labelFilteredById ? false : ((listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0) > pageSize,
|
|
205
|
-
totalElements: labelFilteredById ? 1 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0
|
|
251
|
+
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,
|
|
252
|
+
totalElements: labelFilteredById ? 1 : isTrackingStatusFilterActive ? (statusFilteredPaginationInfo === null || statusFilteredPaginationInfo === void 0 ? void 0 : statusFilteredPaginationInfo.totalCount) || 0 : (listLabelsData === null || listLabelsData === void 0 ? void 0 : listLabelsData.total) || 0
|
|
206
253
|
},
|
|
207
254
|
setFilters: onSetFilters,
|
|
208
|
-
shouldShowFilters
|
|
255
|
+
shouldShowFilters: isAnyFilterEnabled
|
|
209
256
|
};
|
|
210
257
|
};
|
|
211
258
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var reactApi = require('@shipengine/react-api');
|
|
7
|
+
|
|
8
|
+
const MIN_RESULTS = 20; // Minimum number of filtered results needed to stop fetching
|
|
9
|
+
const MAX_PAGES = 5; // Maximum number of pages to fetch if we have enough results
|
|
10
|
+
const useTrackingStatusFilter = ({
|
|
11
|
+
isActive,
|
|
12
|
+
labelStatus,
|
|
13
|
+
shipmentId,
|
|
14
|
+
trackingStatusFilters,
|
|
15
|
+
sortDir,
|
|
16
|
+
currentPage,
|
|
17
|
+
pageSize
|
|
18
|
+
}) => {
|
|
19
|
+
const [allLabels, setAllLabels] = React.useState([]);
|
|
20
|
+
const {
|
|
21
|
+
data: infiniteData,
|
|
22
|
+
fetchNextPage,
|
|
23
|
+
hasNextPage,
|
|
24
|
+
isLoading,
|
|
25
|
+
isFetchingNextPage
|
|
26
|
+
} = reactApi.useListLabelsInfinite({
|
|
27
|
+
enabled: isActive,
|
|
28
|
+
queryFnParams: {
|
|
29
|
+
labelStatus,
|
|
30
|
+
pageSize: 100,
|
|
31
|
+
shipmentId,
|
|
32
|
+
sortDir
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (isActive && (infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages)) {
|
|
37
|
+
const allLabelsFromPages = infiniteData.pages.flatMap(page => page.labels || []);
|
|
38
|
+
setAllLabels(allLabelsFromPages);
|
|
39
|
+
}
|
|
40
|
+
}, [isActive, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages]);
|
|
41
|
+
const filteredLabels = React.useMemo(() => {
|
|
42
|
+
if (!isActive || !trackingStatusFilters.length) {
|
|
43
|
+
return allLabels;
|
|
44
|
+
}
|
|
45
|
+
return allLabels.filter(label => {
|
|
46
|
+
if (label.status === "voided") {
|
|
47
|
+
return trackingStatusFilters.includes("voided");
|
|
48
|
+
}
|
|
49
|
+
return trackingStatusFilters.includes(label.trackingStatus);
|
|
50
|
+
});
|
|
51
|
+
}, [isActive, allLabels, trackingStatusFilters]);
|
|
52
|
+
const totalCount = filteredLabels.length;
|
|
53
|
+
const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
54
|
+
const paginatedLabels = React.useMemo(() => {
|
|
55
|
+
const startIndex = (currentPage - 1) * pageSize;
|
|
56
|
+
const endIndex = Math.min(startIndex + pageSize, filteredLabels.length);
|
|
57
|
+
return filteredLabels.slice(startIndex, endIndex);
|
|
58
|
+
}, [filteredLabels, currentPage, pageSize]);
|
|
59
|
+
// Check if we have enough data for the next page
|
|
60
|
+
const hasDataForNextPage = React.useMemo(() => {
|
|
61
|
+
const nextPageStart = currentPage * pageSize;
|
|
62
|
+
return nextPageStart < filteredLabels.length;
|
|
63
|
+
}, [currentPage, pageSize, filteredLabels.length]);
|
|
64
|
+
// Check if we have more unfetched results
|
|
65
|
+
const hasMoreUnfetchedResults = React.useMemo(() => {
|
|
66
|
+
return hasNextPage && (infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages) && infiniteData.pages.length >= MAX_PAGES && filteredLabels.length >= MIN_RESULTS;
|
|
67
|
+
}, [hasNextPage, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages, filteredLabels.length]);
|
|
68
|
+
// Trigger fetchNextPage
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
// Don't fetch if not active or already fetching
|
|
71
|
+
if (!isActive || isFetchingNextPage) return;
|
|
72
|
+
// Continue fetching if we don't have minimum results yet
|
|
73
|
+
if (filteredLabels.length < MIN_RESULTS && hasNextPage) {
|
|
74
|
+
fetchNextPage();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Continue fetching if we don't have data for the next page
|
|
78
|
+
if (!hasDataForNextPage && hasNextPage) {
|
|
79
|
+
fetchNextPage();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Stop fetching if we've reached max pages and have enough results
|
|
83
|
+
if ((infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages) && infiniteData.pages.length >= MAX_PAGES && filteredLabels.length >= MIN_RESULTS && hasDataForNextPage) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Otherwise, fetch next page if available
|
|
87
|
+
if (hasNextPage) {
|
|
88
|
+
fetchNextPage();
|
|
89
|
+
}
|
|
90
|
+
}, [isActive, currentPage, pageSize, filteredLabels.length, hasNextPage, isFetchingNextPage, fetchNextPage, hasDataForNextPage, infiniteData === null || infiniteData === void 0 ? void 0 : infiniteData.pages]);
|
|
91
|
+
return {
|
|
92
|
+
allLabelsCount: totalCount,
|
|
93
|
+
fetchNextPage,
|
|
94
|
+
filteredLabelsCount: totalCount,
|
|
95
|
+
hasMorePages: hasNextPage,
|
|
96
|
+
hasMoreUnfetchedResults,
|
|
97
|
+
isFetchingNextPage,
|
|
98
|
+
isLoading: isLoading || filteredLabels.length === 0 && isFetchingNextPage,
|
|
99
|
+
labels: paginatedLabels,
|
|
100
|
+
paginationInfo: {
|
|
101
|
+
currentPage,
|
|
102
|
+
pageSize,
|
|
103
|
+
totalCount,
|
|
104
|
+
totalPages
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.useTrackingStatusFilter = useTrackingStatusFilter;
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
6
|
+
var useSortableQuery = require('../../hooks/use-sortable-query.cjs');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
var reactI18next = require('react-i18next');
|
|
8
9
|
var giger = require('@shipengine/giger');
|
|
9
10
|
var useLabelsGrid = require('./hooks/use-labels-grid.cjs');
|
|
10
11
|
var labelsGrid_styles = require('./labels-grid.styles.cjs');
|
|
11
|
-
var sortableHeader = require('../../components/grid-controller/sortable-header.cjs');
|
|
12
|
+
var sortableHeader = require('../../components/grid-controller/sortable-header/sortable-header.cjs');
|
|
12
13
|
var cellFormattedDate = require('../../components/grid-controller/cell-formatted-date.cjs');
|
|
13
14
|
var actionsMenu = require('../../components/actions-menu/actions-menu.cjs');
|
|
14
15
|
var errorState = require('../../components/error-state/error-state.cjs');
|
|
@@ -17,7 +18,6 @@ var gridFilters = require('../../components/grid-filters/grid-filters.cjs');
|
|
|
17
18
|
var gridFooter = require('../../components/grid-controller/grid-footer.cjs');
|
|
18
19
|
var index = require('../../locales/en/index.cjs');
|
|
19
20
|
var elementsContextProvider = require('../../elements-provider/elements-context-provider.cjs');
|
|
20
|
-
var loader = require('../../components/loader/loader.cjs');
|
|
21
21
|
var spacer = require('../../components/spacer/spacer.cjs');
|
|
22
22
|
var poweredByShipengine = require('../../components/powered-by-shipengine/powered-by-shipengine.cjs');
|
|
23
23
|
var createElement = require('../../create-element/create-element.cjs');
|
|
@@ -45,7 +45,13 @@ const Component = ({
|
|
|
45
45
|
} = elementsContextProvider.useElements();
|
|
46
46
|
const defaultFeatures = getFeatures("labelsGridFeatures");
|
|
47
47
|
const prevStatus = React.useRef(labelStatus);
|
|
48
|
-
const
|
|
48
|
+
const {
|
|
49
|
+
toggleSort,
|
|
50
|
+
sortState
|
|
51
|
+
} = useSortableQuery.useSortableQuery({
|
|
52
|
+
defaultSortBy: "modified_at",
|
|
53
|
+
defaultSortDir: "desc"
|
|
54
|
+
});
|
|
49
55
|
features = Object.assign(Object.assign({}, defaultFeatures), features !== null && features !== void 0 ? features : {});
|
|
50
56
|
const labelIdColumn = React.useMemo(() => {
|
|
51
57
|
var _a;
|
|
@@ -63,14 +69,21 @@ const Component = ({
|
|
|
63
69
|
var _a;
|
|
64
70
|
return (_a = features === null || features === void 0 ? void 0 : features.columns) === null || _a === void 0 ? void 0 : _a.find(c => c.name === "shipmentNumber");
|
|
65
71
|
}, [features]);
|
|
72
|
+
const statusColumn = React.useMemo(() => {
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = features === null || features === void 0 ? void 0 : features.columns) === null || _a === void 0 ? void 0 : _a.find(c => c.name === "status");
|
|
75
|
+
}, [features]);
|
|
66
76
|
const showLabelIdFilter = labelIdColumn && ((_a = labelIdColumn.allowFilter) !== null && _a !== void 0 ? _a : true);
|
|
67
77
|
const showShipmentIdFilter = shipmentIdColumn && ((_b = shipmentIdColumn.allowFilter) !== null && _b !== void 0 ? _b : true);
|
|
68
|
-
const
|
|
78
|
+
const showStatusFilter = statusColumn && ((_c = statusColumn.allowFilter) !== null && _c !== void 0 ? _c : true);
|
|
79
|
+
const showTrackingStatusFilter = trackingStatusColumn && !!trackingStatusColumn.allowFilter;
|
|
69
80
|
const {
|
|
70
81
|
labels,
|
|
71
82
|
getGridData,
|
|
72
83
|
isError,
|
|
73
84
|
isLoading,
|
|
85
|
+
isFetchingNextPage,
|
|
86
|
+
hasMoreUnfetchedResults,
|
|
74
87
|
filters,
|
|
75
88
|
setFilters,
|
|
76
89
|
pageConfig,
|
|
@@ -78,12 +91,13 @@ const Component = ({
|
|
|
78
91
|
shouldShowFilters,
|
|
79
92
|
clearAllFilters
|
|
80
93
|
} = useLabelsGrid.useLabelsGrid({
|
|
81
|
-
createdDateSortBy,
|
|
82
94
|
fetchShipments: !!shipmentNumberColumn,
|
|
83
95
|
labelStatus,
|
|
84
96
|
showLabelIdFilter,
|
|
85
97
|
showShipmentIdFilter,
|
|
86
|
-
|
|
98
|
+
showStatusFilter,
|
|
99
|
+
showTrackingStatusFilter,
|
|
100
|
+
sortDir: sortState.dir
|
|
87
101
|
});
|
|
88
102
|
React.useEffect(() => {
|
|
89
103
|
if (prevStatus.current !== labelStatus) {
|
|
@@ -99,14 +113,17 @@ const Component = ({
|
|
|
99
113
|
shipmentId: Object.assign(Object.assign({}, filters.shipmentId), {
|
|
100
114
|
nickname: shipmentIdColumn === null || shipmentIdColumn === void 0 ? void 0 : shipmentIdColumn.nickname
|
|
101
115
|
}),
|
|
116
|
+
status: Object.assign(Object.assign({}, filters.status), {
|
|
117
|
+
nickname: statusColumn === null || statusColumn === void 0 ? void 0 : statusColumn.nickname
|
|
118
|
+
}),
|
|
102
119
|
trackingStatus: Object.assign(Object.assign({}, filters.trackingStatus), {
|
|
103
120
|
nickname: trackingStatusColumn === null || trackingStatusColumn === void 0 ? void 0 : trackingStatusColumn.nickname
|
|
104
121
|
})
|
|
105
122
|
};
|
|
106
|
-
}, [filters, labelIdColumn, shipmentIdColumn, trackingStatusColumn]);
|
|
123
|
+
}, [filters, labelIdColumn, shipmentIdColumn, statusColumn, trackingStatusColumn]);
|
|
107
124
|
const toggleCreatedDateSort = React.useCallback(() => {
|
|
108
|
-
|
|
109
|
-
}, [
|
|
125
|
+
toggleSort("created_at");
|
|
126
|
+
}, [toggleSort]);
|
|
110
127
|
const columns = React.useMemo(() => {
|
|
111
128
|
var _a;
|
|
112
129
|
const labelTags = {
|
|
@@ -150,7 +167,7 @@ const Component = ({
|
|
|
150
167
|
headerContent: jsxRuntime.jsx(sortableHeader.SortableHeader, {
|
|
151
168
|
headerText: t("list-labels:headers.created"),
|
|
152
169
|
onToggleSort: toggleCreatedDateSort,
|
|
153
|
-
sortDirection:
|
|
170
|
+
sortDirection: sortState.createdAtDir
|
|
154
171
|
}),
|
|
155
172
|
renderCellContent: label => {
|
|
156
173
|
return jsxRuntime.jsx(cellFormattedDate.CellFormattedDate, {
|
|
@@ -378,24 +395,13 @@ const Component = ({
|
|
|
378
395
|
});
|
|
379
396
|
}
|
|
380
397
|
return cols;
|
|
381
|
-
}, [t, toggleCreatedDateSort,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
return jsxRuntime.jsx(errorState.ErrorState, {
|
|
389
|
-
css: labelsGrid_styles.styles.errorState,
|
|
390
|
-
subtitle: [t("list-labels:errorMessages.subtitle"), t("errorMessages.refreshAndTryAgain")],
|
|
391
|
-
title: t("list-labels:errorMessages.title")
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
395
|
-
children: [jsxRuntime.jsx(gridController.GridController, {
|
|
396
|
-
columns: columns,
|
|
397
|
-
data: getGridData(),
|
|
398
|
-
emptyContent: isAnyFilterActive ? jsxRuntime.jsx(giger.EmptyState, Object.assign({
|
|
398
|
+
}, [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]);
|
|
399
|
+
const emptyContentComponent = React.useMemo(() => {
|
|
400
|
+
if (isLoading) {
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
403
|
+
if (isAnyFilterActive) {
|
|
404
|
+
return jsxRuntime.jsx(giger.EmptyState, Object.assign({
|
|
399
405
|
isElevated: false,
|
|
400
406
|
subtitle: t("list-labels:emptyWithFilters.subtitle"),
|
|
401
407
|
title: t("list-labels:emptyWithFilters.title")
|
|
@@ -405,17 +411,36 @@ const Component = ({
|
|
|
405
411
|
}, {
|
|
406
412
|
children: t("list-labels:emptyWithFilters.button")
|
|
407
413
|
}))
|
|
408
|
-
}))
|
|
414
|
+
}));
|
|
415
|
+
} else {
|
|
416
|
+
return jsxRuntime.jsx(giger.EmptyState, {
|
|
409
417
|
isElevated: false,
|
|
410
418
|
subtitle: t("list-labels:empty.subtitle"),
|
|
411
419
|
title: t("list-labels:empty.title")
|
|
412
|
-
})
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}, [clearAllFilters, isAnyFilterActive, isLoading, t]);
|
|
423
|
+
if (isError) {
|
|
424
|
+
return jsxRuntime.jsx(errorState.ErrorState, {
|
|
425
|
+
css: labelsGrid_styles.styles.errorState,
|
|
426
|
+
subtitle: [t("list-labels:errorMessages.subtitle"), t("errorMessages.refreshAndTryAgain")],
|
|
427
|
+
title: t("list-labels:errorMessages.title")
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
431
|
+
children: [jsxRuntime.jsx(gridController.GridController, {
|
|
432
|
+
columns: columns,
|
|
433
|
+
data: getGridData(),
|
|
434
|
+
emptyContent: emptyContentComponent,
|
|
413
435
|
filters: shouldShowFilters && jsxRuntime.jsx(gridFilters.GridFilters, {
|
|
414
436
|
filters: gridFilters$1,
|
|
437
|
+
filtersDisabled: isLoading,
|
|
415
438
|
onClearAllFilters: clearAllFilters,
|
|
416
439
|
onFiltersUpdated: setFilters
|
|
417
440
|
}),
|
|
418
441
|
footerContent: jsxRuntime.jsx(gridFooter.GridFooter, {
|
|
442
|
+
hasMoreUnfetchedResults: hasMoreUnfetchedResults,
|
|
443
|
+
isLoadingMore: isFetchingNextPage,
|
|
419
444
|
onPageChange: pageConfig.pagerProps.onPageSelect,
|
|
420
445
|
page: pageConfig.currentPage,
|
|
421
446
|
pages: pageConfig.pagesAmount,
|
|
@@ -423,6 +448,7 @@ const Component = ({
|
|
|
423
448
|
showPagination: pageConfig.showPagination,
|
|
424
449
|
total: pageConfig.totalElements
|
|
425
450
|
}),
|
|
451
|
+
isLoading: isLoading,
|
|
426
452
|
onRowClick: onRowClick
|
|
427
453
|
}), globalFeatures.poweredByShipEngine && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
428
454
|
children: [jsxRuntime.jsx(spacer.Spacer, {}), jsxRuntime.jsx(poweredByShipengine.PoweredByShipEngine, {})]
|
|
@@ -9,6 +9,7 @@ var React = require('react');
|
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
var giger = require('@shipengine/giger');
|
|
11
11
|
var windsorFramework = require('./windsor-framework/windsor-framework.cjs');
|
|
12
|
+
var shipment = require('../../../../utilities/shipengine/shipment.cjs');
|
|
12
13
|
var useCustomsContentsOptions = require('../../hooks/use-customs-contents-options.cjs');
|
|
13
14
|
var useCustomsNonDeliveryOptions = require('../../hooks/use-customs-non-delivery-options.cjs');
|
|
14
15
|
var productsDisplay = require('./products-display/products-display.cjs');
|
|
@@ -28,7 +29,7 @@ const CustomsForms = ({
|
|
|
28
29
|
onUpdateCustoms,
|
|
29
30
|
onUpdateTaxableIds,
|
|
30
31
|
isCanadaDeliveredDutyEligible,
|
|
31
|
-
shipment,
|
|
32
|
+
shipment: shipment$1,
|
|
32
33
|
onDirty,
|
|
33
34
|
requiresWindsorFramework: _requiresWindsorFramework = false,
|
|
34
35
|
harmonizedTariffCodes
|
|
@@ -37,6 +38,12 @@ const CustomsForms = ({
|
|
|
37
38
|
const {
|
|
38
39
|
t
|
|
39
40
|
} = reactI18next.useTranslation(["purchase-label", "common"]);
|
|
41
|
+
// Convert deprecated customs items to the products format
|
|
42
|
+
const formattedShipment = React.useMemo(() => {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
const hasDeprecatedCustomsItems = !!((_b = (_a = shipment$1.customs) === null || _a === void 0 ? void 0 : _a.customsItems) === null || _b === void 0 ? void 0 : _b.length) && !((_d = (_c = shipment$1.packages) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.products);
|
|
45
|
+
return hasDeprecatedCustomsItems ? shipment.moveCustomsItemsToProducts(shipment$1) : shipment$1;
|
|
46
|
+
}, [shipment$1]);
|
|
40
47
|
const {
|
|
41
48
|
errors: {
|
|
42
49
|
packages: packageErrors
|
|
@@ -139,11 +146,11 @@ const CustomsForms = ({
|
|
|
139
146
|
currency: currency,
|
|
140
147
|
harmonizedTariffCodes: harmonizedTariffCodes,
|
|
141
148
|
onUpdate: handleUpdateProducts,
|
|
142
|
-
shipment:
|
|
149
|
+
shipment: formattedShipment
|
|
143
150
|
}), jsxRuntime.jsx(taxIds.TaxIds, {
|
|
144
151
|
onDirty: onDirty,
|
|
145
152
|
onUpdateTaxableIds: onUpdateTaxableIds,
|
|
146
|
-
shipment:
|
|
153
|
+
shipment: formattedShipment
|
|
147
154
|
})]
|
|
148
155
|
}));
|
|
149
156
|
};
|