@bjsdistribution/dms-client-return 0.0.36 → 0.0.38
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/CaretDownFilledIcon.d.ts +3 -0
- package/dist/common/CaretUpFilledIcon.d.ts +3 -0
- package/dist/common/SortIcon.d.ts +3 -0
- package/dist/components/order-daily-overview/store/store.d.ts +1 -0
- package/dist/dms-client-return.cjs.development.js +296 -97
- 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 +296 -97
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/common/CaretDownFilledIcon.tsx +27 -0
- package/src/common/CaretUpFilledIcon.tsx +27 -0
- package/src/common/SortIcon.tsx +23 -0
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +12 -11
- package/src/components/order-daily-overview/index.tsx +29 -33
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +102 -21
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +4 -0
- package/src/components/order-daily-overview/store/store.ts +8 -2
- package/src/components/order-daily-overview/table/ReturnTable.tsx +77 -18
- package/src/components/order-view/modalsPopup/ModalManager.tsx +5 -34
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
useAtom,
|
|
4
4
|
useClientData,
|
|
5
5
|
useOrderStaticData,
|
|
6
6
|
} from '../../order-view/store';
|
|
7
|
-
import {
|
|
7
|
+
import { useStatsLoading } from '../store/store';
|
|
8
8
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
9
9
|
import {
|
|
10
10
|
ColumStyle,
|
|
@@ -17,6 +17,9 @@ import { Empty, Skeleton } from 'antd';
|
|
|
17
17
|
import { useNavigate } from 'react-router-dom';
|
|
18
18
|
import { filtersReducerAtom } from '../header-filters/filterStore';
|
|
19
19
|
import { useCustomerData } from '../../store';
|
|
20
|
+
import SortIcon from '../../../common/SortIcon';
|
|
21
|
+
import CaretDownFilledIcon from '../../../common/CaretDownFilledIcon';
|
|
22
|
+
import Loader from '../header/loader/Loader';
|
|
20
23
|
|
|
21
24
|
interface ApiResponse {
|
|
22
25
|
message: string;
|
|
@@ -29,12 +32,59 @@ interface ApiResponse {
|
|
|
29
32
|
const ReturnTable: React.FC = () => {
|
|
30
33
|
const [clientData] = useClientData();
|
|
31
34
|
const [updatedData, setUpdatedData] = useState<any>([]);
|
|
32
|
-
const [statsLoading, setLoading] =
|
|
35
|
+
const [statsLoading, setLoading] = useStatsLoading();
|
|
33
36
|
const [, setOrderStaticData] = useOrderStaticData();
|
|
34
37
|
const [, dispatch] = useAtom(filtersReducerAtom);
|
|
35
38
|
const navigate = useNavigate();
|
|
36
39
|
const [customers] = useCustomerData();
|
|
37
40
|
|
|
41
|
+
//sorting
|
|
42
|
+
const [sortConfig, setSortConfig] = useState<{
|
|
43
|
+
key: string;
|
|
44
|
+
direction: 'asc' | 'desc';
|
|
45
|
+
} | null>(null);
|
|
46
|
+
|
|
47
|
+
const handleSort = (key: string) => {
|
|
48
|
+
setSortConfig(prev => {
|
|
49
|
+
if (prev?.key === key && prev.direction === 'asc') {
|
|
50
|
+
return { key, direction: 'desc' };
|
|
51
|
+
}
|
|
52
|
+
return { key, direction: 'asc' };
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const sortedData = useMemo(() => {
|
|
57
|
+
if (!updatedData || !sortConfig) return updatedData;
|
|
58
|
+
|
|
59
|
+
const { key, direction } = sortConfig;
|
|
60
|
+
return [...updatedData].sort((a, b) => {
|
|
61
|
+
const valueA = a[key];
|
|
62
|
+
const valueB = b[key];
|
|
63
|
+
|
|
64
|
+
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
65
|
+
return direction === 'asc' ? valueA - valueB : valueB - valueA;
|
|
66
|
+
}
|
|
67
|
+
if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
68
|
+
return direction === 'asc'
|
|
69
|
+
? valueA.localeCompare(valueB)
|
|
70
|
+
: valueB.localeCompare(valueA);
|
|
71
|
+
}
|
|
72
|
+
return 0;
|
|
73
|
+
});
|
|
74
|
+
}, [updatedData, sortConfig]);
|
|
75
|
+
|
|
76
|
+
const renderSortIcon = (columnKey: string) => {
|
|
77
|
+
if (!sortConfig || sortConfig.key !== columnKey) {
|
|
78
|
+
return <SortIcon />;
|
|
79
|
+
}
|
|
80
|
+
return sortConfig.direction === 'asc' ? (
|
|
81
|
+
<CaretDownFilledIcon />
|
|
82
|
+
) : (
|
|
83
|
+
<CaretDownFilledIcon />
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//API call
|
|
38
88
|
const { data: fetchedStaticData, loading: staticDataLoading } = useApiHook<{
|
|
39
89
|
data: ApiResponse[];
|
|
40
90
|
}>({
|
|
@@ -91,29 +141,38 @@ const ReturnTable: React.FC = () => {
|
|
|
91
141
|
payload: [],
|
|
92
142
|
});
|
|
93
143
|
}
|
|
94
|
-
navigate(`filter/${customerId}`);
|
|
144
|
+
//navigate(`filter/${customerId}`);
|
|
95
145
|
|
|
96
146
|
//forlocal
|
|
97
|
-
|
|
147
|
+
navigate(`/filter/${customerId}`);
|
|
98
148
|
};
|
|
99
149
|
|
|
100
150
|
return (
|
|
101
151
|
<>
|
|
152
|
+
{statsLoading && <Loader />}
|
|
102
153
|
<StyledTableWrapper id="tableScrolling">
|
|
103
154
|
<StyledTable>
|
|
104
155
|
<thead>
|
|
105
156
|
<tr>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
157
|
+
{[
|
|
158
|
+
{ label: 'Trading Name', key: 'trading_as' },
|
|
159
|
+
{ label: 'Client', key: 'customer_name' },
|
|
160
|
+
{ label: 'Orders', key: 'orders' },
|
|
161
|
+
{ label: 'Products', key: 'return_order_products' },
|
|
162
|
+
{ label: 'RTS', key: 'RTS' },
|
|
163
|
+
{ label: 'Pending', key: 'PENDING' },
|
|
164
|
+
{ label: 'Dispose', key: 'DISPOSE' },
|
|
165
|
+
{ label: 'Re-allocate', key: 'RE-ALLOCATE' },
|
|
166
|
+
{ label: 'Re-Del', key: 'RE-DEL' },
|
|
167
|
+
{ label: 'Recycle', key: 'RECYCLE' },
|
|
168
|
+
{ label: 'Unknown', key: 'UNKNOWN' },
|
|
169
|
+
].map(({ label, key }) => (
|
|
170
|
+
<th key={key} onClick={() => handleSort(key)}>
|
|
171
|
+
<div style={{ display: 'flex', cursor: 'pointer' }}>
|
|
172
|
+
{label} <span>{renderSortIcon(key)}</span>
|
|
173
|
+
</div>
|
|
174
|
+
</th>
|
|
175
|
+
))}
|
|
117
176
|
</tr>
|
|
118
177
|
</thead>
|
|
119
178
|
<tbody>
|
|
@@ -123,7 +182,7 @@ const ReturnTable: React.FC = () => {
|
|
|
123
182
|
<Skeleton active />
|
|
124
183
|
</td>
|
|
125
184
|
</tr>
|
|
126
|
-
) :
|
|
185
|
+
) : sortedData?.length === 0 ? (
|
|
127
186
|
<tr>
|
|
128
187
|
<td colSpan={11}>
|
|
129
188
|
<EmptyDataContainer>
|
|
@@ -132,7 +191,7 @@ const ReturnTable: React.FC = () => {
|
|
|
132
191
|
</td>
|
|
133
192
|
</tr>
|
|
134
193
|
) : (
|
|
135
|
-
|
|
194
|
+
sortedData?.map((key: any, index: number) => {
|
|
136
195
|
return (
|
|
137
196
|
<tr key={index}>
|
|
138
197
|
<td>{key?.trading_as}</td>
|
|
@@ -78,38 +78,14 @@ const ModalManager = () => {
|
|
|
78
78
|
dispatch({ type: 'close' });
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
// useEffect(() => {
|
|
82
|
-
// console.log(error, 'error');
|
|
83
|
-
// //@ts-ignore
|
|
84
|
-
// if (!confirmLoading) {
|
|
85
|
-
// // if (error && error.errorStatus !== 200) {
|
|
86
|
-
// // console.log(error, 'errorINsodeofIFFFFFF');
|
|
87
|
-
// // notification.error({
|
|
88
|
-
// // message: error.errorStatus || 'Error',
|
|
89
|
-
// // description: error.errorMessage || 'Something went wrong',
|
|
90
|
-
// // });
|
|
91
|
-
// // setError(null);
|
|
92
|
-
// // }
|
|
93
|
-
|
|
94
|
-
// //@ts-ignore
|
|
95
|
-
// if (error === null && response && response?.code === 200) {
|
|
96
|
-
// notification.success({
|
|
97
|
-
// message: 'Success',
|
|
98
|
-
// // @ts-ignore
|
|
99
|
-
// description: `${response?.message}`,
|
|
100
|
-
// });
|
|
101
|
-
// dispatch({ type: 'close' });
|
|
102
|
-
// setSelectedReturnOrder([]);
|
|
103
|
-
// setCheck([]);
|
|
104
|
-
// setNewPayload([]);
|
|
105
|
-
// setSelectAll(false);
|
|
106
|
-
// }
|
|
107
|
-
// }
|
|
108
|
-
// }, [confirmLoading]); //forCheck
|
|
109
|
-
|
|
110
81
|
useEffect(() => {
|
|
111
82
|
// @ts-ignore
|
|
112
83
|
if (apiError && apiError?.code !== 200) {
|
|
84
|
+
notification.error({
|
|
85
|
+
message: 'Failure',
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
description: `${apiError?.message}`,
|
|
88
|
+
});
|
|
113
89
|
dispatch({ type: 'close' });
|
|
114
90
|
setSelectedReturnOrder([]);
|
|
115
91
|
setCheck([]);
|
|
@@ -117,11 +93,6 @@ const ModalManager = () => {
|
|
|
117
93
|
setGrouped([]);
|
|
118
94
|
setSelectAll(false);
|
|
119
95
|
setShouldPerformAction(false);
|
|
120
|
-
notification.error({
|
|
121
|
-
message: 'Failure',
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
description: `${apiError?.message}`,
|
|
124
|
-
});
|
|
125
96
|
setError(null);
|
|
126
97
|
// @ts-ignore
|
|
127
98
|
} else if (response?.code === 200) {
|