@bjsdistribution/dms-client-return 0.0.2 → 0.0.4
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/README.md +1 -1
- package/dist/components/order-daily-overview/common/interface.d.ts +22 -0
- package/dist/components/order-daily-overview/header-filters/Styledfilters.d.ts +1 -2
- package/dist/components/order-daily-overview/header-filters/filterStore.d.ts +16 -0
- package/dist/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.d.ts +1 -0
- package/dist/components/order-daily-overview/shared/utlis.d.ts +2 -2
- package/dist/components/order-daily-overview/store/store.d.ts +4 -0
- package/dist/components/order-daily-overview/table/table-data/styles.d.ts +2 -0
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.d.ts +3 -1
- package/dist/components/order-view/generic-table/AuditLogs.d.ts +4 -0
- package/dist/components/order-view/hooks/useGetEventNotes.d.ts +2 -0
- package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +2 -0
- package/dist/components/order-view/modalsPopup/CreateReturnModal.d.ts +4 -0
- package/dist/components/order-view/notes/logs/fakeData.d.ts +7 -7
- package/dist/components/order-view/store.d.ts +23 -1
- package/dist/components/order-view/system-event-logs/columns/Code.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Date.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Event.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/Note.d.ts +3 -0
- package/dist/components/order-view/system-event-logs/columns/index.d.ts +4 -0
- package/dist/components/order-view/system-event-logs/helper.d.ts +7 -0
- package/dist/components/store.d.ts +5 -2
- package/dist/components/types.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +3553 -2396
- 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 +3557 -2400
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/common/expand-collapse/index.tsx +3 -3
- package/src/components/fakeData.ts +14 -23
- package/src/components/order-daily-overview/common/fakedata.tsx +5 -6
- package/src/components/order-daily-overview/common/interface.ts +120 -97
- package/src/components/order-daily-overview/filters/Filters.tsx +6 -13
- package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +56 -67
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +170 -224
- package/src/components/order-daily-overview/header-filters/Styledfilters.tsx +20 -7
- package/src/components/order-daily-overview/header-filters/filterStore.ts +145 -0
- package/src/components/order-daily-overview/index.tsx +77 -20
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +32 -4
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +184 -235
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +69 -10
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +10 -3
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +9 -47
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +106 -190
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +35 -38
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +69 -1
- package/src/components/order-daily-overview/store/store.ts +23 -12
- package/src/components/order-daily-overview/table/ReturnTable.tsx +133 -207
- package/src/components/order-daily-overview/table/table-data/styles.ts +15 -0
- package/src/components/order-view/details-filters/DetailsFilters.tsx +5 -4
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +0 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/PrintDropDown.tsx +54 -46
- package/src/components/order-view/general-information/Status.tsx +1 -1
- package/src/components/order-view/generic-table/AuditLogs.tsx +96 -0
- package/src/components/order-view/hooks/useGetEventNotes.tsx +47 -0
- package/src/components/order-view/hooks/useGetSystemLogs.tsx +60 -0
- package/src/components/order-view/index.tsx +25 -4
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +83 -0
- package/src/components/order-view/modalsPopup/ModalManager.tsx +49 -49
- package/src/components/order-view/modalsPopup/UnReceiveProduct.tsx +1 -1
- package/src/components/order-view/notes/AddNote.tsx +127 -13
- package/src/components/order-view/notes/index.tsx +100 -3
- package/src/components/order-view/notes/logs/fakeData.ts +8 -48
- package/src/components/order-view/notes/logs/index.tsx +6 -45
- package/src/components/order-view/order-actions/actions/escalation/EscalationModal.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/customer-section/RecipientName.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Address.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Latitude.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Longitude.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Postcode.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/What3words.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +3 -2
- package/src/components/order-view/order-details/expanded-content/index.tsx +1 -1
- package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +7 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/orders-section/Depot.tsx +14 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/Droptime.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/OrderNumber.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/RecipientReference.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +1 -0
- package/src/components/order-view/order-details/expanded-content/orders-section/VehicleType.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/DeliveryPoint.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/ServiceType.tsx +13 -1
- package/src/components/order-view/order-details/expanded-content/services-section/TimedService.tsx +14 -1
- package/src/components/order-view/order-resources/collapsed-content/index.tsx +1 -1
- package/src/components/order-view/products-info/expanded-content/index.tsx +2 -2
- package/src/components/order-view/products-info/index.tsx +3 -2
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +30 -34
- package/src/components/order-view/store.ts +80 -14
- package/src/components/order-view/system-event-logs/collapsed-content/index.tsx +1 -1
- package/src/components/order-view/system-event-logs/columns/Code.tsx +17 -0
- package/src/components/order-view/system-event-logs/columns/Date.tsx +18 -0
- package/src/components/order-view/system-event-logs/columns/Event.tsx +26 -0
- package/src/components/order-view/system-event-logs/columns/Note.tsx +24 -0
- package/src/components/order-view/system-event-logs/columns/index.tsx +6 -0
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +34 -6
- package/src/components/order-view/system-event-logs/helper.ts +29 -0
- package/src/components/store.ts +26 -4
- package/src/components/types.ts +2 -6
- package/src/index.tsx +32 -5
- package/dist/components/order-daily-overview/table/InfiniteScrolling.d.ts +0 -5
- package/dist/components/order-daily-overview/table/Return.d.ts +0 -3
- package/dist/components/order-daily-overview/table/table-data/MyTable.d.ts +0 -18
- package/dist/components/order-daily-overview/table/table-data/Table.d.ts +0 -18
- package/dist/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.d.ts +0 -3
- package/dist/components/order-view/system-event-logs/system-logs-table/SytemLogsStyles.d.ts +0 -3
- package/src/components/order-daily-overview/table/InfiniteScrolling.tsx +0 -54
- package/src/components/order-daily-overview/table/Return.tsx +0 -156
- package/src/components/order-daily-overview/table/table-data/MyTable.tsx +0 -433
- package/src/components/order-daily-overview/table/table-data/Table.tsx +0 -445
- package/src/components/order-view/system-event-logs/system-logs-table/SystemLogsTables.tsx +0 -59
- package/src/components/order-view/system-event-logs/system-logs-table/SytemLogsStyles.tsx +0 -239
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Skeleton } from 'antd';
|
|
4
|
+
import { formatDateTime } from '@bjsdistribution/dms-component-library';
|
|
5
|
+
import { usegetNotes, UseNotesLoading } from '../store';
|
|
6
|
+
import { NotesTableData } from '../notes/logs/fakeData';
|
|
7
|
+
|
|
8
|
+
const GenericAuditLogsTable = () => {
|
|
9
|
+
const tableHeadData = NotesTableData[0].tableHead; // Assuming NotesTableData contains table header information
|
|
10
|
+
const [getNotes] = usegetNotes();
|
|
11
|
+
const [isLoading] = UseNotesLoading();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<ScrollableTableWrapper>
|
|
15
|
+
<AuditTableWrapper>
|
|
16
|
+
<table>
|
|
17
|
+
<thead>
|
|
18
|
+
<tr>
|
|
19
|
+
{tableHeadData.map(column => (
|
|
20
|
+
<th key={column.key}>{column.label}</th>
|
|
21
|
+
))}
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody>
|
|
25
|
+
{isLoading ? (
|
|
26
|
+
<tr>
|
|
27
|
+
<td className="noBoder" colSpan={tableHeadData?.length}>
|
|
28
|
+
<Skeleton />
|
|
29
|
+
</td>
|
|
30
|
+
</tr>
|
|
31
|
+
) : getNotes && getNotes?.length > 0 ? (
|
|
32
|
+
getNotes?.map((note: any) => (
|
|
33
|
+
<tr key={note?.id}>
|
|
34
|
+
<td>
|
|
35
|
+
<div className="bold" title={note?.created_by}>
|
|
36
|
+
{note?.created_by}
|
|
37
|
+
</div>
|
|
38
|
+
<div>{formatDateTime(note?.created_at)}</div>
|
|
39
|
+
</td>
|
|
40
|
+
<td>{note?.description}</td>
|
|
41
|
+
</tr>
|
|
42
|
+
))
|
|
43
|
+
) : (
|
|
44
|
+
<tr>
|
|
45
|
+
<td colSpan={tableHeadData?.length}>No data found</td>
|
|
46
|
+
</tr>
|
|
47
|
+
)}
|
|
48
|
+
</tbody>
|
|
49
|
+
</table>
|
|
50
|
+
</AuditTableWrapper>
|
|
51
|
+
</ScrollableTableWrapper>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const ScrollableTableWrapper = styled.div``;
|
|
56
|
+
|
|
57
|
+
export const AuditTableWrapper = styled.div`
|
|
58
|
+
height: 250px;
|
|
59
|
+
min-height: 200px;
|
|
60
|
+
/* overflow: auto; */
|
|
61
|
+
|
|
62
|
+
table {
|
|
63
|
+
border-spacing: 0;
|
|
64
|
+
width: 100%;
|
|
65
|
+
text-align: left;
|
|
66
|
+
|
|
67
|
+
thead {
|
|
68
|
+
th {
|
|
69
|
+
border-bottom: 1px solid rgba(58, 54, 48, 0.25);
|
|
70
|
+
background: #faf9f9;
|
|
71
|
+
padding: 14px 12px;
|
|
72
|
+
color: #3a3630;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
font-weight: 600;
|
|
75
|
+
line-height: 24px;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
tbody {
|
|
79
|
+
td {
|
|
80
|
+
color: #667085;
|
|
81
|
+
font-family: Lato;
|
|
82
|
+
font-size: 13px;
|
|
83
|
+
font-style: normal;
|
|
84
|
+
font-weight: 400;
|
|
85
|
+
line-height: 16px;
|
|
86
|
+
padding: 10px;
|
|
87
|
+
.bold {
|
|
88
|
+
font-weight: 500;
|
|
89
|
+
font-size: 14px;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
export default GenericAuditLogsTable;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import { getCookie } from '../utils';
|
|
3
|
+
// import { useOrderDetails, useOrderProductSystemLogs } from '../store';
|
|
4
|
+
|
|
5
|
+
function useGetEventNotes() {
|
|
6
|
+
const ssoToken = getCookie('id_token');
|
|
7
|
+
|
|
8
|
+
const perform = async () => {
|
|
9
|
+
const endpoint = `${getBaseEndpoint()}/events/get/event_information/`;
|
|
10
|
+
// setLoading(true);
|
|
11
|
+
try {
|
|
12
|
+
const headers = {
|
|
13
|
+
accept: 'application/json',
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
Authorization: `Bearer ${ssoToken}`,
|
|
16
|
+
'x-pagination': JSON.stringify({
|
|
17
|
+
is_pagination: false,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
const response = await fetch(endpoint, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers,
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const json = await response.json();
|
|
26
|
+
const detail = json?.detail;
|
|
27
|
+
const msg = detail[0]?.msg;
|
|
28
|
+
console.error('Error response:', msg);
|
|
29
|
+
// setLoading(false);
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const json = await response.json();
|
|
33
|
+
if (json.code === 200) {
|
|
34
|
+
return json?.data;
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.error('Error fetching data:', err);
|
|
39
|
+
return [];
|
|
40
|
+
} finally {
|
|
41
|
+
// setLoading(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return perform;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default useGetEventNotes;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import { getCookie } from '../utils';
|
|
3
|
+
import { useOrderDetails, useOrderProductSystemLogs } from '../store';
|
|
4
|
+
|
|
5
|
+
function useSystemLogs() {
|
|
6
|
+
const ssoToken = getCookie('id_token');
|
|
7
|
+
const [orderDetails] = useOrderDetails();
|
|
8
|
+
const gsitId = orderDetails?.gsit_order_id;
|
|
9
|
+
const [, setSystemLogsEvents] = useOrderProductSystemLogs();
|
|
10
|
+
|
|
11
|
+
const perform = async () => {
|
|
12
|
+
const endpoint = `${getBaseEndpoint()}/events/get/event/`;
|
|
13
|
+
// setLoading(true);
|
|
14
|
+
try {
|
|
15
|
+
const headers = {
|
|
16
|
+
accept: 'application/json',
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
Authorization: `Bearer ${ssoToken}`,
|
|
19
|
+
'x-pagination': JSON.stringify({
|
|
20
|
+
page: 1,
|
|
21
|
+
per_page: 100,
|
|
22
|
+
}),
|
|
23
|
+
'x-filters': JSON.stringify([
|
|
24
|
+
{
|
|
25
|
+
field: 'object_id',
|
|
26
|
+
op: '=',
|
|
27
|
+
value: `${gsitId}`,
|
|
28
|
+
},
|
|
29
|
+
]),
|
|
30
|
+
};
|
|
31
|
+
const response = await fetch(endpoint, {
|
|
32
|
+
method: 'GET',
|
|
33
|
+
headers,
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const json = await response.json();
|
|
37
|
+
const detail = json?.detail;
|
|
38
|
+
const msg = detail[0]?.msg;
|
|
39
|
+
console.error('Error response:', msg);
|
|
40
|
+
// setLoading(false);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const json = await response.json();
|
|
44
|
+
if (json.code === 200) {
|
|
45
|
+
// setLoading(false);
|
|
46
|
+
setSystemLogsEvents(json.data);
|
|
47
|
+
return json.data;
|
|
48
|
+
}
|
|
49
|
+
return [];
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.error('Error fetching data:', err);
|
|
52
|
+
return [];
|
|
53
|
+
} finally {
|
|
54
|
+
// setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return perform;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default useSystemLogs;
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
useOrderId,
|
|
22
22
|
useDepotOptions,
|
|
23
23
|
usePrevOrderDetails,
|
|
24
|
+
useOrderProductSystemLogs,
|
|
24
25
|
} from './store';
|
|
25
26
|
// import Loader from '../order-daily-overview/header/loader/Loader';
|
|
26
27
|
import { useLoading } from '../order-daily-overview/store/store';
|
|
@@ -30,6 +31,7 @@ import RouterHeader from '../order-daily-overview/header/route-header/RouterHead
|
|
|
30
31
|
// import HeaderFilter from '../order-daily-overview/Header-filters/HeaderFilter';
|
|
31
32
|
// import Filters from '../order-daily-overview/filters/Filters';
|
|
32
33
|
import DetailsFilters from './details-filters/DetailsFilters';
|
|
34
|
+
import useSystemLogs from './hooks/useGetSystemLogs';
|
|
33
35
|
|
|
34
36
|
interface ApiResponse {
|
|
35
37
|
message: string;
|
|
@@ -49,7 +51,7 @@ function OrderView() {
|
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
// For API Call
|
|
52
|
-
const [, setOrderDetails] = useOrderDetails();
|
|
54
|
+
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
53
55
|
const [, setPrevOrderDetails] = usePrevOrderDetails();
|
|
54
56
|
const [, setLoading] = useLoading();
|
|
55
57
|
const [, setOrderStaticData] = useOrderStaticData();
|
|
@@ -153,6 +155,24 @@ function OrderView() {
|
|
|
153
155
|
}
|
|
154
156
|
}, [depotDataLoading]);
|
|
155
157
|
|
|
158
|
+
const gsitId = orderDetails?.gsit_order_id;
|
|
159
|
+
|
|
160
|
+
const systemLogsData = useSystemLogs();
|
|
161
|
+
const [, setSystemLogsEvents] = useOrderProductSystemLogs();
|
|
162
|
+
|
|
163
|
+
const fetchReminderData = async () => {
|
|
164
|
+
const result = await systemLogsData();
|
|
165
|
+
setSystemLogsEvents(result);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (gsitId) {
|
|
170
|
+
fetchReminderData();
|
|
171
|
+
|
|
172
|
+
console.log('Setting filters for gsitId:', gsitId);
|
|
173
|
+
}
|
|
174
|
+
}, [gsitId]);
|
|
175
|
+
|
|
156
176
|
return (
|
|
157
177
|
<>
|
|
158
178
|
<DashBoardWrapper>
|
|
@@ -206,15 +226,16 @@ const Section = styled.div`
|
|
|
206
226
|
border-radius: 12px;
|
|
207
227
|
box-shadow: 0px 4px 30px 0px rgba(46, 45, 116, 0.05);
|
|
208
228
|
border: 1px solid #e0e0e0;
|
|
229
|
+
padding: 12px;
|
|
209
230
|
`;
|
|
210
231
|
/* // `; */
|
|
211
232
|
const DashBoardWrapper = styled.section`
|
|
212
233
|
.Tableconatiner {
|
|
213
234
|
border-radius: 12px;
|
|
214
|
-
background: #fff;
|
|
215
|
-
box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1);
|
|
235
|
+
/* background: #fff; */
|
|
236
|
+
/* box-shadow: -2px 0px 12px 0px rgba(56, 71, 109, 0.1); */
|
|
216
237
|
display: block;
|
|
217
|
-
padding: 15px
|
|
238
|
+
padding: 15px 0px;
|
|
218
239
|
}
|
|
219
240
|
.headerWrap,
|
|
220
241
|
.tableData,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Alert, Checkbox } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { useLocationData } from '../../store';
|
|
5
|
+
|
|
6
|
+
const CreateReturnModal = () => {
|
|
7
|
+
const [, setSelectedLocations] = useState<any[]>();
|
|
8
|
+
const [locationData] = useLocationData();
|
|
9
|
+
|
|
10
|
+
const handleSelectLocations = (id: any) => {
|
|
11
|
+
setSelectedLocations((prevSelectedLocations: any) => {
|
|
12
|
+
const isSelected = prevSelectedLocations?.some(
|
|
13
|
+
(location: any) => location.id === id
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (isSelected) {
|
|
17
|
+
return prevSelectedLocations.filter(
|
|
18
|
+
(invoice: any) => invoice.id !== id
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
return [...prevSelectedLocations, { id, status_id: 3 }];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return (
|
|
26
|
+
<Wrapper>
|
|
27
|
+
<Alert
|
|
28
|
+
onClose={() => {}}
|
|
29
|
+
description=""
|
|
30
|
+
type="info"
|
|
31
|
+
title="Do you wish to proceed?"
|
|
32
|
+
showOkButton={false}
|
|
33
|
+
/>
|
|
34
|
+
<Container>
|
|
35
|
+
<ul style={{ listStyle: 'none', padding: 0 }}>
|
|
36
|
+
{locationData?.map((invoice: any) => (
|
|
37
|
+
<li
|
|
38
|
+
key={invoice.id}
|
|
39
|
+
style={{
|
|
40
|
+
marginBottom: '8px',
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<Checkbox
|
|
46
|
+
checked={true}
|
|
47
|
+
onChange={() => handleSelectLocations(invoice.id)}
|
|
48
|
+
/>
|
|
49
|
+
<StyledText style={{ marginLeft: '8px' }}>
|
|
50
|
+
{invoice.location_name}
|
|
51
|
+
</StyledText>
|
|
52
|
+
</li>
|
|
53
|
+
))}
|
|
54
|
+
</ul>
|
|
55
|
+
</Container>
|
|
56
|
+
</Wrapper>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const StyledText = styled.div`
|
|
61
|
+
color: #8d8f90;
|
|
62
|
+
font-family: Poppins;
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
const Container = styled.div``;
|
|
69
|
+
|
|
70
|
+
export const Wrapper = styled.div`
|
|
71
|
+
display: flex;
|
|
72
|
+
padding: 15px;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
align-items: flex-start;
|
|
76
|
+
gap: 15px;
|
|
77
|
+
align-self: stretch;
|
|
78
|
+
border-radius: 8px;
|
|
79
|
+
background: #f8fafc;
|
|
80
|
+
box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1);
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
export default CreateReturnModal;
|
|
@@ -14,24 +14,24 @@ import {
|
|
|
14
14
|
} from '../store';
|
|
15
15
|
|
|
16
16
|
import ProductAction from './ProductAction';
|
|
17
|
-
import
|
|
18
|
-
import DeleteProduct from './DeleteProduct';
|
|
17
|
+
// import DeleteProduct from './DeleteProduct';
|
|
19
18
|
import AddProduct from './AddProduct';
|
|
20
19
|
import logsTable from './qclogs/logsTable';
|
|
21
20
|
import DefectsModal from './DefectsModal';
|
|
22
21
|
import repackModal from './RepackModal';
|
|
23
|
-
import { ApiResponse
|
|
22
|
+
import { ApiResponse } from '../types';
|
|
23
|
+
import CreateReturnModal from './CreateReturnModal';
|
|
24
24
|
const ModalManager = () => {
|
|
25
25
|
const [popupName, dispatch] = useAtom(countReducerAtom);
|
|
26
|
-
const [,
|
|
26
|
+
const [,] = useProductDetails();
|
|
27
27
|
const [orderProduct, setOrderProduct] = useCreateOrderProducts();
|
|
28
28
|
const [orderId] = useOrderId();
|
|
29
|
-
const [selectedRows
|
|
29
|
+
const [selectedRows] = useDeleteProdsID();
|
|
30
30
|
const [unRecieve, setUnRecieve] = useRecieveOrderProducts();
|
|
31
31
|
const [updateOrderProduct, setUpdateOrderProduct] = useUpdateOrderProducts();
|
|
32
32
|
const [selectedProductId] = useAtom(selectedProductIdAtom);
|
|
33
33
|
const [selectedTab] = useAtom(selectedTabKeyAtom);
|
|
34
|
-
const [
|
|
34
|
+
const [, setIsFormValid] = useState(false);
|
|
35
35
|
|
|
36
36
|
console.log(orderProduct, 'abcabcabcabcabcabcabcabcabcabcabc');
|
|
37
37
|
|
|
@@ -48,45 +48,45 @@ const ModalManager = () => {
|
|
|
48
48
|
setIsFormValid(validateForm());
|
|
49
49
|
}, [selectedRows]);
|
|
50
50
|
|
|
51
|
-
const payloads: DeleteProds[] = selectedRows?.map(row => ({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}));
|
|
51
|
+
// const payloads: DeleteProds[] = selectedRows?.map(row => ({
|
|
52
|
+
// id: row.id,
|
|
53
|
+
// order_id: row.order_id,
|
|
54
|
+
// }));
|
|
55
55
|
|
|
56
|
-
const { data: isresponse, setShouldPerformAction: setaction } = useApiHook<{
|
|
57
|
-
|
|
58
|
-
}>({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
56
|
+
// const { data: isresponse, setShouldPerformAction: setaction } = useApiHook<{
|
|
57
|
+
// data: ApiResponse[];
|
|
58
|
+
// }>({
|
|
59
|
+
// endpoint: `order/order_products/delete/`,
|
|
60
|
+
// method: 'DELETE',
|
|
61
|
+
// body: payloads,
|
|
62
|
+
// performAction: false,
|
|
63
|
+
// });
|
|
64
64
|
|
|
65
65
|
// Effect to handle API response
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, [isresponse]);
|
|
72
|
-
const onDeleteProducts = () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
66
|
+
// useEffect(() => {
|
|
67
|
+
// if (isresponse && isresponse?.data) {
|
|
68
|
+
// handleRemoveRow();
|
|
69
|
+
// dispatch({ type: 'close' });
|
|
70
|
+
// }
|
|
71
|
+
// }, [isresponse]);
|
|
72
|
+
// const onDeleteProducts = () => {
|
|
73
|
+
// if (isFormValid) {
|
|
74
|
+
// setaction(true);
|
|
75
|
+
// } else {
|
|
76
|
+
// console.log('Please fill in all required fields before proceeding.');
|
|
77
|
+
// }
|
|
78
|
+
// };
|
|
79
79
|
|
|
80
|
-
const handleRemoveRow = () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
80
|
+
// const handleRemoveRow = () => {
|
|
81
|
+
// if (selectedRows.length > 0) {
|
|
82
|
+
// setProductData((prevProductData: any) =>
|
|
83
|
+
// prevProductData.filter(
|
|
84
|
+
// (item: any) => !selectedRows.some(row => row.id === item.id)
|
|
85
|
+
// )
|
|
86
|
+
// );
|
|
87
|
+
// setSelectedRows([]);
|
|
88
|
+
// }
|
|
89
|
+
// };
|
|
90
90
|
|
|
91
91
|
// API block for creating product order
|
|
92
92
|
const {
|
|
@@ -226,13 +226,13 @@ const ModalManager = () => {
|
|
|
226
226
|
|
|
227
227
|
return (
|
|
228
228
|
<>
|
|
229
|
-
{popupName?.state == '
|
|
229
|
+
{popupName?.state == 'create-return' && (
|
|
230
230
|
<AntModal
|
|
231
|
-
openStatus={popupName?.state == '
|
|
231
|
+
openStatus={popupName?.state == 'create-return' ? true : false}
|
|
232
232
|
closeModal={() => closeModal()}
|
|
233
233
|
PopupHeader={{
|
|
234
|
-
heading: '
|
|
235
|
-
subHeading: '
|
|
234
|
+
heading: 'CONFIRM RETURN',
|
|
235
|
+
subHeading: '',
|
|
236
236
|
}}
|
|
237
237
|
PopupFooter={{
|
|
238
238
|
btns: [
|
|
@@ -245,13 +245,13 @@ const ModalManager = () => {
|
|
|
245
245
|
|
|
246
246
|
btnAlign: 'justifyEnd',
|
|
247
247
|
}}
|
|
248
|
-
BodyComponent={
|
|
249
|
-
width={
|
|
248
|
+
BodyComponent={CreateReturnModal}
|
|
249
|
+
width={800}
|
|
250
250
|
classNameAdd={'globalPopup'}
|
|
251
251
|
/>
|
|
252
252
|
)}
|
|
253
253
|
|
|
254
|
-
{popupName?.state === 'deleteProduct' && (
|
|
254
|
+
{/* {popupName?.state === 'deleteProduct' && (
|
|
255
255
|
<AntModal
|
|
256
256
|
openStatus={popupName?.state === 'deleteProduct'}
|
|
257
257
|
closeModal={closeModal}
|
|
@@ -275,7 +275,7 @@ const ModalManager = () => {
|
|
|
275
275
|
width={1104}
|
|
276
276
|
classNameAdd={'globalPopup'}
|
|
277
277
|
/>
|
|
278
|
-
)}
|
|
278
|
+
)} */}
|
|
279
279
|
|
|
280
280
|
{popupName?.state === 'addProduct' && (
|
|
281
281
|
<AntModal
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AntSelect, Label } from '@bjsdistribution/dms-component-library';
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import Notes from '
|
|
4
|
+
import Notes from '../order-actions/actions/log-service-refusal/Notes';
|
|
5
5
|
import {
|
|
6
6
|
useOrderStaticData,
|
|
7
7
|
useProductDetails,
|
|
@@ -1,27 +1,130 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button,
|
|
3
3
|
Label,
|
|
4
|
-
|
|
4
|
+
// SelectDropdown,
|
|
5
5
|
} from '@bjsdistribution/dms-component-library';
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
+
// import NoteType from './NoteType';
|
|
9
|
+
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
10
|
+
import { getCookie } from '../utils';
|
|
11
|
+
import { useLocation } from 'react-router-dom';
|
|
12
|
+
import {
|
|
13
|
+
useCallAPi,
|
|
14
|
+
usemoduleIds,
|
|
15
|
+
UseNotesLoading,
|
|
16
|
+
useOrderId,
|
|
17
|
+
} from '../store';
|
|
18
|
+
import { notification } from 'antd';
|
|
8
19
|
|
|
9
20
|
function AddNote() {
|
|
10
|
-
const
|
|
11
|
-
|
|
21
|
+
const [, setNoteLoadingStore] = UseNotesLoading();
|
|
22
|
+
const [noteText, setNoteText] = useState('');
|
|
23
|
+
const [orderId] = useOrderId();
|
|
24
|
+
|
|
25
|
+
const location = useLocation();
|
|
26
|
+
const pathname = location.pathname;
|
|
27
|
+
const orderIdLocaation = pathname.split('/')[1];
|
|
28
|
+
|
|
29
|
+
// const [note, setNote] = useState('');
|
|
30
|
+
const [, CallAPi] = useCallAPi();
|
|
31
|
+
const ssoToken = getCookie('id_token');
|
|
32
|
+
|
|
33
|
+
const [moduleIds] = usemoduleIds();
|
|
34
|
+
|
|
35
|
+
// Save New Note
|
|
36
|
+
|
|
37
|
+
const [notificationData, setNotificationData] = useState<{
|
|
38
|
+
type: 'success' | 'error';
|
|
39
|
+
message: string;
|
|
40
|
+
description: string;
|
|
41
|
+
} | null>(null);
|
|
42
|
+
|
|
43
|
+
const saveNote = async () => {
|
|
44
|
+
setNoteLoadingStore(true);
|
|
45
|
+
CallAPi(false);
|
|
46
|
+
|
|
47
|
+
if (!noteText) return;
|
|
48
|
+
const endpoint = `${getBaseEndpoint()}/audit_logs/orders/`;
|
|
49
|
+
const payload = {
|
|
50
|
+
audit_logs: [
|
|
51
|
+
{
|
|
52
|
+
parent_object_id: orderId || orderIdLocaation,
|
|
53
|
+
parent_module_id: moduleIds?.parentId,
|
|
54
|
+
module_id: moduleIds?.id,
|
|
55
|
+
module_object_id: orderId || orderIdLocaation,
|
|
56
|
+
action: 'create',
|
|
57
|
+
description: noteText,
|
|
58
|
+
data_dump: '{}',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const response = await fetch(endpoint, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
Authorization: `Bearer ${ssoToken}`,
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(payload),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// setNoteLoadingStore(false);
|
|
74
|
+
|
|
75
|
+
const { message, error }: any = response;
|
|
76
|
+
if (response) {
|
|
77
|
+
setNotificationData({
|
|
78
|
+
type: 'success',
|
|
79
|
+
message: 'Success',
|
|
80
|
+
description: message || 'Successfully Created Note.',
|
|
81
|
+
});
|
|
82
|
+
setNoteLoadingStore(true);
|
|
83
|
+
setNoteText('');
|
|
84
|
+
setNoteLoadingStore(false);
|
|
85
|
+
CallAPi(true);
|
|
86
|
+
} else if (error) {
|
|
87
|
+
// Error: Set error notification
|
|
88
|
+
setNotificationData({
|
|
89
|
+
type: 'error',
|
|
90
|
+
message: 'Error',
|
|
91
|
+
description: error || 'Something went wrong. Please try again.',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Error saving note:', error);
|
|
96
|
+
alert('Failed to save note');
|
|
97
|
+
}
|
|
12
98
|
};
|
|
13
99
|
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (notificationData) {
|
|
102
|
+
const { type, message, description } = notificationData;
|
|
103
|
+
notification[type]({
|
|
104
|
+
message,
|
|
105
|
+
description,
|
|
106
|
+
duration: 5,
|
|
107
|
+
});
|
|
108
|
+
setNotificationData(null); // Clear notification data after showing
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Set top position for notifications
|
|
112
|
+
notification.config({
|
|
113
|
+
top: 80,
|
|
114
|
+
});
|
|
115
|
+
}, [notificationData]);
|
|
116
|
+
|
|
14
117
|
return (
|
|
15
118
|
<Container>
|
|
16
119
|
<Label label="Add New Note" />
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
120
|
+
<StyledTextArea
|
|
121
|
+
name="description"
|
|
122
|
+
placeholder="Enter your note here..."
|
|
123
|
+
value={noteText}
|
|
124
|
+
onChange={(e: any) => setNoteText(e.target.value)}
|
|
125
|
+
/>
|
|
23
126
|
<SaveNoteContainer>
|
|
24
|
-
<Button
|
|
127
|
+
<Button disabled={!noteText} onClick={saveNote}>
|
|
25
128
|
SAVE NOTE
|
|
26
129
|
</Button>
|
|
27
130
|
</SaveNoteContainer>
|
|
@@ -39,10 +142,21 @@ const Container = styled.div`
|
|
|
39
142
|
const SaveNoteContainer = styled.div`
|
|
40
143
|
display: inline-flex;
|
|
41
144
|
gap: 10px;
|
|
145
|
+
.disabled button {
|
|
146
|
+
opacity: 0.5;
|
|
147
|
+
cursor: default;
|
|
148
|
+
}
|
|
42
149
|
`;
|
|
43
150
|
|
|
44
|
-
const
|
|
45
|
-
|
|
151
|
+
const StyledTextArea = styled.textarea`
|
|
152
|
+
height: 57px;
|
|
153
|
+
border-radius: 12px;
|
|
154
|
+
background: #fff;
|
|
155
|
+
resize: none;
|
|
156
|
+
border-radius: 8px;
|
|
157
|
+
border: 1px solid var(--Neutral-Gray-Gray-100, #e0e2e7);
|
|
158
|
+
background: var(--Flowkit-White, #fff);
|
|
159
|
+
padding: 8px 12px;
|
|
46
160
|
`;
|
|
47
161
|
|
|
48
162
|
// const StyledSelectDropdown = styled(SelectDropdown)`
|