@bjsdistribution/dms-client-return 0.1.18-dev → 0.1.18-prod
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/common/date-picker/header/ClearDate.d.ts +1 -1
- 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/ReturnRTFilters.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-daily-overview/header/route-header/ClientRouterHeader.d.ts +11 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- 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 +55 -1
- package/dist/components/order-view/utils.d.ts +11 -2
- 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 +8897 -5744
- 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 +8917 -5764
- 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 +139 -0
- package/src/components/client-portal/OutstandingTable.tsx +356 -0
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +77 -17
- package/src/components/client-portal/ReturnOverview.tsx +15 -6
- package/src/components/client-portal/ReturnRTFilters.tsx +196 -80
- package/src/components/client-portal/ReturnSearchBar.tsx +64 -94
- package/src/components/client-portal/ReturnStatus.tsx +50 -66
- 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/ClientRouterHeader.tsx +166 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +2 -86
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +46 -15
- package/src/components/order-daily-overview/index.tsx +22 -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 -35
- 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 +635 -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 +150 -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 +19 -10
- 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 +55 -80
- 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/AssemblyType.tsx +9 -91
- package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +10 -182
- 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 +113 -1
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +6 -2
- package/src/components/order-view/types.ts +60 -1
- package/src/components/order-view/utils.ts +37 -33
- 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 +23 -5
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/helper.d.ts +0 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +0 -3
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +0 -57
- package/src/components/order-view/order-actions/actions/log-service-refusal/helper.ts +0 -26
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +0 -130
|
@@ -7,112 +7,53 @@ 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
|
-
|
|
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
|
+
const cleanedFilters = filters.filter(f => f.field !== 'order_status');
|
|
41
|
+
|
|
42
|
+
const modifiedFilters = [...baseFilters, ...cleanedFilters];
|
|
43
|
+
const { paginationData, fetchData: getPendingData } = useAxios<ApiResponse>({
|
|
106
44
|
endpoint: '/v1/return/product/pending/',
|
|
107
45
|
method: 'GET',
|
|
108
46
|
filters: modifiedFilters,
|
|
109
47
|
pagination: pagination,
|
|
110
48
|
});
|
|
111
49
|
|
|
50
|
+
// Debouncing effect
|
|
112
51
|
useEffect(() => {
|
|
113
|
-
|
|
52
|
+
const trimmedText = debouncedSearchText?.trim() || '';
|
|
53
|
+
|
|
54
|
+
if (trimmedText.length > 2) {
|
|
114
55
|
getPendingData({
|
|
115
|
-
endPointQuery: `?search_term=${
|
|
56
|
+
endPointQuery: `?search_term=${trimmedText}`,
|
|
116
57
|
}).then((response: any) => {
|
|
117
58
|
if (paginationData) {
|
|
118
59
|
const formattedPagination = javascriptStringDumpToJSON(
|
|
@@ -123,22 +64,18 @@ function ReturnSearchBar() {
|
|
|
123
64
|
}
|
|
124
65
|
|
|
125
66
|
if (response?.data?.length > 0) {
|
|
126
|
-
|
|
67
|
+
setOutstandingData(response.data);
|
|
127
68
|
} else {
|
|
128
|
-
|
|
69
|
+
setOutstandingData([]);
|
|
129
70
|
}
|
|
130
71
|
});
|
|
131
|
-
} else if (
|
|
132
|
-
debouncedSearchText.length > 0 &&
|
|
133
|
-
debouncedSearchText.length <= 2
|
|
134
|
-
) {
|
|
72
|
+
} else if (trimmedText.length > 0 && trimmedText.length <= 2) {
|
|
135
73
|
notification.warning({
|
|
136
|
-
message: 'Search
|
|
74
|
+
message: 'Search phrase cannot be less than 2 characters',
|
|
137
75
|
});
|
|
138
76
|
}
|
|
139
|
-
}, [debouncedSearchText,
|
|
77
|
+
}, [debouncedSearchText, JSON.stringify(modifiedFilters)]);
|
|
140
78
|
|
|
141
|
-
// Debouncing effect
|
|
142
79
|
useEffect(() => {
|
|
143
80
|
const handler = setTimeout(() => {
|
|
144
81
|
setDebouncedSearchText(searchText);
|
|
@@ -149,14 +86,47 @@ function ReturnSearchBar() {
|
|
|
149
86
|
}, [searchText]);
|
|
150
87
|
|
|
151
88
|
useEffect(() => {
|
|
152
|
-
if (debouncedSearchText
|
|
89
|
+
if (debouncedSearchText?.length === 0) {
|
|
153
90
|
setSearchText('');
|
|
154
91
|
}
|
|
155
92
|
}, [debouncedSearchText]);
|
|
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: [...cleanedFilters],
|
|
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)]);
|
|
156
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,21 @@ 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
|
-
const getDateFilters = (
|
|
38
|
-
startDate: dayjs.Dayjs | null,
|
|
39
|
-
endDate: dayjs.Dayjs | null
|
|
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;
|
|
39
|
+
const [debouncedSearchText, setOutstandingSearch] = useSearchText();
|
|
78
40
|
|
|
79
|
-
|
|
80
|
-
setModifiedFilters(dateFilters);
|
|
81
|
-
}, [startDate, endDate]);
|
|
82
|
-
|
|
83
|
-
//stats API
|
|
41
|
+
const cleanedFilters = filters.filter(f => f.field !== 'order_status');
|
|
84
42
|
|
|
43
|
+
const [
|
|
44
|
+
debouncedSearchAfterText,
|
|
45
|
+
setDebouncedSearchText,
|
|
46
|
+
] = useSearchAfterText();
|
|
85
47
|
const { data: statsData, loading: apiLoading, fetchData } = useAxios<{
|
|
86
48
|
data: returnCountType[];
|
|
87
49
|
}>({
|
|
@@ -89,12 +51,29 @@ const ReturnStatus = () => {
|
|
|
89
51
|
method: 'GET',
|
|
90
52
|
//@ts-ignore
|
|
91
53
|
pagination: { is_pagination: false },
|
|
92
|
-
filters:
|
|
54
|
+
filters: cleanedFilters,
|
|
93
55
|
});
|
|
94
56
|
|
|
95
57
|
useEffect(() => {
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
if (
|
|
59
|
+
clientPortal &&
|
|
60
|
+
debouncedSearchText === '' &&
|
|
61
|
+
status == 'outstanding_return'
|
|
62
|
+
) {
|
|
63
|
+
fetchData();
|
|
64
|
+
}
|
|
65
|
+
}, [debouncedSearchText, debouncedSearchAfterText, JSON.stringify(filters)]);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (
|
|
69
|
+
(clientPortal &&
|
|
70
|
+
debouncedSearchAfterText === '' &&
|
|
71
|
+
status == 'scheduled_for_return') ||
|
|
72
|
+
status == 'return_completed'
|
|
73
|
+
) {
|
|
74
|
+
fetchData();
|
|
75
|
+
}
|
|
76
|
+
}, [debouncedSearchAfterText, debouncedSearchText, JSON.stringify(filters)]);
|
|
98
77
|
|
|
99
78
|
useEffect(() => {
|
|
100
79
|
if (statsData && statsData?.data) {
|
|
@@ -108,31 +87,36 @@ const ReturnStatus = () => {
|
|
|
108
87
|
id: 1,
|
|
109
88
|
icon: 'outstanding_return',
|
|
110
89
|
status: 'outstanding_return',
|
|
111
|
-
count: count?.outstanding_count
|
|
90
|
+
count: count?.outstanding_count,
|
|
112
91
|
label: 'Outstanding Return',
|
|
113
92
|
},
|
|
114
93
|
{
|
|
115
94
|
id: 2,
|
|
116
95
|
icon: 'scheduled_for_return',
|
|
117
96
|
status: 'scheduled_for_return',
|
|
118
|
-
count: count?.scheduled_count
|
|
97
|
+
count: count?.scheduled_count,
|
|
119
98
|
label: 'Scheduled For Return',
|
|
120
99
|
},
|
|
121
100
|
{
|
|
122
101
|
id: 3,
|
|
123
102
|
icon: 'return_completed',
|
|
124
103
|
status: 'return_completed',
|
|
125
|
-
count: count?.completed_count
|
|
104
|
+
count: count?.completed_count,
|
|
126
105
|
label: 'Return Completed',
|
|
127
106
|
},
|
|
128
107
|
];
|
|
129
|
-
|
|
108
|
+
|
|
130
109
|
const handleCardClick = (item: any) => {
|
|
131
110
|
if (activeCardId === item?.id) {
|
|
132
111
|
return;
|
|
133
112
|
}
|
|
134
113
|
setActiveCardId(item?.id);
|
|
114
|
+
//for dev
|
|
135
115
|
navigate(`/return/${item?.status}`);
|
|
116
|
+
//for local
|
|
117
|
+
//navigate(`/${item?.status}`);
|
|
118
|
+
setOutstandingSearch('');
|
|
119
|
+
setDebouncedSearchText('');
|
|
136
120
|
if (item?.status == 'scheduled_for_return') {
|
|
137
121
|
dispatch({
|
|
138
122
|
type: 'SET_SCHEDULED_RETURN_FILTER',
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import {
|
|
4
|
+
useAtom,
|
|
5
|
+
useClientPortal,
|
|
6
|
+
// useCallApiAgain,
|
|
7
|
+
useReturnConfirmedOrderData,
|
|
8
|
+
useSearchAfterText,
|
|
9
|
+
} from '../../store';
|
|
10
|
+
import ReturnConfirmedTable from './ReturnConfirmedTable';
|
|
11
|
+
import {
|
|
12
|
+
useItemsPerReturnPage,
|
|
13
|
+
useLoading,
|
|
14
|
+
UsePaginationData,
|
|
15
|
+
UsePaginationReturnData,
|
|
16
|
+
} from '../../order-daily-overview/store/store';
|
|
17
|
+
import { filtersReducerReturnAtom } from '../../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
18
|
+
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
19
|
+
import { ApiResponse } from '../../types';
|
|
20
|
+
import { notification } from 'antd';
|
|
21
|
+
import ReturnPagination from '../../order-daily-overview/table-view/ReturnPagination';
|
|
22
|
+
// import { useParams } from 'react-router-dom';
|
|
23
|
+
import { dateFilterCPReducer } from '../DateFilterStore';
|
|
24
|
+
|
|
25
|
+
const ConfirmedMain = () => {
|
|
26
|
+
const [, setReturnConfirmedData] = useReturnConfirmedOrderData();
|
|
27
|
+
const [, setLoading] = useLoading();
|
|
28
|
+
const [statePagination] = useAtom(filtersReducerReturnAtom);
|
|
29
|
+
// const [callApi] = useCallApiAgain();
|
|
30
|
+
const { 'x-pagination': pagination } = statePagination;
|
|
31
|
+
const [state] = useAtom(dateFilterCPReducer);
|
|
32
|
+
const { 'x-filters': filters } = state;
|
|
33
|
+
const [paginationObj] = UsePaginationReturnData();
|
|
34
|
+
const [, setCurrentPage] = useState(1);
|
|
35
|
+
const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
|
|
36
|
+
const [, setPaginationObject] = UsePaginationData();
|
|
37
|
+
const { page, total } = paginationObj;
|
|
38
|
+
const [debouncedSearchText] = useSearchAfterText();
|
|
39
|
+
const handlePageChange = (page: number) => {
|
|
40
|
+
setCurrentPage(page);
|
|
41
|
+
};
|
|
42
|
+
const handleItemsPerPageChange = (itemsPerPage: number) => {
|
|
43
|
+
setItemsPerPage(itemsPerPage);
|
|
44
|
+
};
|
|
45
|
+
// const { status } = useParams();
|
|
46
|
+
const [clientPortal] = useClientPortal();
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
data: fetchedReturnOrderData,
|
|
50
|
+
loading,
|
|
51
|
+
paginationData,
|
|
52
|
+
fetchData,
|
|
53
|
+
} = useAxios<ApiResponse>({
|
|
54
|
+
endpoint: '/v1/return/orders/',
|
|
55
|
+
method: 'GET',
|
|
56
|
+
filters: filters,
|
|
57
|
+
pagination: pagination,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (clientPortal && debouncedSearchText === '') {
|
|
62
|
+
fetchData();
|
|
63
|
+
}
|
|
64
|
+
}, [JSON.stringify(filters), debouncedSearchText]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
setLoading(loading);
|
|
68
|
+
|
|
69
|
+
if (fetchedReturnOrderData?.data) {
|
|
70
|
+
setReturnConfirmedData(fetchedReturnOrderData?.data);
|
|
71
|
+
|
|
72
|
+
if (paginationData) {
|
|
73
|
+
try {
|
|
74
|
+
const { count, ...rest } = JSON.parse(paginationData);
|
|
75
|
+
setPaginationObject(rest);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
notification.error({
|
|
78
|
+
message: 'Error',
|
|
79
|
+
description: 'Failed to parse pagination data',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [fetchedReturnOrderData, loading]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<DashBoardWrapper>
|
|
89
|
+
{/* <RouterHeader /> */}
|
|
90
|
+
<div className="Tableconatiner">
|
|
91
|
+
{/* <HeaderFilter /> */}
|
|
92
|
+
<Container>
|
|
93
|
+
<ReturnConfirmedTable />
|
|
94
|
+
{total > 0 && (
|
|
95
|
+
<ReturnPagination
|
|
96
|
+
currentPage={page}
|
|
97
|
+
totalItems={total}
|
|
98
|
+
itemsPerPage={itemsPerPage}
|
|
99
|
+
onPageChange={handlePageChange}
|
|
100
|
+
onItemsPerPageChange={handleItemsPerPageChange}
|
|
101
|
+
></ReturnPagination>
|
|
102
|
+
)}
|
|
103
|
+
</Container>
|
|
104
|
+
</div>
|
|
105
|
+
</DashBoardWrapper>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
const Container = styled.div`
|
|
110
|
+
position: relative;
|
|
111
|
+
/* top: -30px; */
|
|
112
|
+
`;
|
|
113
|
+
const DashBoardWrapper = styled.section`
|
|
114
|
+
.Tableconatiner {
|
|
115
|
+
border-radius: 12px;
|
|
116
|
+
background: #fff;
|
|
117
|
+
box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);
|
|
118
|
+
display: block;
|
|
119
|
+
padding: 15px 20px;
|
|
120
|
+
}
|
|
121
|
+
.headerWrap,
|
|
122
|
+
.tableData,
|
|
123
|
+
.styleCovered {
|
|
124
|
+
transition: all ease 0.5s;
|
|
125
|
+
}
|
|
126
|
+
&.stickyTableHead {
|
|
127
|
+
h2 {
|
|
128
|
+
font-size: 21px;
|
|
129
|
+
}
|
|
130
|
+
.headerWrap {
|
|
131
|
+
height: 84px;
|
|
132
|
+
padding: 10px;
|
|
133
|
+
border-radius: 0px 0px 15px 15px;
|
|
134
|
+
> div {
|
|
135
|
+
position: relative;
|
|
136
|
+
z-index: 10;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
.styleCovered {
|
|
140
|
+
margin-top: -32px;
|
|
141
|
+
width: 67%;
|
|
142
|
+
float: right;
|
|
143
|
+
gap: 5px;
|
|
144
|
+
padding-right: 11px;
|
|
145
|
+
|
|
146
|
+
li {
|
|
147
|
+
padding: 4px 10px 5px 5px;
|
|
148
|
+
gap: 5px;
|
|
149
|
+
.svgCover {
|
|
150
|
+
width: 30px;
|
|
151
|
+
height: 30px;
|
|
152
|
+
svg {
|
|
153
|
+
height: auto;
|
|
154
|
+
width: 58%;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.countDigit {
|
|
158
|
+
font-size: 19px;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
.countMess {
|
|
162
|
+
font-size: 13px;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
.dmsBulkFilter {
|
|
166
|
+
min-height: unset;
|
|
167
|
+
gap: 4px;
|
|
168
|
+
> div {
|
|
169
|
+
padding: 4px 12px;
|
|
170
|
+
label {
|
|
171
|
+
font-size: 11px;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.StyledFilterList {
|
|
177
|
+
gap: 4px;
|
|
178
|
+
li {
|
|
179
|
+
height: 29px;
|
|
180
|
+
padding: 3px 8px;
|
|
181
|
+
gap: 4px;
|
|
182
|
+
.StyledFilterBtnIcon {
|
|
183
|
+
width: 20px;
|
|
184
|
+
height: 20px;
|
|
185
|
+
svh {
|
|
186
|
+
width: 10px;
|
|
187
|
+
height: auto;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
.StyledFilterBtnLabel {
|
|
191
|
+
font-size: 13px;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
.StyledFilterLabel {
|
|
196
|
+
padding-left: 10px;
|
|
197
|
+
span {
|
|
198
|
+
font-size: 13px;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
.cardcontainer.tableData {
|
|
202
|
+
max-height: calc(100vh - 310px);
|
|
203
|
+
min-height: calc(100vh - 310px);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.tableData {
|
|
207
|
+
max-height: calc(100vh - 320px);
|
|
208
|
+
min-height: calc(100vh - 320px);
|
|
209
|
+
|
|
210
|
+
margin-top: 8px;
|
|
211
|
+
thead {
|
|
212
|
+
position: sticky;
|
|
213
|
+
top: 0;
|
|
214
|
+
z-index: 9;
|
|
215
|
+
th {
|
|
216
|
+
font-size: 13px;
|
|
217
|
+
padding: 2px 15px;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
export default ConfirmedMain;
|