@bjsdistribution/dms-client-return 0.1.9-prod → 0.1.10-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/components/client-portal/OutstandingTable.d.ts +3 -0
- package/dist/components/client-portal/ReturnAfterSearchBar.d.ts +4 -0
- package/dist/components/client-portal/ReturnOverview.d.ts +3 -0
- package/dist/components/client-portal/ReturnRTFilters.d.ts +5 -0
- package/dist/components/client-portal/ReturnSearchBar.d.ts +4 -0
- package/dist/components/client-portal/ReturnStatus.d.ts +8 -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/common/fakedata.d.ts +1 -0
- package/dist/components/order-daily-overview/header/route-header/RouterHeader.d.ts +1 -0
- 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/products-info/expanded-content/index.d.ts +4 -1
- package/dist/components/order-view/return-client-products/ProductTable.d.ts +4 -1
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +4 -1
- package/dist/components/order-view/store.d.ts +14 -2
- package/dist/components/order-view/types.d.ts +49 -1
- package/dist/components/order-view/utils.d.ts +3 -0
- package/dist/components/store.d.ts +12 -1
- package/dist/components/utils.d.ts +1 -0
- package/dist/dms-client-return.cjs.development.js +7053 -2711
- 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 +7111 -2769
- 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/OutstandingTable.tsx +412 -0
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +242 -0
- package/src/components/client-portal/ReturnOverview.tsx +185 -0
- package/src/components/client-portal/ReturnRTFilters.tsx +228 -0
- package/src/components/client-portal/ReturnSearchBar.tsx +294 -0
- package/src/components/client-portal/ReturnStatus.tsx +252 -0
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +235 -0
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +404 -0
- package/src/components/order-daily-overview/common/fakedata.tsx +18 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +130 -1
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +15 -3
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +100 -70
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +4 -0
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +86 -0
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +12 -2
- package/src/components/order-daily-overview/return-after-table/table-filters/TableFilters.tsx +22 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +34 -6
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +24 -11
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +26 -6
- package/src/components/order-daily-overview/shared/elements/PrintDropDown.tsx +5 -3
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +5 -0
- package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
- package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
- package/src/components/order-view/index.tsx +45 -0
- package/src/components/order-view/notes/AddNote.tsx +94 -65
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
- package/src/components/order-view/notification/OrderTemplate.tsx +192 -41
- 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/create-task-reminder/CreateReminderModal.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 +15 -3
- package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
- package/src/components/order-view/products-info/expanded-content/index.tsx +27 -11
- package/src/components/order-view/products-info/index.tsx +4 -4
- package/src/components/order-view/return-client-products/ProductTable.tsx +6 -2
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +54 -15
- package/src/components/order-view/store.ts +106 -0
- package/src/components/order-view/types.ts +54 -1
- package/src/components/order-view/utils.ts +37 -0
- package/src/components/store.ts +62 -1
- package/src/components/utils.ts +13 -3
- package/src/index.tsx +26 -16
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
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
|
+
import {
|
|
18
|
+
useAtom,
|
|
19
|
+
// useCallApiAgain,
|
|
20
|
+
useReturnConfirmedOrderData,
|
|
21
|
+
useSearchAfterText,
|
|
22
|
+
} from '../../store';
|
|
23
|
+
import ReturnConfirmedTable from './ReturnConfirmedTable';
|
|
24
|
+
import {
|
|
25
|
+
useItemsPerReturnPage,
|
|
26
|
+
useLoading,
|
|
27
|
+
UsePaginationData,
|
|
28
|
+
UsePaginationReturnData,
|
|
29
|
+
} from '../../order-daily-overview/store/store';
|
|
30
|
+
import { filtersReducerReturnAtom } from '../../order-daily-overview/return-after-table/table-filters/ReturnFilterStore';
|
|
31
|
+
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
32
|
+
import { ApiResponse } from '../../types';
|
|
33
|
+
import { notification } from 'antd';
|
|
34
|
+
import ReturnPagination from '../../order-daily-overview/table-view/ReturnPagination';
|
|
35
|
+
import { useParams } from 'react-router-dom';
|
|
36
|
+
|
|
37
|
+
const ConfirmedMain = () => {
|
|
38
|
+
const [, setReturnConfirmedData] = useReturnConfirmedOrderData();
|
|
39
|
+
const [, setLoading] = useLoading();
|
|
40
|
+
const [state] = useAtom(filtersReducerReturnAtom);
|
|
41
|
+
// const [callApi] = useCallApiAgain();
|
|
42
|
+
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
43
|
+
const [paginationObj] = UsePaginationReturnData();
|
|
44
|
+
const [, setCurrentPage] = useState(1);
|
|
45
|
+
const [itemsPerPage, setItemsPerPage] = useItemsPerReturnPage();
|
|
46
|
+
const [, setPaginationObject] = UsePaginationData();
|
|
47
|
+
const { page, total } = paginationObj;
|
|
48
|
+
const [debouncedSearchText] = useSearchAfterText();
|
|
49
|
+
const handlePageChange = (page: number) => {
|
|
50
|
+
setCurrentPage(page);
|
|
51
|
+
};
|
|
52
|
+
const handleItemsPerPageChange = (itemsPerPage: number) => {
|
|
53
|
+
setItemsPerPage(itemsPerPage);
|
|
54
|
+
};
|
|
55
|
+
const { status } = useParams();
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
data: fetchedReturnOrderData,
|
|
59
|
+
loading,
|
|
60
|
+
paginationData,
|
|
61
|
+
fetchData,
|
|
62
|
+
} = useAxios<ApiResponse>({
|
|
63
|
+
endpoint: '/v1/return/orders/',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
filters: filters && filters?.length > 0 ? filters : undefined,
|
|
66
|
+
pagination: pagination,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const shouldFetch = debouncedSearchText === '' && filters?.length > 0;
|
|
71
|
+
|
|
72
|
+
if (shouldFetch) {
|
|
73
|
+
fetchData();
|
|
74
|
+
}
|
|
75
|
+
}, [debouncedSearchText, status, JSON.stringify(filters)]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setLoading(loading);
|
|
79
|
+
|
|
80
|
+
if (fetchedReturnOrderData?.data) {
|
|
81
|
+
setReturnConfirmedData(fetchedReturnOrderData?.data);
|
|
82
|
+
|
|
83
|
+
if (paginationData) {
|
|
84
|
+
try {
|
|
85
|
+
const { count, ...rest } = JSON.parse(paginationData);
|
|
86
|
+
setPaginationObject(rest);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
notification.error({
|
|
89
|
+
message: 'Error',
|
|
90
|
+
description: 'Failed to parse pagination data',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [fetchedReturnOrderData, loading]);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div>
|
|
99
|
+
<DashBoardWrapper>
|
|
100
|
+
{/* <RouterHeader /> */}
|
|
101
|
+
<div className="Tableconatiner">
|
|
102
|
+
{/* <HeaderFilter /> */}
|
|
103
|
+
<Container>
|
|
104
|
+
<ReturnConfirmedTable />
|
|
105
|
+
{total > 0 && (
|
|
106
|
+
<ReturnPagination
|
|
107
|
+
currentPage={page}
|
|
108
|
+
totalItems={total}
|
|
109
|
+
itemsPerPage={itemsPerPage}
|
|
110
|
+
onPageChange={handlePageChange}
|
|
111
|
+
onItemsPerPageChange={handleItemsPerPageChange}
|
|
112
|
+
></ReturnPagination>
|
|
113
|
+
)}
|
|
114
|
+
</Container>
|
|
115
|
+
</div>
|
|
116
|
+
</DashBoardWrapper>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
const Container = styled.div`
|
|
121
|
+
position: relative;
|
|
122
|
+
/* top: -30px; */
|
|
123
|
+
`;
|
|
124
|
+
const DashBoardWrapper = styled.section`
|
|
125
|
+
.Tableconatiner {
|
|
126
|
+
border-radius: 12px;
|
|
127
|
+
background: #fff;
|
|
128
|
+
box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);
|
|
129
|
+
display: block;
|
|
130
|
+
padding: 15px 20px;
|
|
131
|
+
}
|
|
132
|
+
.headerWrap,
|
|
133
|
+
.tableData,
|
|
134
|
+
.styleCovered {
|
|
135
|
+
transition: all ease 0.5s;
|
|
136
|
+
}
|
|
137
|
+
&.stickyTableHead {
|
|
138
|
+
h2 {
|
|
139
|
+
font-size: 21px;
|
|
140
|
+
}
|
|
141
|
+
.headerWrap {
|
|
142
|
+
height: 84px;
|
|
143
|
+
padding: 10px;
|
|
144
|
+
border-radius: 0px 0px 15px 15px;
|
|
145
|
+
> div {
|
|
146
|
+
position: relative;
|
|
147
|
+
z-index: 10;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
.styleCovered {
|
|
151
|
+
margin-top: -32px;
|
|
152
|
+
width: 67%;
|
|
153
|
+
float: right;
|
|
154
|
+
gap: 5px;
|
|
155
|
+
padding-right: 11px;
|
|
156
|
+
|
|
157
|
+
li {
|
|
158
|
+
padding: 4px 10px 5px 5px;
|
|
159
|
+
gap: 5px;
|
|
160
|
+
.svgCover {
|
|
161
|
+
width: 30px;
|
|
162
|
+
height: 30px;
|
|
163
|
+
svg {
|
|
164
|
+
height: auto;
|
|
165
|
+
width: 58%;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
.countDigit {
|
|
169
|
+
font-size: 19px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
.countMess {
|
|
173
|
+
font-size: 13px;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
.dmsBulkFilter {
|
|
177
|
+
min-height: unset;
|
|
178
|
+
gap: 4px;
|
|
179
|
+
> div {
|
|
180
|
+
padding: 4px 12px;
|
|
181
|
+
label {
|
|
182
|
+
font-size: 11px;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.StyledFilterList {
|
|
188
|
+
gap: 4px;
|
|
189
|
+
li {
|
|
190
|
+
height: 29px;
|
|
191
|
+
padding: 3px 8px;
|
|
192
|
+
gap: 4px;
|
|
193
|
+
.StyledFilterBtnIcon {
|
|
194
|
+
width: 20px;
|
|
195
|
+
height: 20px;
|
|
196
|
+
svh {
|
|
197
|
+
width: 10px;
|
|
198
|
+
height: auto;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
.StyledFilterBtnLabel {
|
|
202
|
+
font-size: 13px;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
.StyledFilterLabel {
|
|
207
|
+
padding-left: 10px;
|
|
208
|
+
span {
|
|
209
|
+
font-size: 13px;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
.cardcontainer.tableData {
|
|
213
|
+
max-height: calc(100vh - 310px);
|
|
214
|
+
min-height: calc(100vh - 310px);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.tableData {
|
|
218
|
+
max-height: calc(100vh - 320px);
|
|
219
|
+
min-height: calc(100vh - 320px);
|
|
220
|
+
|
|
221
|
+
margin-top: 8px;
|
|
222
|
+
thead {
|
|
223
|
+
position: sticky;
|
|
224
|
+
top: 0;
|
|
225
|
+
z-index: 9;
|
|
226
|
+
th {
|
|
227
|
+
font-size: 13px;
|
|
228
|
+
padding: 2px 15px;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
export default ConfirmedMain;
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { Empty } from 'antd';
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Skeleton } from 'antd';
|
|
4
|
+
import { NavLink } from 'react-router-dom';
|
|
5
|
+
import {
|
|
6
|
+
Checkbox,
|
|
7
|
+
displayValueOrNA,
|
|
8
|
+
// useApiHook,
|
|
9
|
+
} from '@bjsdistribution/dms-component-library';
|
|
10
|
+
import {
|
|
11
|
+
useLoading,
|
|
12
|
+
usePrintOptionTOggle,
|
|
13
|
+
} from '../../order-daily-overview/store/store';
|
|
14
|
+
import {
|
|
15
|
+
useReturnConfirmedOrderData,
|
|
16
|
+
useSelectedClientAfterOrders,
|
|
17
|
+
} from '../../store';
|
|
18
|
+
import { useOrderId } from '../../order-view/store';
|
|
19
|
+
import SortIcon from '../../../common/SortIcon';
|
|
20
|
+
import CaretDownFilledIcon from '../../../common/CaretDownFilledIcon';
|
|
21
|
+
import {
|
|
22
|
+
CustomDrop,
|
|
23
|
+
EmptyDataContainer,
|
|
24
|
+
StyledTable,
|
|
25
|
+
StyledTableWrapper,
|
|
26
|
+
} from '../../order-daily-overview/return-order-table/return-orders-filters/returnstyles';
|
|
27
|
+
import PrinterIcon from '../../../assets/icons/PrinterIcon';
|
|
28
|
+
import DownIcon from '../../../assets/icons/DownIcon';
|
|
29
|
+
import PrintDropDown from '../../order-daily-overview/shared/elements/PrintDropDown';
|
|
30
|
+
import { formatDate } from '../../order-daily-overview/shared/utlis';
|
|
31
|
+
|
|
32
|
+
const ReturnConfirmedTable = () => {
|
|
33
|
+
const dropdownRefParent = useRef<HTMLDivElement>(null);
|
|
34
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
35
|
+
const [printToogle, setPrintToggle] = usePrintOptionTOggle();
|
|
36
|
+
const [, setOrderId] = useOrderId();
|
|
37
|
+
const [returnConfirmedTable] = useReturnConfirmedOrderData();
|
|
38
|
+
const [loading] = useLoading();
|
|
39
|
+
const [selectClientAll, setSelectClientAll] = useState(false);
|
|
40
|
+
const [
|
|
41
|
+
selectedOrderIds,
|
|
42
|
+
setSelectedOrderIds,
|
|
43
|
+
] = useSelectedClientAfterOrders();
|
|
44
|
+
//sorting
|
|
45
|
+
const [sortConfig, setSortConfig] = useState<{
|
|
46
|
+
key: string;
|
|
47
|
+
direction: 'asc' | 'desc';
|
|
48
|
+
} | null>(null);
|
|
49
|
+
|
|
50
|
+
const handleSort = (key: string) => {
|
|
51
|
+
setSortConfig((prev: any) => {
|
|
52
|
+
if (prev?.key === key && prev.direction === 'asc') {
|
|
53
|
+
return { key, direction: 'desc' };
|
|
54
|
+
}
|
|
55
|
+
return { key, direction: 'asc' };
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const sortedData = useMemo(() => {
|
|
60
|
+
if (!returnConfirmedTable || !sortConfig) return returnConfirmedTable;
|
|
61
|
+
|
|
62
|
+
const { key, direction } = sortConfig;
|
|
63
|
+
return [...returnConfirmedTable].sort((a, b) => {
|
|
64
|
+
const valueA = a[key];
|
|
65
|
+
const valueB = b[key];
|
|
66
|
+
|
|
67
|
+
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
68
|
+
return direction === 'asc' ? valueA - valueB : valueB - valueA;
|
|
69
|
+
}
|
|
70
|
+
if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
71
|
+
return direction === 'asc'
|
|
72
|
+
? valueA.localeCompare(valueB)
|
|
73
|
+
: valueB.localeCompare(valueA);
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
});
|
|
77
|
+
}, [returnConfirmedTable, sortConfig]);
|
|
78
|
+
|
|
79
|
+
const renderSortIcon = (columnKey: string) => {
|
|
80
|
+
if (!sortConfig || sortConfig.key !== columnKey) {
|
|
81
|
+
return <SortIcon />;
|
|
82
|
+
}
|
|
83
|
+
return sortConfig.direction === 'asc' ? (
|
|
84
|
+
<CaretDownFilledIcon />
|
|
85
|
+
) : (
|
|
86
|
+
<CaretDownFilledIcon />
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const OpenDropDown = (index: number) => {
|
|
91
|
+
setPrintToggle((prevIndex: any) => (prevIndex === index ? null : index));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Close dropdown outside click
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
97
|
+
return () => {
|
|
98
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
99
|
+
};
|
|
100
|
+
}, []);
|
|
101
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
102
|
+
if (
|
|
103
|
+
dropdownRef.current &&
|
|
104
|
+
!dropdownRef.current.contains(event.target as Node)
|
|
105
|
+
) {
|
|
106
|
+
setPrintToggle(null);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
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
|
+
const getStatusClass = (status: string) => {
|
|
139
|
+
switch (status) {
|
|
140
|
+
case 'Cancelled':
|
|
141
|
+
return { color: '#E95252', background: 'rgba(233, 82, 82, 0.15)' };
|
|
142
|
+
case 'On Hold':
|
|
143
|
+
return { color: '#F4A503', background: '#FFF1D6' };
|
|
144
|
+
case 'Sub-Contracted':
|
|
145
|
+
return { color: '#F4A503', background: '#FFF1D6' };
|
|
146
|
+
case 'Awaiting route':
|
|
147
|
+
return { color: '#845ADF', background: 'rgba(132, 90, 223, 0.15)' };
|
|
148
|
+
case 'Awaiting':
|
|
149
|
+
return { color: '#845ADF', background: 'rgba(132, 90, 223, 0.15)' };
|
|
150
|
+
case 'Completed':
|
|
151
|
+
return {
|
|
152
|
+
color: '#1F9254',
|
|
153
|
+
background: 'rgba(41, 204, 106, 0.15)',
|
|
154
|
+
};
|
|
155
|
+
case 'Outstanding':
|
|
156
|
+
return { color: '#FF9900', background: 'rgba(255, 153, 0, 0.15)' };
|
|
157
|
+
case 'Routed':
|
|
158
|
+
return { color: '#6396E5', background: 'rgba(99, 150, 229, 0.15)' };
|
|
159
|
+
default:
|
|
160
|
+
return { color: '#000', background: '#fff' };
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
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
|
+
const handleSelectOrderId = (id: string | number) => {
|
|
215
|
+
setSelectedOrderIds(prev =>
|
|
216
|
+
prev.includes(id) ? prev.filter(orderId => orderId !== id) : [...prev, id]
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
const handleClientSelectAll = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
220
|
+
const isChecked = e.target.checked;
|
|
221
|
+
setSelectClientAll(isChecked);
|
|
222
|
+
|
|
223
|
+
if (isChecked) {
|
|
224
|
+
setSelectedOrderIds(
|
|
225
|
+
returnConfirmedTable?.map((item: any) => item?.id) || []
|
|
226
|
+
);
|
|
227
|
+
} else {
|
|
228
|
+
setSelectedOrderIds([]);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
console.log('selectedOrderIds===>', selectedOrderIds);
|
|
232
|
+
console.log('returnConfirmedTable=====>', returnConfirmedTable);
|
|
233
|
+
return (
|
|
234
|
+
<>
|
|
235
|
+
<StyledTableWrapper className="fortables">
|
|
236
|
+
<StyledTable>
|
|
237
|
+
<thead>
|
|
238
|
+
<tr>
|
|
239
|
+
{/* <th className="emailInvoiceCheckbox">
|
|
240
|
+
<Checkbox checked={false} />
|
|
241
|
+
</th> */}
|
|
242
|
+
<th className="emailInvoiceCheckbox">
|
|
243
|
+
<Checkbox
|
|
244
|
+
checked={selectClientAll}
|
|
245
|
+
onChange={handleClientSelectAll}
|
|
246
|
+
/>
|
|
247
|
+
</th>
|
|
248
|
+
<th onClick={() => handleSort('created_at')}>
|
|
249
|
+
<div className="sortIconClass">
|
|
250
|
+
Created {renderSortIcon('created_at')}
|
|
251
|
+
</div>
|
|
252
|
+
</th>
|
|
253
|
+
<th onClick={() => handleSort('return_location_name')}>
|
|
254
|
+
<div className="sortIconClass">
|
|
255
|
+
Return Location {renderSortIcon('return_location_name')}
|
|
256
|
+
</div>
|
|
257
|
+
</th>
|
|
258
|
+
<th onClick={() => handleSort('recipient_name')}>
|
|
259
|
+
<div className="sortIconClass">
|
|
260
|
+
Recipient {renderSortIcon('recipient_name')}
|
|
261
|
+
</div>
|
|
262
|
+
</th>
|
|
263
|
+
<th> Client</th>
|
|
264
|
+
<th>Consignment</th>
|
|
265
|
+
<th>Return Order No</th>
|
|
266
|
+
<th> Total Parts</th>
|
|
267
|
+
<th onClick={() => handleSort('weight')}>
|
|
268
|
+
<div className="sortIconClass">
|
|
269
|
+
Total Weight {renderSortIcon('weight')}
|
|
270
|
+
</div>
|
|
271
|
+
</th>
|
|
272
|
+
<th onClick={() => handleSort('cube')}>
|
|
273
|
+
<div className="sortIconClass">
|
|
274
|
+
Total CBM {renderSortIcon('cube')}
|
|
275
|
+
</div>
|
|
276
|
+
</th>
|
|
277
|
+
<th>Status</th>
|
|
278
|
+
<th className="emailInvoiceShare">Labels</th>
|
|
279
|
+
</tr>
|
|
280
|
+
</thead>
|
|
281
|
+
<tbody>
|
|
282
|
+
{loading ? (
|
|
283
|
+
<tr>
|
|
284
|
+
<td colSpan={16}>
|
|
285
|
+
<Skeleton active />
|
|
286
|
+
</td>
|
|
287
|
+
<td colSpan={16}></td>
|
|
288
|
+
</tr>
|
|
289
|
+
) : sortedData?.length === 0 ? (
|
|
290
|
+
<tr>
|
|
291
|
+
<td colSpan={16}>
|
|
292
|
+
<EmptyDataContainer>
|
|
293
|
+
<Empty />
|
|
294
|
+
</EmptyDataContainer>
|
|
295
|
+
</td>
|
|
296
|
+
</tr>
|
|
297
|
+
) : (
|
|
298
|
+
sortedData?.map((item: any, index: any) => {
|
|
299
|
+
const statusMapping: any = {
|
|
300
|
+
cancelled: 'Cancelled',
|
|
301
|
+
'on hold': 'On Hold',
|
|
302
|
+
SC: 'Sub-Contracted',
|
|
303
|
+
'awaiting route': 'Awaiting',
|
|
304
|
+
'awaiting confirmation': 'Awaiting',
|
|
305
|
+
complete: 'Completed',
|
|
306
|
+
outstanding: 'Outstanding',
|
|
307
|
+
routed: 'Routed',
|
|
308
|
+
failed: 'Failed',
|
|
309
|
+
};
|
|
310
|
+
const status = statusMapping[item?.status_value] || 'Unknown';
|
|
311
|
+
const statusClass = getStatusClass(status);
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<tr key={item.id}>
|
|
315
|
+
<td>
|
|
316
|
+
<Checkbox
|
|
317
|
+
checked={selectedOrderIds.includes(item?.id)}
|
|
318
|
+
onChange={() => handleSelectOrderId(item?.id)}
|
|
319
|
+
/>
|
|
320
|
+
</td>
|
|
321
|
+
<td>{formatDate(new Date(item?.created_at))}</td>
|
|
322
|
+
<td>{displayValueOrNA(item?.return_location_name)}</td>
|
|
323
|
+
<td onClick={() => setOrderId(item.id)}>
|
|
324
|
+
<ul style={{ listStyleType: 'none', padding: 0 }}>
|
|
325
|
+
<li
|
|
326
|
+
style={{
|
|
327
|
+
color: '#0099ff',
|
|
328
|
+
fontWeight: 600,
|
|
329
|
+
paddingLeft: 0,
|
|
330
|
+
}}
|
|
331
|
+
>
|
|
332
|
+
<NavLink to={`../${item.id}`}>
|
|
333
|
+
{displayValueOrNA(item?.recipient_name)}
|
|
334
|
+
</NavLink>
|
|
335
|
+
</li>
|
|
336
|
+
<li style={{ color: '#888075' }}>
|
|
337
|
+
{displayValueOrNA(item?.postcode)}
|
|
338
|
+
</li>
|
|
339
|
+
</ul>
|
|
340
|
+
</td>
|
|
341
|
+
|
|
342
|
+
<td>{displayValueOrNA(item?.customer_name)}</td>
|
|
343
|
+
|
|
344
|
+
<td>{displayValueOrNA(item?.consignment)}</td>
|
|
345
|
+
<td>{displayValueOrNA(item?.order_number)}</td>
|
|
346
|
+
|
|
347
|
+
<td>{displayValueOrNA(item?.total_products)}</td>
|
|
348
|
+
<td>
|
|
349
|
+
{displayValueOrNA(item?.weight)}{' '}
|
|
350
|
+
{item?.weight && item?.weight > 0 ? 'KG' : ''}
|
|
351
|
+
</td>
|
|
352
|
+
|
|
353
|
+
<td>{displayValueOrNA(item?.cube)}</td>
|
|
354
|
+
|
|
355
|
+
<td>
|
|
356
|
+
<ul
|
|
357
|
+
className="statuscontainer"
|
|
358
|
+
style={{
|
|
359
|
+
listStyleType: 'none',
|
|
360
|
+
background: statusClass.background,
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<li
|
|
364
|
+
className="statustext"
|
|
365
|
+
style={{ color: statusClass.color }}
|
|
366
|
+
>
|
|
367
|
+
{status}
|
|
368
|
+
</li>
|
|
369
|
+
</ul>
|
|
370
|
+
</td>
|
|
371
|
+
<td>
|
|
372
|
+
<ul className="actionbox">
|
|
373
|
+
<CustomDrop
|
|
374
|
+
ref={dropdownRefParent}
|
|
375
|
+
className={printToogle === index ? 'active' : ''}
|
|
376
|
+
>
|
|
377
|
+
<li
|
|
378
|
+
className="shareIconContainer"
|
|
379
|
+
onClick={() => OpenDropDown(index)}
|
|
380
|
+
>
|
|
381
|
+
<PrinterIcon />
|
|
382
|
+
<DownIcon />
|
|
383
|
+
|
|
384
|
+
{printToogle === index && (
|
|
385
|
+
<div ref={dropdownRef}>
|
|
386
|
+
<PrintDropDown legacyProductId={item} />
|
|
387
|
+
</div>
|
|
388
|
+
)}
|
|
389
|
+
</li>
|
|
390
|
+
</CustomDrop>
|
|
391
|
+
</ul>
|
|
392
|
+
</td>
|
|
393
|
+
</tr>
|
|
394
|
+
);
|
|
395
|
+
})
|
|
396
|
+
)}
|
|
397
|
+
</tbody>
|
|
398
|
+
</StyledTable>
|
|
399
|
+
</StyledTableWrapper>
|
|
400
|
+
</>
|
|
401
|
+
);
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
export default ReturnConfirmedTable;
|
|
@@ -119,6 +119,24 @@ export const optionsPrint: PrintOption[] = [
|
|
|
119
119
|
},
|
|
120
120
|
];
|
|
121
121
|
|
|
122
|
+
export const optionsClientPortPrint: PrintOption[] = [
|
|
123
|
+
{
|
|
124
|
+
icon: 'deliveryLables',
|
|
125
|
+
label: 'Print Delivery Labels',
|
|
126
|
+
type: 'delivery_label_url',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
icon: 'customerLables',
|
|
130
|
+
label: 'Print Customer Labels',
|
|
131
|
+
type: 'customer_label_url',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
icon: 'collectionLables',
|
|
135
|
+
label: 'Print Return Labels',
|
|
136
|
+
type: 'return_label_url',
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
122
140
|
export const optionsForReturnPrint = [
|
|
123
141
|
{ icon: 'deliveryLables', label: 'Print Return Labels' },
|
|
124
142
|
];
|