@bjsdistribution/dms-client-return 0.1.20-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/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/dms-client-return.cjs.development.js +4364 -1614
- 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 +4429 -1679
- 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 +15 -72
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +41 -87
- package/src/components/client-portal/ReturnRTFilters.tsx +0 -2
- package/src/components/client-portal/ReturnSearchBar.tsx +41 -152
- package/src/components/client-portal/ReturnStatus.tsx +33 -84
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +12 -23
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +8 -85
- 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 +6 -1
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +3 -0
- 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 +25 -11
- 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 +1 -1
- package/src/index.tsx +6 -3
|
@@ -8,163 +8,51 @@ import styled from 'styled-components';
|
|
|
8
8
|
import {
|
|
9
9
|
useAtom,
|
|
10
10
|
useClientOutstandingReturnData,
|
|
11
|
-
useClientPortal,
|
|
12
|
-
useEndDate,
|
|
13
11
|
useSearchText,
|
|
14
|
-
useStartDate,
|
|
15
12
|
useStatsCPCount,
|
|
16
13
|
} from '../store';
|
|
17
|
-
import dayjs from 'dayjs';
|
|
18
14
|
import { filtersReducerAtom } from '../order-daily-overview/header-filters/filterStore';
|
|
19
15
|
import { ApiResponse } from '../types';
|
|
20
16
|
import { javascriptStringDumpToJSON } from '../utils';
|
|
21
17
|
import { UsePaginationData } from '../order-daily-overview/store/store';
|
|
22
18
|
import { notification } from 'antd';
|
|
23
|
-
import { useParams } from 'react-router-dom';
|
|
24
19
|
import { returnCountType } from './ReturnStatus';
|
|
20
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
25
21
|
|
|
26
22
|
function ReturnSearchBar() {
|
|
27
23
|
const [searchText, setSearchText] = useState('');
|
|
28
24
|
const [debouncedSearchText, setDebouncedSearchText] = useSearchText();
|
|
29
|
-
const [modifiedFilters, setModifiedFilters] = useState<any[]>([]);
|
|
30
25
|
const [, setOutstandingData] = useClientOutstandingReturnData();
|
|
31
|
-
const { status } = useParams();
|
|
32
|
-
//condition on client view
|
|
33
|
-
const [clientPortal] = useClientPortal();
|
|
34
26
|
const [, setPaginationObject] = UsePaginationData();
|
|
35
27
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
36
28
|
setSearchText(event.target.value);
|
|
37
29
|
};
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const [
|
|
41
|
-
const [state] = useAtom(filtersReducerAtom);
|
|
30
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
31
|
+
const { 'x-filters': filters } = state;
|
|
32
|
+
const [statePagination] = useAtom(filtersReducerAtom);
|
|
42
33
|
const [, setCount] = useStatsCPCount();
|
|
43
|
-
const
|
|
34
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
44
35
|
|
|
45
|
-
const
|
|
36
|
+
const baseFilters = [
|
|
37
|
+
{ field: 'isdeleted', op: '=', value: 0 },
|
|
38
|
+
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
39
|
+
];
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!isClientOutstanding) return;
|
|
50
|
-
|
|
51
|
-
setModifiedFilters([
|
|
52
|
-
{ field: 'isdeleted', op: '=', value: 0 },
|
|
53
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
54
|
-
]);
|
|
55
|
-
}, []);
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (!clientPortal) return;
|
|
59
|
-
|
|
60
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
61
|
-
|
|
62
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
63
|
-
const eDate = endDate?.isValid?.()
|
|
64
|
-
? endDate
|
|
65
|
-
: stored?.endDate
|
|
66
|
-
? dayjs(stored?.endDate)
|
|
67
|
-
: null;
|
|
68
|
-
|
|
69
|
-
if (!sDate?.isValid?.()) return;
|
|
70
|
-
|
|
71
|
-
let dateFilters = [];
|
|
72
|
-
|
|
73
|
-
if (eDate && eDate.isValid()) {
|
|
74
|
-
dateFilters = [
|
|
75
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
76
|
-
{
|
|
77
|
-
field: 'created_at',
|
|
78
|
-
op: '<=',
|
|
79
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
80
|
-
},
|
|
81
|
-
];
|
|
82
|
-
} else {
|
|
83
|
-
dateFilters = [
|
|
84
|
-
{
|
|
85
|
-
field: 'created_at',
|
|
86
|
-
op: '=',
|
|
87
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
88
|
-
},
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const updatedFilters =
|
|
93
|
-
status === 'outstanding_return'
|
|
94
|
-
? [
|
|
95
|
-
{ field: 'isdeleted', op: '=', value: 0 },
|
|
96
|
-
{ field: 'product_return_action_id', op: '=', value: 'RTS' },
|
|
97
|
-
...dateFilters,
|
|
98
|
-
]
|
|
99
|
-
: dateFilters;
|
|
100
|
-
|
|
101
|
-
setModifiedFilters(updatedFilters);
|
|
102
|
-
}, [startDate, endDate, status]);
|
|
103
|
-
|
|
104
|
-
//For stats
|
|
105
|
-
|
|
106
|
-
const getDateFilters = (
|
|
107
|
-
startDate: dayjs.Dayjs | null,
|
|
108
|
-
endDate: dayjs.Dayjs | null
|
|
109
|
-
) => {
|
|
110
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
111
|
-
|
|
112
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
113
|
-
const eDate = endDate?.isValid?.()
|
|
114
|
-
? endDate
|
|
115
|
-
: stored?.endDate
|
|
116
|
-
? dayjs(stored?.endDate)
|
|
117
|
-
: null;
|
|
118
|
-
|
|
119
|
-
if (!sDate?.isValid?.()) return [];
|
|
120
|
-
|
|
121
|
-
let dateFilters = [];
|
|
122
|
-
|
|
123
|
-
if (eDate && eDate.isValid()) {
|
|
124
|
-
dateFilters = [
|
|
125
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
126
|
-
{
|
|
127
|
-
field: 'created_at',
|
|
128
|
-
op: '<=',
|
|
129
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
} else {
|
|
133
|
-
dateFilters = [
|
|
134
|
-
{
|
|
135
|
-
field: 'created_at',
|
|
136
|
-
op: '=',
|
|
137
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
138
|
-
},
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return dateFilters;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (!clientPortal) return;
|
|
147
|
-
|
|
148
|
-
const dateFilters = getDateFilters(startDate, endDate);
|
|
149
|
-
setModifiedStatsFilters(dateFilters);
|
|
150
|
-
}, [startDate, endDate]);
|
|
151
|
-
|
|
152
|
-
const {
|
|
153
|
-
// loading,
|
|
154
|
-
paginationData,
|
|
155
|
-
fetchData: getPendingData,
|
|
156
|
-
// data: fetchedReturnOrderData,
|
|
157
|
-
} = useAxios<ApiResponse>({
|
|
41
|
+
const modifiedFilters = [...baseFilters, ...filters];
|
|
42
|
+
const { paginationData, fetchData: getPendingData } = useAxios<ApiResponse>({
|
|
158
43
|
endpoint: '/v1/return/product/pending/',
|
|
159
44
|
method: 'GET',
|
|
160
45
|
filters: modifiedFilters,
|
|
161
46
|
pagination: pagination,
|
|
162
47
|
});
|
|
163
48
|
|
|
49
|
+
// Debouncing effect
|
|
164
50
|
useEffect(() => {
|
|
165
|
-
|
|
51
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
52
|
+
|
|
53
|
+
if (trimmedText.length > 2) {
|
|
166
54
|
getPendingData({
|
|
167
|
-
endPointQuery: `?search_term=${
|
|
55
|
+
endPointQuery: `?search_term=${trimmedText}`,
|
|
168
56
|
}).then((response: any) => {
|
|
169
57
|
if (paginationData) {
|
|
170
58
|
const formattedPagination = javascriptStringDumpToJSON(
|
|
@@ -175,22 +63,18 @@ function ReturnSearchBar() {
|
|
|
175
63
|
}
|
|
176
64
|
|
|
177
65
|
if (response?.data?.length > 0) {
|
|
178
|
-
setOutstandingData(response
|
|
66
|
+
setOutstandingData(response.data);
|
|
179
67
|
} else {
|
|
180
68
|
setOutstandingData([]);
|
|
181
69
|
}
|
|
182
70
|
});
|
|
183
|
-
} else if (
|
|
184
|
-
debouncedSearchText?.length > 0 &&
|
|
185
|
-
debouncedSearchText?.length <= 2
|
|
186
|
-
) {
|
|
71
|
+
} else if (trimmedText.length > 0 && trimmedText.length <= 2) {
|
|
187
72
|
notification.warning({
|
|
188
|
-
message: 'Search
|
|
73
|
+
message: 'Search phrase cannot be less than 2 characters',
|
|
189
74
|
});
|
|
190
75
|
}
|
|
191
|
-
}, [debouncedSearchText]);
|
|
76
|
+
}, [debouncedSearchText, JSON.stringify(modifiedFilters)]);
|
|
192
77
|
|
|
193
|
-
// Debouncing effect
|
|
194
78
|
useEffect(() => {
|
|
195
79
|
const handler = setTimeout(() => {
|
|
196
80
|
setDebouncedSearchText(searchText);
|
|
@@ -213,28 +97,33 @@ function ReturnSearchBar() {
|
|
|
213
97
|
endpoint: `v1/portal/return/stats/`,
|
|
214
98
|
method: 'GET',
|
|
215
99
|
pagination: { is_pagination: false },
|
|
216
|
-
filters:
|
|
100
|
+
filters: filters,
|
|
217
101
|
});
|
|
218
102
|
|
|
219
103
|
useEffect(() => {
|
|
220
|
-
const
|
|
221
|
-
if (!isClientOutstanding || debouncedSearchText?.length < 3) return;
|
|
104
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
222
105
|
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (response?.data) {
|
|
106
|
+
if (trimmedText.length > 2) {
|
|
107
|
+
const fetchStats = async () => {
|
|
108
|
+
const response = await fetchStatsData({
|
|
109
|
+
endPointQuery: `?search_term=${trimmedText}&type=outstanding`,
|
|
110
|
+
});
|
|
229
111
|
//@ts-ignore
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
112
|
+
if (response?.data) {
|
|
113
|
+
//@ts-ignore
|
|
114
|
+
setCount(response?.data);
|
|
115
|
+
} else {
|
|
116
|
+
setCount(null);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
235
119
|
|
|
236
|
-
|
|
237
|
-
|
|
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)]);
|
|
238
127
|
|
|
239
128
|
const handleClear = () => {
|
|
240
129
|
setSearchText('');
|
|
@@ -3,21 +3,19 @@ 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
|
-
useEndDate,
|
|
13
12
|
useSearchAfterText,
|
|
14
13
|
useSearchText,
|
|
15
|
-
useStartDate,
|
|
16
14
|
useStatsCPCount,
|
|
17
15
|
} from '../store';
|
|
18
16
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
19
|
-
import {
|
|
20
|
-
import dayjs from 'dayjs';
|
|
17
|
+
import { dateFilterCPReducer } from './DateFilterStore';
|
|
18
|
+
// import dayjs from 'dayjs';
|
|
21
19
|
export type returnCountType = {
|
|
22
20
|
outstanding_count: number | null;
|
|
23
21
|
scheduled_count: number;
|
|
@@ -31,66 +29,18 @@ const ReturnStatus = () => {
|
|
|
31
29
|
completed_count: number;
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
// const [count, setCount] = useState<returnCountType[] | undefined>();
|
|
35
32
|
const [activeCardId, setActiveCardId] = useActiveCardId();
|
|
36
|
-
const [, dispatch] = useAtom(
|
|
33
|
+
const [state, dispatch] = useAtom(dateFilterCPReducer);
|
|
34
|
+
const { 'x-filters': filters } = state;
|
|
37
35
|
const { status } = useParams();
|
|
36
|
+
const navigate = useNavigate();
|
|
38
37
|
const [count, setCount] = useStatsCPCount();
|
|
39
|
-
const [startDate] = useStartDate();
|
|
40
|
-
const [endDate] = useEndDate();
|
|
41
38
|
const [clientPortal] = useClientPortal();
|
|
42
|
-
const [
|
|
43
|
-
const [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
startDate: dayjs.Dayjs | null,
|
|
48
|
-
endDate: dayjs.Dayjs | null
|
|
49
|
-
) => {
|
|
50
|
-
const stored = JSON.parse(localStorage.getItem('returnDate') || '{}');
|
|
51
|
-
|
|
52
|
-
const sDate = startDate?.isValid?.() ? startDate : dayjs(stored?.startDate);
|
|
53
|
-
const eDate = endDate?.isValid?.()
|
|
54
|
-
? endDate
|
|
55
|
-
: stored?.endDate
|
|
56
|
-
? dayjs(stored?.endDate)
|
|
57
|
-
: null;
|
|
58
|
-
|
|
59
|
-
if (!sDate?.isValid?.()) return [];
|
|
60
|
-
|
|
61
|
-
let dateFilters = [];
|
|
62
|
-
|
|
63
|
-
if (eDate && eDate.isValid()) {
|
|
64
|
-
dateFilters = [
|
|
65
|
-
{ field: 'created_at', op: '>=', value: sDate.format('YYYY-MM-DD') },
|
|
66
|
-
{
|
|
67
|
-
field: 'created_at',
|
|
68
|
-
op: '<=',
|
|
69
|
-
value: eDate.add(1, 'day').format('YYYY-MM-DD'),
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
} else {
|
|
73
|
-
dateFilters = [
|
|
74
|
-
{
|
|
75
|
-
field: 'created_at',
|
|
76
|
-
op: '=',
|
|
77
|
-
value: sDate.format('YYYY-MM-DD'),
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return dateFilters;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (!clientPortal) return;
|
|
87
|
-
|
|
88
|
-
const dateFilters = getDateFilters(startDate, endDate);
|
|
89
|
-
setModifiedFilters(dateFilters);
|
|
90
|
-
}, [startDate, endDate]);
|
|
91
|
-
|
|
92
|
-
//stats API
|
|
93
|
-
|
|
39
|
+
const [debouncedSearchText, setOutstandingSearch] = useSearchText();
|
|
40
|
+
const [
|
|
41
|
+
debouncedSearchAfterText,
|
|
42
|
+
setDebouncedSearchText,
|
|
43
|
+
] = useSearchAfterText();
|
|
94
44
|
const { data: statsData, loading: apiLoading, fetchData } = useAxios<{
|
|
95
45
|
data: returnCountType[];
|
|
96
46
|
}>({
|
|
@@ -98,33 +48,30 @@ const ReturnStatus = () => {
|
|
|
98
48
|
method: 'GET',
|
|
99
49
|
//@ts-ignore
|
|
100
50
|
pagination: { is_pagination: false },
|
|
101
|
-
filters:
|
|
51
|
+
filters: filters,
|
|
102
52
|
});
|
|
103
53
|
|
|
104
|
-
const prevSearchTextRef = useRef('');
|
|
105
|
-
const prevSearchAfterTextRef = useRef('');
|
|
106
|
-
|
|
107
54
|
useEffect(() => {
|
|
108
|
-
|
|
109
|
-
|
|
55
|
+
if (
|
|
56
|
+
clientPortal &&
|
|
57
|
+
debouncedSearchText === '' &&
|
|
58
|
+
status == 'outstanding_return'
|
|
59
|
+
) {
|
|
110
60
|
fetchData();
|
|
111
61
|
}
|
|
112
|
-
|
|
113
|
-
}, [debouncedSearchText, startDate, endDate]);
|
|
62
|
+
}, [debouncedSearchText, debouncedSearchAfterText, JSON.stringify(filters)]);
|
|
114
63
|
|
|
115
64
|
useEffect(() => {
|
|
116
|
-
|
|
117
|
-
|
|
65
|
+
if (
|
|
66
|
+
(clientPortal &&
|
|
67
|
+
debouncedSearchAfterText === '' &&
|
|
68
|
+
status == 'scheduled_for_return') ||
|
|
69
|
+
status == 'return_completed'
|
|
70
|
+
) {
|
|
71
|
+
console.log('CALL');
|
|
118
72
|
fetchData();
|
|
119
73
|
}
|
|
120
|
-
|
|
121
|
-
}, [debouncedSearchAfterText, startDate, endDate]);
|
|
122
|
-
|
|
123
|
-
console.log(debouncedSearchText, 'debouncedSearchText');
|
|
124
|
-
console.log(debouncedSearchAfterText, 'debouncedSearchAfterText');
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
fetchData();
|
|
127
|
-
}, [startDate, endDate]);
|
|
74
|
+
}, [debouncedSearchAfterText, debouncedSearchText, JSON.stringify(filters)]);
|
|
128
75
|
|
|
129
76
|
useEffect(() => {
|
|
130
77
|
if (statsData && statsData?.data) {
|
|
@@ -138,33 +85,35 @@ const ReturnStatus = () => {
|
|
|
138
85
|
id: 1,
|
|
139
86
|
icon: 'outstanding_return',
|
|
140
87
|
status: 'outstanding_return',
|
|
141
|
-
count: count?.outstanding_count
|
|
88
|
+
count: count?.outstanding_count,
|
|
142
89
|
label: 'Outstanding Return',
|
|
143
90
|
},
|
|
144
91
|
{
|
|
145
92
|
id: 2,
|
|
146
93
|
icon: 'scheduled_for_return',
|
|
147
94
|
status: 'scheduled_for_return',
|
|
148
|
-
count: count?.scheduled_count
|
|
95
|
+
count: count?.scheduled_count,
|
|
149
96
|
label: 'Scheduled For Return',
|
|
150
97
|
},
|
|
151
98
|
{
|
|
152
99
|
id: 3,
|
|
153
100
|
icon: 'return_completed',
|
|
154
101
|
status: 'return_completed',
|
|
155
|
-
count: count?.completed_count
|
|
102
|
+
count: count?.completed_count,
|
|
156
103
|
label: 'Return Completed',
|
|
157
104
|
},
|
|
158
105
|
];
|
|
159
|
-
const navigate = useNavigate();
|
|
160
|
-
const [, setDebouncedSearchText] = useSearchAfterText();
|
|
161
106
|
|
|
162
107
|
const handleCardClick = (item: any) => {
|
|
163
108
|
if (activeCardId === item?.id) {
|
|
164
109
|
return;
|
|
165
110
|
}
|
|
166
111
|
setActiveCardId(item?.id);
|
|
112
|
+
//for dev
|
|
167
113
|
navigate(`/return/${item?.status}`);
|
|
114
|
+
//for local
|
|
115
|
+
//navigate(`/${item?.status}`);
|
|
116
|
+
setOutstandingSearch('');
|
|
168
117
|
setDebouncedSearchText('');
|
|
169
118
|
if (item?.status == 'scheduled_for_return') {
|
|
170
119
|
dispatch({
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
// import OrderTable from './table/OrderTable';
|
|
4
|
-
// import ReturnOrderFilter from './table-filters/ReturnOrderFilter';
|
|
5
|
-
// import { useAtom, useReturnAfterOrderData } from '../../order-view/store';
|
|
6
|
-
// import {
|
|
7
|
-
// useItemsPerReturnPage,
|
|
8
|
-
// useLoading,
|
|
9
|
-
// UsePaginationData,
|
|
10
|
-
// UsePaginationReturnData,
|
|
11
|
-
// } from '../store/store';
|
|
12
|
-
// import { ApiResponse } from '../common/interface';
|
|
13
|
-
// import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
14
|
-
// import { filtersReducerReturnAtom } from './table-filters/ReturnFilterStore';
|
|
15
|
-
// import { notification } from 'antd';
|
|
16
|
-
// import ReturnPagination from '../table-view/ReturnPagination';
|
|
17
3
|
import {
|
|
18
4
|
useAtom,
|
|
5
|
+
useClientPortal,
|
|
19
6
|
// useCallApiAgain,
|
|
20
7
|
useReturnConfirmedOrderData,
|
|
21
8
|
useSearchAfterText,
|
|
@@ -32,14 +19,17 @@ import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
|
32
19
|
import { ApiResponse } from '../../types';
|
|
33
20
|
import { notification } from 'antd';
|
|
34
21
|
import ReturnPagination from '../../order-daily-overview/table-view/ReturnPagination';
|
|
35
|
-
import { useParams } from 'react-router-dom';
|
|
22
|
+
// import { useParams } from 'react-router-dom';
|
|
23
|
+
import { dateFilterCPReducer } from '../DateFilterStore';
|
|
36
24
|
|
|
37
25
|
const ConfirmedMain = () => {
|
|
38
26
|
const [, setReturnConfirmedData] = useReturnConfirmedOrderData();
|
|
39
27
|
const [, setLoading] = useLoading();
|
|
40
|
-
const [
|
|
28
|
+
const [statePagination] = useAtom(filtersReducerReturnAtom);
|
|
41
29
|
// const [callApi] = useCallApiAgain();
|
|
42
|
-
const { 'x-
|
|
30
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
31
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
32
|
+
const { 'x-filters': filters } = state;
|
|
43
33
|
const [paginationObj] = UsePaginationReturnData();
|
|
44
34
|
const [, setCurrentPage] = useState(1);
|
|
45
35
|
const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
|
|
@@ -52,7 +42,8 @@ const ConfirmedMain = () => {
|
|
|
52
42
|
const handleItemsPerPageChange = (itemsPerPage: number) => {
|
|
53
43
|
setItemsPerPage(itemsPerPage);
|
|
54
44
|
};
|
|
55
|
-
const { status } = useParams();
|
|
45
|
+
// const { status } = useParams();
|
|
46
|
+
const [clientPortal] = useClientPortal();
|
|
56
47
|
|
|
57
48
|
const {
|
|
58
49
|
data: fetchedReturnOrderData,
|
|
@@ -62,17 +53,15 @@ const ConfirmedMain = () => {
|
|
|
62
53
|
} = useAxios<ApiResponse>({
|
|
63
54
|
endpoint: '/v1/return/orders/',
|
|
64
55
|
method: 'GET',
|
|
65
|
-
filters: filters
|
|
56
|
+
filters: filters,
|
|
66
57
|
pagination: pagination,
|
|
67
58
|
});
|
|
68
59
|
|
|
69
60
|
useEffect(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (shouldFetch) {
|
|
61
|
+
if (clientPortal && debouncedSearchText === '') {
|
|
73
62
|
fetchData();
|
|
74
63
|
}
|
|
75
|
-
}, [
|
|
64
|
+
}, [JSON.stringify(filters), debouncedSearchText]);
|
|
76
65
|
|
|
77
66
|
useEffect(() => {
|
|
78
67
|
setLoading(loading);
|
|
@@ -5,7 +5,6 @@ import { NavLink } from 'react-router-dom';
|
|
|
5
5
|
import {
|
|
6
6
|
Checkbox,
|
|
7
7
|
displayValueOrNA,
|
|
8
|
-
// useApiHook,
|
|
9
8
|
} from '@bjsdistribution/dms-component-library';
|
|
10
9
|
import {
|
|
11
10
|
useLoading,
|
|
@@ -107,45 +106,18 @@ const ReturnConfirmedTable = () => {
|
|
|
107
106
|
}
|
|
108
107
|
};
|
|
109
108
|
|
|
110
|
-
// const handleSelectAll = (e: any) => {
|
|
111
|
-
// setSelectAll(e.target.checked);
|
|
112
|
-
// if (e.target.checked) {
|
|
113
|
-
// setSelectedReturnOrder(
|
|
114
|
-
// returnAfterOrder.map((e: any) => ({
|
|
115
|
-
// id: e.id,
|
|
116
|
-
// status_id: 3,
|
|
117
|
-
// }))
|
|
118
|
-
// );
|
|
119
|
-
// } else {
|
|
120
|
-
// setSelectedReturnOrder([]);
|
|
121
|
-
// }
|
|
122
|
-
// };
|
|
123
|
-
|
|
124
|
-
// const handleSelectInvoice = (id: any) => {
|
|
125
|
-
// setSelectedReturnOrder((prevSelectedInvoices: any) => {
|
|
126
|
-
// const isSelected = prevSelectedInvoices?.some(
|
|
127
|
-
// (item: any) => item.id === id
|
|
128
|
-
// );
|
|
129
|
-
|
|
130
|
-
// if (isSelected) {
|
|
131
|
-
// return prevSelectedInvoices.filter((items: any) => items.id !== id);
|
|
132
|
-
// } else {
|
|
133
|
-
// return [...prevSelectedInvoices, { id, status_id: 3 }];
|
|
134
|
-
// }
|
|
135
|
-
// });
|
|
136
|
-
// };
|
|
137
|
-
|
|
138
109
|
const getStatusClass = (status: string) => {
|
|
139
110
|
switch (status) {
|
|
140
111
|
case 'Cancelled':
|
|
112
|
+
case 'Failed':
|
|
141
113
|
return { color: '#E95252', background: 'rgba(233, 82, 82, 0.15)' };
|
|
142
114
|
case 'On Hold':
|
|
143
115
|
return { color: '#F4A503', background: '#FFF1D6' };
|
|
144
116
|
case 'Sub-Contracted':
|
|
117
|
+
case 'SC':
|
|
145
118
|
return { color: '#F4A503', background: '#FFF1D6' };
|
|
146
119
|
case 'Awaiting route':
|
|
147
|
-
|
|
148
|
-
case 'Awaiting':
|
|
120
|
+
case 'Awaiting Confirmation':
|
|
149
121
|
return { color: '#845ADF', background: 'rgba(132, 90, 223, 0.15)' };
|
|
150
122
|
case 'Completed':
|
|
151
123
|
return {
|
|
@@ -161,56 +133,6 @@ const ReturnConfirmedTable = () => {
|
|
|
161
133
|
}
|
|
162
134
|
};
|
|
163
135
|
|
|
164
|
-
// API for Assign
|
|
165
|
-
// const {
|
|
166
|
-
// data: actionResponse,
|
|
167
|
-
// setShouldPerformAction: setAssignAction,
|
|
168
|
-
// error: apiError,
|
|
169
|
-
// } = useApiHook<{
|
|
170
|
-
// data: ApiResponse[];
|
|
171
|
-
// }>({
|
|
172
|
-
// endpoint: `return_orders/update/assign/`,
|
|
173
|
-
// method: 'PUT',
|
|
174
|
-
// body: [assignPayload],
|
|
175
|
-
// performAction: false,
|
|
176
|
-
// });
|
|
177
|
-
|
|
178
|
-
//client options
|
|
179
|
-
// const assignOptions = assignData?.map((option: any) => ({
|
|
180
|
-
// label: option?.type?.charAt(0)?.toUpperCase() + option?.type?.slice(1),
|
|
181
|
-
// value: option?.bjs_delivery,
|
|
182
|
-
// }));
|
|
183
|
-
|
|
184
|
-
// const handleAssignPayload = (Id: number, value: boolean) => {
|
|
185
|
-
// setCallAPi(false);
|
|
186
|
-
// setAssign(value);
|
|
187
|
-
// setAssignPayload({
|
|
188
|
-
// ...assignPayload,
|
|
189
|
-
// return_order_id: Id,
|
|
190
|
-
// bjs_delivery: value,
|
|
191
|
-
// });
|
|
192
|
-
// setAssignAction(true);
|
|
193
|
-
// };
|
|
194
|
-
|
|
195
|
-
// useEffect(() => {
|
|
196
|
-
// //@ts-ignore
|
|
197
|
-
// if (actionResponse?.code === 200) {
|
|
198
|
-
// setCallAPi(true);
|
|
199
|
-
// notification.success({
|
|
200
|
-
// message: 'Success',
|
|
201
|
-
// // @ts-ignore
|
|
202
|
-
// description: `${actionResponse?.message}`,
|
|
203
|
-
// });
|
|
204
|
-
// // @ts-ignore
|
|
205
|
-
// } else if (apiError?.detail) {
|
|
206
|
-
// notification.error({
|
|
207
|
-
// message: 'Failure',
|
|
208
|
-
// // @ts-ignore
|
|
209
|
-
// description: `${apiError?.detail[0]?.msg}`,
|
|
210
|
-
// });
|
|
211
|
-
// }
|
|
212
|
-
// }, [actionResponse, apiError]);
|
|
213
|
-
|
|
214
136
|
const handleSelectOrderId = (id: string | number) => {
|
|
215
137
|
setSelectedOrderIds(prev =>
|
|
216
138
|
prev.includes(id) ? prev.filter(orderId => orderId !== id) : [...prev, id]
|
|
@@ -228,8 +150,7 @@ const ReturnConfirmedTable = () => {
|
|
|
228
150
|
setSelectedOrderIds([]);
|
|
229
151
|
}
|
|
230
152
|
};
|
|
231
|
-
|
|
232
|
-
console.log('returnConfirmedTable=====>', returnConfirmedTable);
|
|
153
|
+
|
|
233
154
|
return (
|
|
234
155
|
<>
|
|
235
156
|
<StyledTableWrapper className="fortables">
|
|
@@ -299,13 +220,15 @@ const ReturnConfirmedTable = () => {
|
|
|
299
220
|
const statusMapping: any = {
|
|
300
221
|
cancelled: 'Cancelled',
|
|
301
222
|
'on hold': 'On Hold',
|
|
223
|
+
subcontracted: 'Sub-Contracted',
|
|
302
224
|
SC: 'Sub-Contracted',
|
|
303
|
-
'awaiting route': 'Awaiting',
|
|
304
|
-
'awaiting confirmation': 'Awaiting',
|
|
225
|
+
'awaiting route': 'Awaiting route',
|
|
226
|
+
'awaiting confirmation': 'Awaiting Confirmation',
|
|
305
227
|
complete: 'Completed',
|
|
306
228
|
outstanding: 'Outstanding',
|
|
307
229
|
routed: 'Routed',
|
|
308
230
|
failed: 'Failed',
|
|
231
|
+
confirmed: 'Confirmed',
|
|
309
232
|
};
|
|
310
233
|
const status = statusMapping[item?.status_value] || 'Unknown';
|
|
311
234
|
const statusClass = getStatusClass(status);
|