@bjsdistribution/dms-client-return 0.1.19-dev → 0.1.21-dev
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/components/client-portal/DateFilterStore.d.ts +15 -0
- package/dist/components/client-portal/OutstandingTable.d.ts +3 -0
- package/dist/components/client-portal/ReturnStatus.d.ts +5 -0
- package/dist/components/client-portal/return-confirm/ConfirmedMain.d.ts +3 -0
- package/dist/components/client-portal/return-confirm/ReturnConfirmedTable.d.ts +3 -0
- package/dist/components/order-view/DynamicTable.d.ts +2 -1
- package/dist/components/order-view/general-information/Status.d.ts +1 -1
- package/dist/components/order-view/general-information/index.d.ts +1 -1
- package/dist/components/order-view/index.d.ts +1 -1
- package/dist/components/order-view/notes/AddNote.d.ts +1 -0
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/index.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
- package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +1 -0
- package/dist/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +1 -0
- package/dist/components/order-view/order-actions/types.d.ts +3 -3
- package/dist/components/order-view/order-details/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/order-details/index.d.ts +1 -1
- package/dist/components/order-view/order-resources/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/products-info/expanded-content/index.d.ts +6 -1
- package/dist/components/order-view/products-info/index.d.ts +1 -1
- package/dist/components/order-view/return-client-products/ProductTable.d.ts +6 -1
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +6 -1
- package/dist/components/order-view/store.d.ts +15 -3
- package/dist/components/order-view/system-event-logs/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/types.d.ts +49 -1
- package/dist/components/order-view/utils.d.ts +3 -0
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +2 -0
- package/dist/components/store.d.ts +5 -1
- package/dist/dms-client-return.cjs.development.js +7035 -3476
- package/dist/dms-client-return.cjs.development.js.map +1 -1
- package/dist/dms-client-return.cjs.production.min.js +1 -1
- package/dist/dms-client-return.cjs.production.min.js.map +1 -1
- package/dist/dms-client-return.esm.js +7099 -3540
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +6 -4
- package/src/assets/icons/ActionIcon.tsx +1 -1
- package/src/assets/icons/ArrowDownIcon.tsx +2 -2
- package/src/components/client-portal/DateFilterStore.ts +94 -0
- package/src/components/client-portal/OutstandingTable.tsx +355 -0
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +76 -17
- package/src/components/client-portal/ReturnOverview.tsx +4 -4
- package/src/components/client-portal/ReturnRTFilters.tsx +57 -40
- package/src/components/client-portal/ReturnSearchBar.tsx +64 -94
- package/src/components/client-portal/ReturnStatus.tsx +50 -68
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +224 -0
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +327 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +11 -18
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +43 -15
- package/src/components/order-daily-overview/index.tsx +23 -4
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +23 -38
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +21 -24
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +36 -36
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +12 -2
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +16 -0
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +58 -155
- package/src/components/order-daily-overview/table/ReturnTable.tsx +8 -4
- package/src/components/order-view/DynamicTable.tsx +21 -8
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +1 -1
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +9 -0
- package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
- package/src/components/order-view/flags-action-modal/Dropdowns.tsx +2 -0
- package/src/components/order-view/general-information/Status.tsx +92 -18
- package/src/components/order-view/general-information/index.tsx +2 -2
- package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
- package/src/components/order-view/index.tsx +50 -8
- package/src/components/order-view/modalsPopup/ModalManager.tsx +1 -1
- package/src/components/order-view/notes/AddNote.tsx +95 -65
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
- package/src/components/order-view/notification/FlagTemplate.tsx +21 -10
- package/src/components/order-view/notification/OrderTemplate.tsx +192 -41
- package/src/components/order-view/notification/ReminderTemplate.tsx +28 -13
- package/src/components/order-view/notification/index.tsx +100 -55
- package/src/components/order-view/order-actions/actions/add-resources/DocFileUpload.tsx +92 -72
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +27 -10
- package/src/components/order-view/order-actions/actions/cancel-order/ReturnAction.tsx +25 -4
- package/src/components/order-view/order-actions/actions/cancel-order/ReturnReason.tsx +24 -4
- package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +9 -2
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +12 -6
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +1 -0
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +88 -30
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +5 -3
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +2 -2
- package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
- package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +620 -0
- package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +201 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
- package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +2 -0
- package/src/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.tsx +7 -2
- package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +2 -0
- package/src/components/order-view/order-actions/index.tsx +18 -5
- package/src/components/order-view/order-actions/store.ts +1 -1
- package/src/components/order-view/order-actions/types.ts +3 -3
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +7 -1
- package/src/components/order-view/order-details/expanded-content/index.tsx +37 -16
- package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/services-section/ServiceLevel.tsx +3 -4
- package/src/components/order-view/order-details/index.tsx +5 -2
- package/src/components/order-view/order-resources/expanded-content/index.tsx +2 -2
- package/src/components/order-view/products-info/expanded-content/index.tsx +33 -11
- package/src/components/order-view/products-info/index.tsx +10 -6
- package/src/components/order-view/return-client-products/ProductTable.tsx +12 -2
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +73 -23
- package/src/components/order-view/store.ts +107 -1
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +6 -2
- package/src/components/order-view/types.ts +54 -1
- package/src/components/order-view/utils.ts +37 -0
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +85 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +33 -14
- package/src/components/store.ts +24 -1
- package/src/index.tsx +6 -3
|
@@ -10,15 +10,24 @@ import { ExportButton, useAxios } from '@bjsdistribution/dms-component-library';
|
|
|
10
10
|
import { useParams } from 'react-router-dom';
|
|
11
11
|
import { filtersReducerReturnAtom } from '../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
12
12
|
import { notification } from 'antd';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
useSelectedClientAfterOrders,
|
|
15
|
+
useSelectedClientPortOrders,
|
|
16
|
+
} from '../store';
|
|
14
17
|
|
|
15
18
|
const ReturnRTFilters = () => {
|
|
16
19
|
const [returnData] = useReturnData();
|
|
17
20
|
const [pendingState] = useAtom(filtersReducerAtom);
|
|
18
21
|
const [state] = useAtom(filtersReducerReturnAtom);
|
|
19
22
|
const [returnAfterOrder] = useReturnAfterOrderData();
|
|
20
|
-
const [
|
|
21
|
-
|
|
23
|
+
const [
|
|
24
|
+
selectedOrderIds,
|
|
25
|
+
setSelectedOrderIds,
|
|
26
|
+
] = useSelectedClientAfterOrders();
|
|
27
|
+
const [
|
|
28
|
+
selectedPendingOrderIds,
|
|
29
|
+
setSelectedPendingOrderIds,
|
|
30
|
+
] = useSelectedClientPortOrders();
|
|
22
31
|
const { status } = useParams<{ status: any }>();
|
|
23
32
|
const { 'x-filters': pendingFilters } = pendingState;
|
|
24
33
|
|
|
@@ -46,10 +55,13 @@ const ReturnRTFilters = () => {
|
|
|
46
55
|
feature_name: 'return',
|
|
47
56
|
};
|
|
48
57
|
}
|
|
49
|
-
// console.log(selectedReturnOrder, 'selectedReturnOrder');
|
|
50
58
|
//Export Manifest
|
|
51
|
-
const
|
|
52
|
-
|
|
59
|
+
const isExportEnabled =
|
|
60
|
+
status === 'outstanding_return'
|
|
61
|
+
? selectedPendingOrderIds?.length > 0
|
|
62
|
+
: status === 'scheduled_for_return' || status === 'return_completed'
|
|
63
|
+
? selectedOrderIds?.length > 0
|
|
64
|
+
: false;
|
|
53
65
|
const { fetchData: callExportApi } = useAxios<{
|
|
54
66
|
data: any[];
|
|
55
67
|
message: string;
|
|
@@ -58,12 +70,19 @@ const ReturnRTFilters = () => {
|
|
|
58
70
|
method: 'POST',
|
|
59
71
|
});
|
|
60
72
|
|
|
61
|
-
const
|
|
73
|
+
const handleExportManifest = async () => {
|
|
62
74
|
if (!isExportEnabled) return;
|
|
63
75
|
|
|
76
|
+
const exportOrderIds =
|
|
77
|
+
status === 'outstanding_return'
|
|
78
|
+
? selectedPendingOrderIds
|
|
79
|
+
: status === 'scheduled_for_return' || status === 'return_completed'
|
|
80
|
+
? selectedOrderIds
|
|
81
|
+
: [];
|
|
82
|
+
|
|
64
83
|
try {
|
|
65
84
|
const response = (await callExportApi({
|
|
66
|
-
payload: { order_ids:
|
|
85
|
+
payload: { order_ids: exportOrderIds },
|
|
67
86
|
})) as {
|
|
68
87
|
code: number | null;
|
|
69
88
|
error?: string | null;
|
|
@@ -78,38 +97,16 @@ const ReturnRTFilters = () => {
|
|
|
78
97
|
message: 'Success',
|
|
79
98
|
description: response?.message || 'Export completed.',
|
|
80
99
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
window.open(response?.data?.url, '_blank');
|
|
101
|
+
|
|
102
|
+
if (status === 'outstanding_return') {
|
|
103
|
+
setSelectedPendingOrderIds([]);
|
|
104
|
+
} else if (
|
|
105
|
+
status === 'scheduled_for_return' ||
|
|
106
|
+
status === 'return_completed'
|
|
107
|
+
) {
|
|
108
|
+
setSelectedOrderIds([]);
|
|
88
109
|
}
|
|
89
|
-
|
|
90
|
-
const blob = await downloadResponse.blob();
|
|
91
|
-
|
|
92
|
-
const urlObject = window.URL.createObjectURL(blob);
|
|
93
|
-
const link = document.createElement('a');
|
|
94
|
-
link.href = urlObject;
|
|
95
|
-
|
|
96
|
-
// You can customize the filename or extract it from headers
|
|
97
|
-
const contentDisposition = downloadResponse.headers.get(
|
|
98
|
-
'Content-Disposition'
|
|
99
|
-
);
|
|
100
|
-
const filenameMatch = contentDisposition?.match(/filename="?(.+)"?/);
|
|
101
|
-
const filename = filenameMatch?.[1] || 'download.csv';
|
|
102
|
-
|
|
103
|
-
link.download = filename;
|
|
104
|
-
document.body.appendChild(link);
|
|
105
|
-
link.click();
|
|
106
|
-
document.body.removeChild(link);
|
|
107
|
-
window.URL.revokeObjectURL(urlObject);
|
|
108
|
-
|
|
109
|
-
notification.success({
|
|
110
|
-
message: 'Downloaded',
|
|
111
|
-
description: 'File downloaded successfully.',
|
|
112
|
-
});
|
|
113
110
|
} else {
|
|
114
111
|
notification.error({
|
|
115
112
|
message: 'No File URL',
|
|
@@ -122,13 +119,28 @@ const ReturnRTFilters = () => {
|
|
|
122
119
|
message: 'Export Failed',
|
|
123
120
|
description: 'Something went wrong during export.',
|
|
124
121
|
});
|
|
122
|
+
|
|
123
|
+
if (status === 'outstanding_return') {
|
|
124
|
+
setSelectedPendingOrderIds([]);
|
|
125
|
+
} else if (
|
|
126
|
+
status === 'scheduled_for_return' ||
|
|
127
|
+
status === 'return_completed'
|
|
128
|
+
) {
|
|
129
|
+
setSelectedOrderIds([]);
|
|
130
|
+
}
|
|
125
131
|
}
|
|
126
132
|
};
|
|
127
133
|
|
|
128
134
|
return (
|
|
129
135
|
<StyledBulkFilterCover className="dmsBulkFilter">
|
|
130
136
|
<ExportButton moduleInfoModule={moduleInfo} />
|
|
131
|
-
<StyledBulkItem
|
|
137
|
+
<StyledBulkItem
|
|
138
|
+
onClick={handleExportManifest}
|
|
139
|
+
style={{
|
|
140
|
+
pointerEvents: isExportEnabled ? 'auto' : 'none',
|
|
141
|
+
opacity: isExportEnabled ? 1 : 0.5,
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
132
144
|
<Text>Export Manifest</Text>
|
|
133
145
|
</StyledBulkItem>
|
|
134
146
|
</StyledBulkFilterCover>
|
|
@@ -174,6 +186,11 @@ export const StyledBulkItem = styled.div`
|
|
|
174
186
|
}
|
|
175
187
|
}
|
|
176
188
|
}
|
|
189
|
+
&:hover:not(:disabled) {
|
|
190
|
+
background: #f0f0f0;
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
}
|
|
193
|
+
|
|
177
194
|
@media screen and (max-width: 1030px) {
|
|
178
195
|
padding: 6px 4px;
|
|
179
196
|
}
|
|
@@ -7,112 +7,52 @@ import React, { useEffect, useState } from 'react';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import {
|
|
9
9
|
useAtom,
|
|
10
|
-
|
|
11
|
-
useEndDate,
|
|
10
|
+
useClientOutstandingReturnData,
|
|
12
11
|
useSearchText,
|
|
13
|
-
|
|
12
|
+
useStatsCPCount,
|
|
14
13
|
} from '../store';
|
|
15
|
-
import dayjs from 'dayjs';
|
|
16
14
|
import { filtersReducerAtom } from '../order-daily-overview/header-filters/filterStore';
|
|
17
15
|
import { ApiResponse } from '../types';
|
|
18
16
|
import { javascriptStringDumpToJSON } from '../utils';
|
|
19
17
|
import { UsePaginationData } from '../order-daily-overview/store/store';
|
|
20
18
|
import { notification } from 'antd';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
19
|
+
import { returnCountType } from './ReturnStatus';
|
|
20
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
23
21
|
|
|
24
22
|
function ReturnSearchBar() {
|
|
25
23
|
const [searchText, setSearchText] = useState('');
|
|
26
24
|
const [debouncedSearchText, setDebouncedSearchText] = useSearchText();
|
|
27
|
-
const [
|
|
28
|
-
const [, setReturnData] = useReturnData();
|
|
29
|
-
const { status } = useParams();
|
|
30
|
-
//condition on client view
|
|
31
|
-
const [clientPortal] = useClientPortal();
|
|
25
|
+
const [, setOutstandingData] = useClientOutstandingReturnData();
|
|
32
26
|
const [, setPaginationObject] = UsePaginationData();
|
|
33
27
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
34
28
|
setSearchText(event.target.value);
|
|
35
29
|
};
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const [
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
50
|
-
]);
|
|
51
|
-
}, []);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!clientPortal) return;
|
|
55
|
-
|
|
56
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
57
|
-
|
|
58
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
59
|
-
const eDate = endDate?.isValid?.()
|
|
60
|
-
? endDate
|
|
61
|
-
: stored?.endDate
|
|
62
|
-
? dayjs(stored?.endDate)
|
|
63
|
-
: null;
|
|
64
|
-
|
|
65
|
-
if (!sDate?.isValid?.()) return;
|
|
66
|
-
|
|
67
|
-
let dateFilters = [];
|
|
68
|
-
|
|
69
|
-
if (eDate && eDate.isValid()) {
|
|
70
|
-
dateFilters = [
|
|
71
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
72
|
-
{
|
|
73
|
-
field: 'created_at',
|
|
74
|
-
op: '<=',
|
|
75
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
} else {
|
|
79
|
-
dateFilters = [
|
|
80
|
-
{
|
|
81
|
-
field: 'created_at',
|
|
82
|
-
op: '=',
|
|
83
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const updatedFilters =
|
|
89
|
-
status === 'outstanding_return'
|
|
90
|
-
? [
|
|
91
|
-
{ field: 'isdeleted', op: '=', value: 0 },
|
|
92
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
93
|
-
...dateFilters,
|
|
94
|
-
]
|
|
95
|
-
: dateFilters;
|
|
96
|
-
|
|
97
|
-
setModifiedFilters(updatedFilters);
|
|
98
|
-
}, [startDate, endDate, status]);
|
|
99
|
-
|
|
100
|
-
const {
|
|
101
|
-
// loading,
|
|
102
|
-
paginationData,
|
|
103
|
-
fetchData: getPendingData,
|
|
104
|
-
// data: fetchedReturnOrderData,
|
|
105
|
-
} = useAxios<ApiResponse>({
|
|
30
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
31
|
+
const { 'x-filters': filters } = state;
|
|
32
|
+
const [statePagination] = useAtom(filtersReducerAtom);
|
|
33
|
+
const [, setCount] = useStatsCPCount();
|
|
34
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
35
|
+
|
|
36
|
+
const baseFilters = [
|
|
37
|
+
{ field: 'isdeleted', op: '=', value: 0 },
|
|
38
|
+
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const modifiedFilters = [...baseFilters, ...filters];
|
|
42
|
+
const { paginationData, fetchData: getPendingData } = useAxios<ApiResponse>({
|
|
106
43
|
endpoint: '/v1/return/product/pending/',
|
|
107
44
|
method: 'GET',
|
|
108
45
|
filters: modifiedFilters,
|
|
109
46
|
pagination: pagination,
|
|
110
47
|
});
|
|
111
48
|
|
|
49
|
+
// Debouncing effect
|
|
112
50
|
useEffect(() => {
|
|
113
|
-
|
|
51
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
52
|
+
|
|
53
|
+
if (trimmedText.length > 2) {
|
|
114
54
|
getPendingData({
|
|
115
|
-
endPointQuery: `?search_term=${
|
|
55
|
+
endPointQuery: `?search_term=${trimmedText}`,
|
|
116
56
|
}).then((response: any) => {
|
|
117
57
|
if (paginationData) {
|
|
118
58
|
const formattedPagination = javascriptStringDumpToJSON(
|
|
@@ -123,22 +63,18 @@ function ReturnSearchBar() {
|
|
|
123
63
|
}
|
|
124
64
|
|
|
125
65
|
if (response?.data?.length > 0) {
|
|
126
|
-
|
|
66
|
+
setOutstandingData(response.data);
|
|
127
67
|
} else {
|
|
128
|
-
|
|
68
|
+
setOutstandingData([]);
|
|
129
69
|
}
|
|
130
70
|
});
|
|
131
|
-
} else if (
|
|
132
|
-
debouncedSearchText.length > 0 &&
|
|
133
|
-
debouncedSearchText.length <= 2
|
|
134
|
-
) {
|
|
71
|
+
} else if (trimmedText.length > 0 && trimmedText.length <= 2) {
|
|
135
72
|
notification.warning({
|
|
136
|
-
message: 'Search
|
|
73
|
+
message: 'Search phrase cannot be less than 2 characters',
|
|
137
74
|
});
|
|
138
75
|
}
|
|
139
|
-
}, [debouncedSearchText]);
|
|
76
|
+
}, [debouncedSearchText, JSON.stringify(modifiedFilters)]);
|
|
140
77
|
|
|
141
|
-
// Debouncing effect
|
|
142
78
|
useEffect(() => {
|
|
143
79
|
const handler = setTimeout(() => {
|
|
144
80
|
setDebouncedSearchText(searchText);
|
|
@@ -149,14 +85,48 @@ function ReturnSearchBar() {
|
|
|
149
85
|
}, [searchText]);
|
|
150
86
|
|
|
151
87
|
useEffect(() => {
|
|
152
|
-
if (debouncedSearchText
|
|
88
|
+
if (debouncedSearchText?.length === 0) {
|
|
153
89
|
setSearchText('');
|
|
154
90
|
}
|
|
155
91
|
}, [debouncedSearchText]);
|
|
156
92
|
|
|
93
|
+
//
|
|
94
|
+
const { fetchData: fetchStatsData } = useAxios<{
|
|
95
|
+
data: returnCountType[];
|
|
96
|
+
}>({
|
|
97
|
+
endpoint: `v1/portal/return/stats/`,
|
|
98
|
+
method: 'GET',
|
|
99
|
+
pagination: { is_pagination: false },
|
|
100
|
+
filters: filters,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
105
|
+
|
|
106
|
+
if (trimmedText.length > 2) {
|
|
107
|
+
const fetchStats = async () => {
|
|
108
|
+
const response = await fetchStatsData({
|
|
109
|
+
endPointQuery: `?search_term=${trimmedText}&type=outstanding`,
|
|
110
|
+
});
|
|
111
|
+
//@ts-ignore
|
|
112
|
+
if (response?.data) {
|
|
113
|
+
//@ts-ignore
|
|
114
|
+
setCount(response?.data);
|
|
115
|
+
} else {
|
|
116
|
+
setCount(null);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
fetchStats();
|
|
121
|
+
} else if (trimmedText.length > 0 && trimmedText.length <= 2) {
|
|
122
|
+
notification.warning({
|
|
123
|
+
message: 'Search phrase cannot be less than 3 characters',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, [debouncedSearchText, JSON.stringify(modifiedFilters)]);
|
|
127
|
+
|
|
157
128
|
const handleClear = () => {
|
|
158
129
|
setSearchText('');
|
|
159
|
-
setDebouncedSearchText('');
|
|
160
130
|
};
|
|
161
131
|
return (
|
|
162
132
|
<Search>
|
|
@@ -3,19 +3,24 @@ import {
|
|
|
3
3
|
device,
|
|
4
4
|
useAxios,
|
|
5
5
|
} from '@bjsdistribution/dms-component-library';
|
|
6
|
-
import React, { useEffect
|
|
6
|
+
import React, { useEffect } from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import {
|
|
9
9
|
useActiveCardId,
|
|
10
10
|
useAtom,
|
|
11
11
|
useClientPortal,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
useSearchAfterText,
|
|
13
|
+
useSearchText,
|
|
14
|
+
useStatsCPCount,
|
|
14
15
|
} from '../store';
|
|
15
16
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
16
|
-
import {
|
|
17
|
-
import dayjs from 'dayjs';
|
|
18
|
-
|
|
17
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
18
|
+
// import dayjs from 'dayjs';
|
|
19
|
+
export type returnCountType = {
|
|
20
|
+
outstanding_count: number | null;
|
|
21
|
+
scheduled_count: number;
|
|
22
|
+
completed_count: number;
|
|
23
|
+
};
|
|
19
24
|
const ReturnStatus = () => {
|
|
20
25
|
//CP
|
|
21
26
|
type returnCountType = {
|
|
@@ -24,64 +29,18 @@ const ReturnStatus = () => {
|
|
|
24
29
|
completed_count: number;
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
// const [count, setCount] = useState<returnCountType[] | undefined>();
|
|
28
32
|
const [activeCardId, setActiveCardId] = useActiveCardId();
|
|
29
|
-
const [, dispatch] = useAtom(
|
|
33
|
+
const [state, dispatch] = useAtom(dateFilterCPReducer);
|
|
34
|
+
const { 'x-filters': filters } = state;
|
|
30
35
|
const { status } = useParams();
|
|
31
|
-
const
|
|
32
|
-
const [
|
|
33
|
-
const [endDate] = useEndDate();
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const [count, setCount] = useStatsCPCount();
|
|
34
38
|
const [clientPortal] = useClientPortal();
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
) => {
|
|
41
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
42
|
-
|
|
43
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
44
|
-
const eDate = endDate?.isValid?.()
|
|
45
|
-
? endDate
|
|
46
|
-
: stored?.endDate
|
|
47
|
-
? dayjs(stored?.endDate)
|
|
48
|
-
: null;
|
|
49
|
-
|
|
50
|
-
if (!sDate?.isValid?.()) return [];
|
|
51
|
-
|
|
52
|
-
let dateFilters = [];
|
|
53
|
-
|
|
54
|
-
if (eDate && eDate.isValid()) {
|
|
55
|
-
dateFilters = [
|
|
56
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
57
|
-
{
|
|
58
|
-
field: 'created_at',
|
|
59
|
-
op: '<=',
|
|
60
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
} else {
|
|
64
|
-
dateFilters = [
|
|
65
|
-
{
|
|
66
|
-
field: 'created_at',
|
|
67
|
-
op: '=',
|
|
68
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return dateFilters;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (!clientPortal) return;
|
|
78
|
-
|
|
79
|
-
const dateFilters = getDateFilters(startDate, endDate);
|
|
80
|
-
setModifiedFilters(dateFilters);
|
|
81
|
-
}, [startDate, endDate]);
|
|
82
|
-
|
|
83
|
-
//stats API
|
|
84
|
-
|
|
39
|
+
const [debouncedSearchText, setOutstandingSearch] = useSearchText();
|
|
40
|
+
const [
|
|
41
|
+
debouncedSearchAfterText,
|
|
42
|
+
setDebouncedSearchText,
|
|
43
|
+
] = useSearchAfterText();
|
|
85
44
|
const { data: statsData, loading: apiLoading, fetchData } = useAxios<{
|
|
86
45
|
data: returnCountType[];
|
|
87
46
|
}>({
|
|
@@ -89,12 +48,30 @@ const ReturnStatus = () => {
|
|
|
89
48
|
method: 'GET',
|
|
90
49
|
//@ts-ignore
|
|
91
50
|
pagination: { is_pagination: false },
|
|
92
|
-
filters:
|
|
51
|
+
filters: filters,
|
|
93
52
|
});
|
|
94
53
|
|
|
95
54
|
useEffect(() => {
|
|
96
|
-
|
|
97
|
-
|
|
55
|
+
if (
|
|
56
|
+
clientPortal &&
|
|
57
|
+
debouncedSearchText === '' &&
|
|
58
|
+
status == 'outstanding_return'
|
|
59
|
+
) {
|
|
60
|
+
fetchData();
|
|
61
|
+
}
|
|
62
|
+
}, [debouncedSearchText, debouncedSearchAfterText, JSON.stringify(filters)]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (
|
|
66
|
+
(clientPortal &&
|
|
67
|
+
debouncedSearchAfterText === '' &&
|
|
68
|
+
status == 'scheduled_for_return') ||
|
|
69
|
+
status == 'return_completed'
|
|
70
|
+
) {
|
|
71
|
+
console.log('CALL');
|
|
72
|
+
fetchData();
|
|
73
|
+
}
|
|
74
|
+
}, [debouncedSearchAfterText, debouncedSearchText, JSON.stringify(filters)]);
|
|
98
75
|
|
|
99
76
|
useEffect(() => {
|
|
100
77
|
if (statsData && statsData?.data) {
|
|
@@ -108,31 +85,36 @@ const ReturnStatus = () => {
|
|
|
108
85
|
id: 1,
|
|
109
86
|
icon: 'outstanding_return',
|
|
110
87
|
status: 'outstanding_return',
|
|
111
|
-
count: count?.outstanding_count
|
|
88
|
+
count: count?.outstanding_count,
|
|
112
89
|
label: 'Outstanding Return',
|
|
113
90
|
},
|
|
114
91
|
{
|
|
115
92
|
id: 2,
|
|
116
93
|
icon: 'scheduled_for_return',
|
|
117
94
|
status: 'scheduled_for_return',
|
|
118
|
-
count: count?.scheduled_count
|
|
95
|
+
count: count?.scheduled_count,
|
|
119
96
|
label: 'Scheduled For Return',
|
|
120
97
|
},
|
|
121
98
|
{
|
|
122
99
|
id: 3,
|
|
123
100
|
icon: 'return_completed',
|
|
124
101
|
status: 'return_completed',
|
|
125
|
-
count: count?.completed_count
|
|
102
|
+
count: count?.completed_count,
|
|
126
103
|
label: 'Return Completed',
|
|
127
104
|
},
|
|
128
105
|
];
|
|
129
|
-
|
|
106
|
+
|
|
130
107
|
const handleCardClick = (item: any) => {
|
|
131
108
|
if (activeCardId === item?.id) {
|
|
132
109
|
return;
|
|
133
110
|
}
|
|
134
111
|
setActiveCardId(item?.id);
|
|
112
|
+
//for dev
|
|
135
113
|
navigate(`/return/${item?.status}`);
|
|
114
|
+
//for local
|
|
115
|
+
//navigate(`/${item?.status}`);
|
|
116
|
+
setOutstandingSearch('');
|
|
117
|
+
setDebouncedSearchText('');
|
|
136
118
|
if (item?.status == 'scheduled_for_return') {
|
|
137
119
|
dispatch({
|
|
138
120
|
type: 'SET_SCHEDULED_RETURN_FILTER',
|