@bjsdistribution/dms-client-return 0.0.11 → 0.0.12
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/order-daily-overview/common/fakedata.d.ts +4 -0
- package/dist/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.d.ts +1 -1
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.d.ts → PrintDropDownReturn.d.ts} +2 -2
- package/dist/components/store.d.ts +6 -1
- package/dist/dms-client-return.cjs.development.js +279 -112
- 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 +280 -113
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/order-daily-overview/common/fakedata.tsx +4 -0
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +10 -1
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +15 -7
- package/src/components/order-daily-overview/index.tsx +1 -1
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +4 -8
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +12 -14
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +32 -33
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +74 -30
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +3 -0
- package/src/components/order-daily-overview/table-view/Pagination.tsx +15 -14
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/{PrintDropDown.tsx → PrintDropDownReturn.tsx} +4 -4
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +74 -36
- package/src/components/order-view/modalsPopup/ModalManager.tsx +47 -12
- package/src/components/store.ts +35 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.12",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"testEnvironment": "jest-environment-jsdom-sixteen"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@bjsdistribution/dms-component-library": "
|
|
62
|
+
"@bjsdistribution/dms-component-library": "0.1.3",
|
|
63
63
|
"@size-limit/preset-small-lib": "^11.0.1",
|
|
64
64
|
"@tippyjs/react": "^4.2.6",
|
|
65
65
|
"@types/react": "^18.2.47",
|
|
@@ -101,6 +101,10 @@ export const optionsPrint = [
|
|
|
101
101
|
{ icon: 'collectionLables', label: 'Print Collection Labels' },
|
|
102
102
|
];
|
|
103
103
|
|
|
104
|
+
export const optionsForReturnPrint = [
|
|
105
|
+
{ icon: 'deliveryLables', label: 'Print Return Labels' },
|
|
106
|
+
];
|
|
107
|
+
|
|
104
108
|
export const Depots = [
|
|
105
109
|
{ value: 'bjsCouriers', label: 'BJS COURIERS' },
|
|
106
110
|
{ value: 'bjsSales', label: 'BJS SALES' },
|
|
@@ -3,12 +3,18 @@ import { CoverPage } from './Styledfilters';
|
|
|
3
3
|
import SelectionFilter from './SelectionFilter';
|
|
4
4
|
import { ApiResponse } from '../../types';
|
|
5
5
|
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useActionType,
|
|
8
|
+
useCustomerData,
|
|
9
|
+
useLocationData,
|
|
10
|
+
useStatusOrderData,
|
|
11
|
+
} from '../../store';
|
|
7
12
|
|
|
8
13
|
function HeaderFilter() {
|
|
9
14
|
const [, setCustomers] = useCustomerData();
|
|
10
15
|
const [, setActionType] = useActionType();
|
|
11
16
|
const [, setLocationData] = useLocationData();
|
|
17
|
+
const [, setStatusOfOrders] = useStatusOrderData();
|
|
12
18
|
|
|
13
19
|
//API for client data
|
|
14
20
|
const { data: fetchedCustomerData, loading: loading } = useApiHook<
|
|
@@ -50,6 +56,9 @@ function HeaderFilter() {
|
|
|
50
56
|
(i: any) => i?.order_product_return_action
|
|
51
57
|
)
|
|
52
58
|
);
|
|
59
|
+
setStatusOfOrders(
|
|
60
|
+
fetchedStaticData?.data?.flatMap((i: any) => i?.order_stock_alias)
|
|
61
|
+
);
|
|
53
62
|
}
|
|
54
63
|
}, [actionLoading, fetchedStaticData]);
|
|
55
64
|
|
|
@@ -12,9 +12,12 @@ import { atom, useAtom } from 'jotai';
|
|
|
12
12
|
import {
|
|
13
13
|
useActionType,
|
|
14
14
|
useCustomerData,
|
|
15
|
+
useGroupedPayload,
|
|
15
16
|
useLocationData,
|
|
16
17
|
useNewReturnPayload,
|
|
17
18
|
useReturnPayload,
|
|
19
|
+
useSelectAll,
|
|
20
|
+
useSelectedOrders,
|
|
18
21
|
} from '../../store';
|
|
19
22
|
import { filtersReducerAtom } from './filterStore';
|
|
20
23
|
import {
|
|
@@ -49,6 +52,9 @@ function SelectionFilter() {
|
|
|
49
52
|
const [storedAccNumber, setStoredAccNumber] = useState<any>();
|
|
50
53
|
const [storedCustomerId, setStoredCustomerId] = useState<any>();
|
|
51
54
|
const [, setNewPayload] = useNewReturnPayload();
|
|
55
|
+
const [, setGrouped] = useGroupedPayload();
|
|
56
|
+
const [, setSelectedReturnOrder] = useSelectedOrders();
|
|
57
|
+
const [, setSelectAll] = useSelectAll();
|
|
52
58
|
|
|
53
59
|
//client options
|
|
54
60
|
const clientOptions = customers?.map((option: any) => ({
|
|
@@ -69,7 +75,7 @@ function SelectionFilter() {
|
|
|
69
75
|
|
|
70
76
|
const LocationOptions = locationData?.map((option: any) => ({
|
|
71
77
|
label: option?.location_name,
|
|
72
|
-
value: option?.
|
|
78
|
+
value: option?.token,
|
|
73
79
|
}));
|
|
74
80
|
|
|
75
81
|
//client change
|
|
@@ -94,7 +100,6 @@ function SelectionFilter() {
|
|
|
94
100
|
account_number: storedAccNo,
|
|
95
101
|
customer_id: storedCustomerId,
|
|
96
102
|
}));
|
|
97
|
-
console.log(selectedUuids, 'selectedUuids');
|
|
98
103
|
const filteredSubLocations = locationData
|
|
99
104
|
?.filter((subCat: any) => subCat?.customer_id === selectedUuids)
|
|
100
105
|
.map((subCat: any) => ({
|
|
@@ -104,6 +109,10 @@ function SelectionFilter() {
|
|
|
104
109
|
|
|
105
110
|
setFilteredLocationOptions(filteredSubLocations);
|
|
106
111
|
setUuid('');
|
|
112
|
+
setSelectedReturnOrder([]);
|
|
113
|
+
setNewPayload([]);
|
|
114
|
+
setGrouped([]);
|
|
115
|
+
setSelectAll(false);
|
|
107
116
|
};
|
|
108
117
|
|
|
109
118
|
useEffect(() => {
|
|
@@ -127,10 +136,9 @@ function SelectionFilter() {
|
|
|
127
136
|
useEffect(() => {}, [getUuid, filteredLocationOptions]);
|
|
128
137
|
|
|
129
138
|
//location change
|
|
130
|
-
const handleLocationChange = (value:
|
|
139
|
+
const handleLocationChange = (value: any, option: DefaultOptionType) => {
|
|
131
140
|
const selectedLabel = option?.label as string;
|
|
132
|
-
|
|
133
|
-
setSelectedLocationValue(selectedLabel);
|
|
141
|
+
setSelectedLocationValue(value);
|
|
134
142
|
|
|
135
143
|
if (selectedLocationValue === selectedLabel) {
|
|
136
144
|
dispatch({
|
|
@@ -196,9 +204,9 @@ function SelectionFilter() {
|
|
|
196
204
|
}
|
|
197
205
|
}, [storedName, selectedFilterValue, selectedLocationValue]);
|
|
198
206
|
|
|
199
|
-
console.log(filteredLocationOptions, 'filteredLocationOptions');
|
|
207
|
+
// console.log(filteredLocationOptions, 'filteredLocationOptions');
|
|
200
208
|
|
|
201
|
-
console.log('check', storedName, selectedFilterValue, selectedLocationValue);
|
|
209
|
+
// console.log('check', storedName, selectedFilterValue, selectedLocationValue);
|
|
202
210
|
return (
|
|
203
211
|
<Wrapper>
|
|
204
212
|
<FilterRow>
|
|
@@ -62,7 +62,7 @@ function ReturnMainTable() {
|
|
|
62
62
|
endpoint: `/return_orders/get/client-returns/`,
|
|
63
63
|
method: 'GET',
|
|
64
64
|
});
|
|
65
|
-
console.log('fetchedClientData', fetchedClientData?.data);
|
|
65
|
+
// console.log('fetchedClientData', fetchedClientData?.data);
|
|
66
66
|
|
|
67
67
|
useEffect(() => {
|
|
68
68
|
setLoading(staticDataLoading);
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AntSelect,
|
|
3
|
-
Checkbox,
|
|
4
|
-
displayValueOrNA,
|
|
5
|
-
} from '@bjsdistribution/dms-component-library';
|
|
1
|
+
import { AntSelect, Checkbox } from '@bjsdistribution/dms-component-library';
|
|
6
2
|
import { Empty } from 'antd';
|
|
7
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
8
4
|
import { Skeleton } from 'antd';
|
|
@@ -18,9 +14,9 @@ import {
|
|
|
18
14
|
} from '../../return-order-table/return-orders-filters/returnstyles';
|
|
19
15
|
import LoadIcon from '../../../../assets/icons/LoadIcon';
|
|
20
16
|
import { usePrintOptionTOggle } from '../../store/store';
|
|
21
|
-
import PrintDropDown from '../../../order-view/details-filters/left-side-filters/dropdowns/
|
|
17
|
+
import PrintDropDown from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
22
18
|
import { NavLink } from 'react-router-dom';
|
|
23
|
-
import { formatDate } from '../../shared/utlis';
|
|
19
|
+
import { displayValueOrNA, formatDate } from '../../shared/utlis';
|
|
24
20
|
|
|
25
21
|
const OrderTable = ({ loadingskeleton }: any) => {
|
|
26
22
|
const [selectedOrders, setSelectedReturnOrder] = useSelectedOrders();
|
|
@@ -207,7 +203,7 @@ const OrderTable = ({ loadingskeleton }: any) => {
|
|
|
207
203
|
<td>{displayValueOrNA(item?.order_number)}</td>
|
|
208
204
|
|
|
209
205
|
<td>{displayValueOrNA(item?.box_count)}</td>
|
|
210
|
-
<td>{displayValueOrNA(item?.weight)}KG</td>
|
|
206
|
+
<td>{displayValueOrNA(item?.weight)} KG</td>
|
|
211
207
|
<td>{displayValueOrNA(item?.cube)}</td>
|
|
212
208
|
<td>
|
|
213
209
|
<AntSelect
|
package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts
CHANGED
|
@@ -67,20 +67,18 @@ const filterReducer = (state: FilterState, action: any): FilterState => {
|
|
|
67
67
|
],
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// ],
|
|
83
|
-
// };
|
|
70
|
+
case 'SET_STATUS_ORDER_FILTER':
|
|
71
|
+
return {
|
|
72
|
+
...state,
|
|
73
|
+
'x-filters': [
|
|
74
|
+
...state['x-filters'].filter(f => f.field !== 'status_id'),
|
|
75
|
+
{
|
|
76
|
+
field: 'status_id',
|
|
77
|
+
op: '=',
|
|
78
|
+
value: action.payload,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
84
82
|
|
|
85
83
|
// case 'SET_LOCATION_FILTER':
|
|
86
84
|
// return {
|
package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx
CHANGED
|
@@ -10,17 +10,20 @@ import DateIcon from '../../../../assets/icons/DateIcon';
|
|
|
10
10
|
// import StatusIcon from '../../../../assets/icons/StatusIcon';
|
|
11
11
|
import ClientIcon from '../../../../assets/icons/ClientIcon';
|
|
12
12
|
// import AssigneIcon from '../../../../assets/icons/AssigneIcon';
|
|
13
|
-
import { DatePicker, Select
|
|
13
|
+
import { DatePicker, Select } from 'antd';
|
|
14
14
|
import { useAtom } from '../../../order-view/store';
|
|
15
15
|
import styled from 'styled-components';
|
|
16
16
|
import { filtersReducerAtom } from './ReturnFilterStore';
|
|
17
17
|
import dayjs from 'dayjs';
|
|
18
|
-
import { useCustomerData } from '../../../store';
|
|
18
|
+
import { useCustomerData, useStatusOrderData } from '../../../store';
|
|
19
|
+
import StatusIcon from '../../../../assets/icons/StatusIcon';
|
|
20
|
+
import AssigneIcon from '../../../../assets/icons/AssigneIcon';
|
|
19
21
|
|
|
20
22
|
const ReturnOrderFilter = () => {
|
|
21
23
|
const [, dispatch] = useAtom(filtersReducerAtom);
|
|
22
24
|
const [customers] = useCustomerData();
|
|
23
25
|
const [selectedDate, setSelectedDate] = useState();
|
|
26
|
+
const [statusOfOrder] = useStatusOrderData();
|
|
24
27
|
// const zoneOptions = [
|
|
25
28
|
// { label: 'Zone 1', value: 'zone1' },
|
|
26
29
|
// { label: 'Zone 2', value: 'zone2' },
|
|
@@ -52,6 +55,14 @@ const ReturnOrderFilter = () => {
|
|
|
52
55
|
value: option?.id,
|
|
53
56
|
}));
|
|
54
57
|
|
|
58
|
+
//status of order
|
|
59
|
+
const orderOptions = statusOfOrder?.map((option: any) => ({
|
|
60
|
+
label:
|
|
61
|
+
option?.status_type?.charAt(0)?.toUpperCase() +
|
|
62
|
+
option?.status_type?.slice(1),
|
|
63
|
+
value: option?.id,
|
|
64
|
+
}));
|
|
65
|
+
|
|
55
66
|
const handleClientChange = (value: any) => {
|
|
56
67
|
console.log(value, 'value');
|
|
57
68
|
dispatch({
|
|
@@ -60,6 +71,14 @@ const ReturnOrderFilter = () => {
|
|
|
60
71
|
});
|
|
61
72
|
};
|
|
62
73
|
|
|
74
|
+
const handleStatusOfOrder = (value: any) => {
|
|
75
|
+
console.log(value, 'value');
|
|
76
|
+
dispatch({
|
|
77
|
+
type: 'SET_STATUS_ORDER_FILTER',
|
|
78
|
+
payload: value,
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
63
82
|
return (
|
|
64
83
|
<>
|
|
65
84
|
<StyledFiter>
|
|
@@ -88,31 +107,21 @@ const ReturnOrderFilter = () => {
|
|
|
88
107
|
</StyledDatePicker>
|
|
89
108
|
</div>
|
|
90
109
|
|
|
91
|
-
|
|
110
|
+
<div className="datefilter">
|
|
92
111
|
<div className="dateiconcontainer">
|
|
93
112
|
<StatusIcon />
|
|
94
113
|
</div>
|
|
95
114
|
<StyledAntSelect>
|
|
96
115
|
<Select
|
|
97
|
-
options={
|
|
116
|
+
options={orderOptions}
|
|
98
117
|
className="custom-select"
|
|
99
118
|
placeholder="Status of Order"
|
|
100
|
-
onChange={
|
|
101
|
-
style={{ minWidth: '
|
|
102
|
-
|
|
103
|
-
maxTagPlaceholder={(omittedValues: any) => (
|
|
104
|
-
<Tooltip
|
|
105
|
-
overlayStyle={{ pointerEvents: 'none' }}
|
|
106
|
-
title={omittedValues
|
|
107
|
-
.map(({ label }: any) => label)
|
|
108
|
-
.join(', ')}
|
|
109
|
-
>
|
|
110
|
-
<span>{`${omittedValues.length} selected`}</span>
|
|
111
|
-
</Tooltip>
|
|
112
|
-
)}
|
|
119
|
+
onChange={handleStatusOfOrder}
|
|
120
|
+
style={{ minWidth: '130px' }}
|
|
121
|
+
allowClear
|
|
113
122
|
/>
|
|
114
123
|
</StyledAntSelect>
|
|
115
|
-
</div>
|
|
124
|
+
</div>
|
|
116
125
|
<div className="datefilter">
|
|
117
126
|
<div className="dateiconcontainer">
|
|
118
127
|
<ClientIcon />
|
|
@@ -124,25 +133,15 @@ const ReturnOrderFilter = () => {
|
|
|
124
133
|
placeholder="Client"
|
|
125
134
|
onChange={handleClientChange}
|
|
126
135
|
style={{ width: '125px', border: 'none' }}
|
|
127
|
-
|
|
128
|
-
maxTagPlaceholder={(omittedValues: any) => (
|
|
129
|
-
<Tooltip
|
|
130
|
-
overlayStyle={{ pointerEvents: 'none' }}
|
|
131
|
-
title={omittedValues
|
|
132
|
-
.map(({ label }: any) => label)
|
|
133
|
-
.join(', ')}
|
|
134
|
-
>
|
|
135
|
-
<span>{`${omittedValues.length} selected`}</span>
|
|
136
|
-
</Tooltip>
|
|
137
|
-
)}
|
|
136
|
+
allowClear
|
|
138
137
|
/>
|
|
139
138
|
</StyledAntSelect>
|
|
140
139
|
</div>
|
|
141
|
-
|
|
140
|
+
<div className="datefilter">
|
|
142
141
|
<div className="dateiconcontainer">
|
|
143
142
|
<AssigneIcon />
|
|
144
143
|
</div>
|
|
145
|
-
<StyledAntSelect>
|
|
144
|
+
{/* <StyledAntSelect>
|
|
146
145
|
<Select
|
|
147
146
|
options={zoneOptions}
|
|
148
147
|
className="custom-select"
|
|
@@ -161,8 +160,8 @@ const ReturnOrderFilter = () => {
|
|
|
161
160
|
</Tooltip>
|
|
162
161
|
)}
|
|
163
162
|
/>
|
|
164
|
-
</StyledAntSelect>
|
|
165
|
-
</div>
|
|
163
|
+
</StyledAntSelect> */}
|
|
164
|
+
</div>
|
|
166
165
|
</LeftSideConatiner>
|
|
167
166
|
</StyledFIlterELements>
|
|
168
167
|
<TableFilters />
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Checkbox, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
2
2
|
import { Empty } from 'antd';
|
|
3
3
|
import { useAtom } from 'jotai';
|
|
4
|
-
import React, { useEffect, useRef
|
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
|
5
5
|
import { Skeleton } from 'antd';
|
|
6
6
|
import {
|
|
7
7
|
useGroupedPayload,
|
|
8
|
+
useLocationData,
|
|
8
9
|
useNewReturnPayload,
|
|
9
10
|
useReturnPayload,
|
|
11
|
+
useSelectAll,
|
|
10
12
|
useSelectedOrders,
|
|
11
13
|
} from '../../../store';
|
|
12
14
|
import { useReturnData } from '../../../order-view/store';
|
|
@@ -17,22 +19,23 @@ import DownIcon from '../../../../assets/icons/DownIcon';
|
|
|
17
19
|
import { useLoading, usePrintOptionTOggle } from '../../store/store';
|
|
18
20
|
import { ApiResponse } from '../../../types';
|
|
19
21
|
import { filtersReducerAtom } from '../../header-filters/filterStore';
|
|
20
|
-
import PrintDropDown from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDown';
|
|
21
22
|
import { displayValueOrNA } from '../../shared/utlis';
|
|
22
|
-
|
|
23
|
+
import PrintDropDownReturn from '../../../order-view/details-filters/left-side-filters/dropdowns/PrintDropDownReturn';
|
|
24
|
+
const ReturnOrderTable = () => {
|
|
23
25
|
const [state] = useAtom(filtersReducerAtom);
|
|
24
26
|
|
|
25
27
|
const [selectedReturnOrder, setSelectedReturnOrder] = useSelectedOrders();
|
|
26
|
-
const [selectAll, setSelectAll] =
|
|
28
|
+
const [selectAll, setSelectAll] = useSelectAll();
|
|
27
29
|
const { 'x-filters': filters, 'x-pagination': pagination } = state;
|
|
28
30
|
const [returnData, setReturnData] = useReturnData();
|
|
29
|
-
const [, setLoading] = useLoading();
|
|
31
|
+
const [load, setLoading] = useLoading();
|
|
30
32
|
const dropdownRefParent = useRef<HTMLDivElement>(null);
|
|
31
33
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
32
34
|
const [printToogle, setPrintToggle] = usePrintOptionTOggle();
|
|
33
35
|
const [createReturn, setReturnPayload] = useReturnPayload();
|
|
34
36
|
const [newpayload, setNewPayload] = useNewReturnPayload();
|
|
35
37
|
const [, setGrouped] = useGroupedPayload();
|
|
38
|
+
const [locationData] = useLocationData();
|
|
36
39
|
|
|
37
40
|
const OpenDropDown = (index: number) => {
|
|
38
41
|
setPrintToggle(prevIndex => (prevIndex === index ? null : index));
|
|
@@ -54,7 +57,7 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
54
57
|
}
|
|
55
58
|
};
|
|
56
59
|
|
|
57
|
-
const { data: fetchedOrderData, loading:
|
|
60
|
+
const { data: fetchedOrderData, loading: returnDataLoad } = useApiHook<
|
|
58
61
|
ApiResponse
|
|
59
62
|
>({
|
|
60
63
|
endpoint: '/return_order_products/',
|
|
@@ -64,11 +67,31 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
64
67
|
});
|
|
65
68
|
|
|
66
69
|
useEffect(() => {
|
|
67
|
-
setLoading(
|
|
70
|
+
setLoading(returnDataLoad);
|
|
68
71
|
if (fetchedOrderData && fetchedOrderData?.data) {
|
|
69
72
|
setReturnData(fetchedOrderData?.data);
|
|
70
73
|
}
|
|
71
|
-
}, [fetchedOrderData,
|
|
74
|
+
}, [fetchedOrderData, returnDataLoad]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
setLoading(returnDataLoad);
|
|
78
|
+
|
|
79
|
+
if (fetchedOrderData && fetchedOrderData?.data && locationData) {
|
|
80
|
+
const updatedReturnData = fetchedOrderData.data.map(returnItem => {
|
|
81
|
+
const matchingLocation = locationData.find(
|
|
82
|
+
(location: any) => location?.token === returnItem?.return_location
|
|
83
|
+
);
|
|
84
|
+
return {
|
|
85
|
+
...returnItem,
|
|
86
|
+
new_location: matchingLocation
|
|
87
|
+
? matchingLocation.location_name
|
|
88
|
+
: null,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
setReturnData(updatedReturnData);
|
|
93
|
+
}
|
|
94
|
+
}, [fetchedOrderData, returnDataLoad, locationData]);
|
|
72
95
|
|
|
73
96
|
const handleSelectAll = (e: any) => {
|
|
74
97
|
setSelectAll(e.target.checked);
|
|
@@ -78,23 +101,27 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
78
101
|
id: loc.id,
|
|
79
102
|
return_locations: loc?.return_locations,
|
|
80
103
|
return_location: loc?.return_location,
|
|
81
|
-
products: loc
|
|
104
|
+
products: loc?.legacy_product_id,
|
|
82
105
|
order_product_return_action: loc?.order_product_return_action,
|
|
83
|
-
return_location_token: loc?.
|
|
106
|
+
return_location_token: loc?.return_location,
|
|
107
|
+
new_location: loc?.new_location,
|
|
84
108
|
}))
|
|
85
109
|
);
|
|
86
110
|
setNewPayload(
|
|
87
111
|
returnData?.map((loc: any) => ({
|
|
88
112
|
id: loc.id,
|
|
89
113
|
account_number: createReturn?.account_number,
|
|
90
|
-
customer_id: createReturn?.customer_id,
|
|
91
|
-
products: loc
|
|
92
|
-
return_action: loc?.order_product_return_action?.type || null,
|
|
93
|
-
return_location_token: loc?.
|
|
114
|
+
customer_id: +createReturn?.customer_id,
|
|
115
|
+
products: [loc?.legacy_product_id],
|
|
116
|
+
return_action: [loc?.order_product_return_action?.type] || null,
|
|
117
|
+
return_location_token: loc?.return_location || null,
|
|
118
|
+
new_location: loc?.new_location,
|
|
94
119
|
}))
|
|
95
120
|
);
|
|
96
121
|
} else {
|
|
97
122
|
setSelectedReturnOrder([]);
|
|
123
|
+
setNewPayload([]);
|
|
124
|
+
setGrouped([]);
|
|
98
125
|
}
|
|
99
126
|
};
|
|
100
127
|
|
|
@@ -102,13 +129,17 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
102
129
|
id: any,
|
|
103
130
|
return_location: any,
|
|
104
131
|
return_locations: any,
|
|
105
|
-
order_product_return_action: any
|
|
132
|
+
order_product_return_action: any,
|
|
133
|
+
new_location: any,
|
|
134
|
+
legacy_product_id: any
|
|
106
135
|
) => {
|
|
107
136
|
setSelectedReturnOrder((prevSelectedLocations: any) => {
|
|
108
137
|
const isSelected = prevSelectedLocations?.some(
|
|
109
138
|
(loc: any) => loc.id === id
|
|
110
139
|
);
|
|
111
140
|
|
|
141
|
+
console.log(new_location, 'new_location');
|
|
142
|
+
|
|
112
143
|
if (isSelected) {
|
|
113
144
|
const updatedSelectedLocations = prevSelectedLocations.filter(
|
|
114
145
|
(loc: any) => loc.id !== id
|
|
@@ -116,9 +147,10 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
116
147
|
|
|
117
148
|
setReturnPayload(prevState => ({
|
|
118
149
|
...prevState,
|
|
119
|
-
products:
|
|
150
|
+
products: legacy_product_id,
|
|
120
151
|
return_action: order_product_return_action?.type || null,
|
|
121
|
-
return_location_token:
|
|
152
|
+
return_location_token: return_location || null,
|
|
153
|
+
new_location: new_location,
|
|
122
154
|
}));
|
|
123
155
|
|
|
124
156
|
setNewPayload((prevPayload: any) =>
|
|
@@ -130,19 +162,20 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
130
162
|
const newReturnPayload = {
|
|
131
163
|
id,
|
|
132
164
|
account_number: createReturn?.account_number,
|
|
133
|
-
customer_id: createReturn?.customer_id,
|
|
134
|
-
products:
|
|
135
|
-
return_action: order_product_return_action?.type || null,
|
|
136
|
-
return_location_token:
|
|
165
|
+
customer_id: +createReturn?.customer_id,
|
|
166
|
+
products: [legacy_product_id],
|
|
167
|
+
return_action: [order_product_return_action?.type] || null,
|
|
168
|
+
return_location_token: return_location || null,
|
|
137
169
|
};
|
|
138
170
|
|
|
139
171
|
setNewPayload((prevPayload: any) => [...prevPayload, newReturnPayload]);
|
|
140
172
|
|
|
141
173
|
setReturnPayload(prevState => ({
|
|
142
174
|
...prevState,
|
|
143
|
-
products:
|
|
175
|
+
products: legacy_product_id,
|
|
144
176
|
return_action: order_product_return_action?.type || null,
|
|
145
|
-
return_location_token:
|
|
177
|
+
return_location_token: return_location || null,
|
|
178
|
+
new_location: new_location,
|
|
146
179
|
}));
|
|
147
180
|
|
|
148
181
|
return [
|
|
@@ -152,6 +185,7 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
152
185
|
return_location,
|
|
153
186
|
return_locations,
|
|
154
187
|
order_product_return_action,
|
|
188
|
+
new_location,
|
|
155
189
|
},
|
|
156
190
|
];
|
|
157
191
|
}
|
|
@@ -217,7 +251,7 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
217
251
|
</tr>
|
|
218
252
|
</thead>
|
|
219
253
|
<tbody>
|
|
220
|
-
{
|
|
254
|
+
{load ? (
|
|
221
255
|
<tr>
|
|
222
256
|
<td colSpan={6}>
|
|
223
257
|
<Skeleton active />
|
|
@@ -237,6 +271,7 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
237
271
|
<tr key={item.id}>
|
|
238
272
|
<td>
|
|
239
273
|
<Checkbox
|
|
274
|
+
className="custom-check"
|
|
240
275
|
checked={selectedReturnOrder?.some(
|
|
241
276
|
(selectedInvoice: any) =>
|
|
242
277
|
selectedInvoice?.id === item.id
|
|
@@ -246,19 +281,24 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
246
281
|
item.id,
|
|
247
282
|
item.return_location,
|
|
248
283
|
item.return_locations,
|
|
249
|
-
item.order_product_return_action
|
|
284
|
+
item.order_product_return_action,
|
|
285
|
+
item.new_location,
|
|
286
|
+
item.legacy_product_id
|
|
250
287
|
)
|
|
251
288
|
}
|
|
252
289
|
/>
|
|
253
290
|
</td>
|
|
254
291
|
|
|
255
292
|
<td>
|
|
256
|
-
{item?.orders_products_stock?.location
|
|
257
|
-
|
|
293
|
+
{item?.orders_products_stock?.location !== null &&
|
|
294
|
+
item?.orders_products_stock?.location !== undefined ? (
|
|
295
|
+
item.orders_products_stock.location
|
|
296
|
+
) : (
|
|
297
|
+
<div className="awaiting">Awaiting</div>
|
|
258
298
|
)}
|
|
259
299
|
</td>
|
|
260
300
|
|
|
261
|
-
<td> {displayValueOrNA(item?.
|
|
301
|
+
<td> {displayValueOrNA(item?.new_location)}</td>
|
|
262
302
|
|
|
263
303
|
<td>
|
|
264
304
|
<ul style={{ listStyleType: 'none', padding: 0 }}>
|
|
@@ -286,7 +326,11 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
286
326
|
<td>{displayValueOrNA(item?.weight)}KG</td>
|
|
287
327
|
<td>{displayValueOrNA(item?.cube)}</td>
|
|
288
328
|
<td>{displayValueOrNA(item?.return_reasons?.reason)}</td>
|
|
289
|
-
<td>
|
|
329
|
+
<td>
|
|
330
|
+
{displayValueOrNA(
|
|
331
|
+
item?.order_product_returns?.collected_at
|
|
332
|
+
)}
|
|
333
|
+
</td>
|
|
290
334
|
<td>{displayValueOrNA(item?.collection_reasons?.reason)}</td>
|
|
291
335
|
<td>
|
|
292
336
|
<ul className="actionbox">
|
|
@@ -302,7 +346,7 @@ const ReturnOrderTable = ({ loadingskeleton }: any) => {
|
|
|
302
346
|
<DownIcon />
|
|
303
347
|
{printToogle == index && (
|
|
304
348
|
<div ref={dropdownRef}>
|
|
305
|
-
<
|
|
349
|
+
<PrintDropDownReturn />
|
|
306
350
|
</div>
|
|
307
351
|
)}
|
|
308
352
|
</li>
|
|
@@ -2,16 +2,18 @@ import React from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
StyledContainer,
|
|
4
4
|
StyledContentWrapper,
|
|
5
|
+
// StyledDropdown,
|
|
5
6
|
StyledInfoBox,
|
|
6
7
|
StyledLabel,
|
|
7
8
|
StyledPaginationItem,
|
|
8
9
|
StyledPaginationWrapper,
|
|
10
|
+
// StyledDropdownData,
|
|
9
11
|
} from './PaginationStyle';
|
|
10
12
|
import PrevIcon from '../../../assets/icons/PrevIcon';
|
|
11
13
|
import NextIcon from '../../../assets/icons/NextIcon';
|
|
12
14
|
import { useAtom } from 'jotai';
|
|
13
|
-
import { filtersReducerAtom } from '../store/filterStore';
|
|
14
15
|
import { Select } from 'antd';
|
|
16
|
+
import { filtersReducerAtom } from '../return-after-table/table-filters/ReturnFilterStore';
|
|
15
17
|
|
|
16
18
|
const PAGE_SIZE_OPTIONS = [50, 100, 150];
|
|
17
19
|
const MAX_PAGES_TO_SHOW = 5;
|
|
@@ -46,18 +48,17 @@ const Pagination: React.FC<any> = ({
|
|
|
46
48
|
type: 'SET_PERPAGE',
|
|
47
49
|
payload: newItemsPerPage,
|
|
48
50
|
});
|
|
49
|
-
|
|
51
|
+
|
|
50
52
|
// Reset to the first page
|
|
51
53
|
dispatch({
|
|
52
54
|
type: 'SET_PAGE',
|
|
53
55
|
payload: 1,
|
|
54
56
|
});
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
onPageChange(1);
|
|
57
59
|
onItemsPerPageChange(newItemsPerPage);
|
|
58
60
|
};
|
|
59
61
|
|
|
60
|
-
|
|
61
62
|
const getPageNumbers = (
|
|
62
63
|
currentPage: number,
|
|
63
64
|
totalPages: number
|
|
@@ -96,16 +97,16 @@ const Pagination: React.FC<any> = ({
|
|
|
96
97
|
</StyledInfoBox>
|
|
97
98
|
<StyledLabel>Row on Page</StyledLabel>
|
|
98
99
|
<Select
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</Select>
|
|
100
|
+
value={itemsPerPage}
|
|
101
|
+
onChange={handleItemsPerPageChange}
|
|
102
|
+
style={{ width: 75 }}
|
|
103
|
+
>
|
|
104
|
+
{PAGE_SIZE_OPTIONS.map(option => (
|
|
105
|
+
<Select.Option key={option} value={option}>
|
|
106
|
+
{option}
|
|
107
|
+
</Select.Option>
|
|
108
|
+
))}
|
|
109
|
+
</Select>
|
|
109
110
|
<StyledPaginationWrapper>
|
|
110
111
|
<StyledPaginationItem
|
|
111
112
|
onClick={() => handlePageChange(currentPage - 1)}
|