@bjsdistribution/dms-client-return 0.0.81 → 0.0.83
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-view/DynamicTable.d.ts +4 -1
- package/dist/components/order-view/notification/ReminderTemplate.d.ts +1 -1
- package/dist/components/order-view/notification/Tabs.d.ts +1 -1
- package/dist/components/order-view/order-actions/Dropdown.d.ts +1 -0
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +3 -0
- package/dist/components/store.d.ts +2 -1
- package/dist/dms-client-return.cjs.development.js +948 -400
- 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 +983 -435
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +1 -1
- package/src/components/order-view/DynamicTable.tsx +115 -90
- package/src/components/order-view/fakedata.ts +4 -2
- package/src/components/order-view/generic-table/AuditLogs.tsx +23 -81
- package/src/components/order-view/index.tsx +9 -7
- package/src/components/order-view/notes/NoteType.tsx +12 -1
- package/src/components/order-view/notes/index.tsx +46 -33
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +17 -4
- package/src/components/order-view/notification/ReminderTemplate.tsx +10 -11
- package/src/components/order-view/notification/Tabs.tsx +26 -6
- package/src/components/order-view/notification/index.tsx +47 -13
- package/src/components/order-view/order-actions/Dropdown.tsx +10 -1
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +21 -2
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +51 -48
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +3 -0
- package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +28 -19
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +24 -2
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +166 -0
- package/src/components/order-view/order-actions/index.tsx +3 -2
- package/src/components/order-view/order-actions/store.ts +1 -2
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +9 -6
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +16 -4
- package/src/components/order-view/view-reminder/reminder-styles.tsx +1 -0
- package/src/components/store.ts +7 -1
package/package.json
CHANGED
|
@@ -7,16 +7,18 @@ import {
|
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import CustomScrollBar from '../../common/scrollbar';
|
|
10
|
-
|
|
10
|
+
import { atom, useAtom } from 'jotai';
|
|
11
|
+
export const selectedID = atom<any>([]);
|
|
11
12
|
|
|
12
13
|
interface DynamicTableProps {
|
|
13
14
|
columns: any;
|
|
14
15
|
data: any[];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
function DynamicTable({ columns, data }: DynamicTableProps) {
|
|
18
|
+
function DynamicTable({ columns, data }: DynamicTableProps, props: any) {
|
|
18
19
|
const tableColumns = useMemo(() => columns, [columns]);
|
|
19
20
|
const tableData = useMemo(() => data, [data]);
|
|
21
|
+
|
|
20
22
|
const table = useReactTable({
|
|
21
23
|
columns: tableColumns,
|
|
22
24
|
data: tableData,
|
|
@@ -26,6 +28,9 @@ function DynamicTable({ columns, data }: DynamicTableProps) {
|
|
|
26
28
|
|
|
27
29
|
const rows = table.getRowModel().rows;
|
|
28
30
|
const headerGroups = table.getHeaderGroups();
|
|
31
|
+
const action = props;
|
|
32
|
+
const [selectedRows] = useAtom(selectedID);
|
|
33
|
+
|
|
29
34
|
const smallColumns = [
|
|
30
35
|
'types',
|
|
31
36
|
'sources',
|
|
@@ -33,11 +38,11 @@ function DynamicTable({ columns, data }: DynamicTableProps) {
|
|
|
33
38
|
'code',
|
|
34
39
|
'type',
|
|
35
40
|
'route',
|
|
36
|
-
'category',
|
|
37
41
|
'action',
|
|
38
42
|
];
|
|
39
|
-
const mediumColumns = ['date'];
|
|
40
|
-
const largeColumns = ['
|
|
43
|
+
const mediumColumns = ['date', 'reference', 'note', 'category'];
|
|
44
|
+
const largeColumns = ['details', 'datetime'];
|
|
45
|
+
const noFlexColumns = ['id'];
|
|
41
46
|
|
|
42
47
|
return (
|
|
43
48
|
<MainContainer>
|
|
@@ -46,79 +51,76 @@ function DynamicTable({ columns, data }: DynamicTableProps) {
|
|
|
46
51
|
<CustomScrollBar>
|
|
47
52
|
<Table>
|
|
48
53
|
<TableHead>
|
|
49
|
-
{headerGroups
|
|
54
|
+
{headerGroups?.map(headerGroup => (
|
|
50
55
|
<TableRow key={headerGroup.id}>
|
|
51
|
-
{headerGroup.headers.map(header =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{header.column.getCanSort() ? (
|
|
73
|
-
header.column.getIsSorted() === false ? (
|
|
74
|
-
<ChevronUpIcon />
|
|
75
|
-
) : header.column.getIsSorted() === 'asc' ? (
|
|
76
|
-
<ChevronUpIcon />
|
|
77
|
-
) : (
|
|
78
|
-
<ChevronDownIcon
|
|
79
|
-
style={{ cursor: 'pointer' }}
|
|
80
|
-
/>
|
|
81
|
-
)
|
|
82
|
-
) : (
|
|
83
|
-
''
|
|
84
|
-
)}
|
|
85
|
-
</span> */}
|
|
86
|
-
</TableHeadData>
|
|
87
|
-
);
|
|
88
|
-
})}
|
|
56
|
+
{headerGroup.headers.map(header => (
|
|
57
|
+
<TableHeadData
|
|
58
|
+
className={`col
|
|
59
|
+
${
|
|
60
|
+
smallColumns.includes(header?.id)
|
|
61
|
+
? 'sm'
|
|
62
|
+
: mediumColumns.includes(header?.id)
|
|
63
|
+
? 'md'
|
|
64
|
+
: largeColumns.includes(header?.id)
|
|
65
|
+
? 'lg'
|
|
66
|
+
: ''
|
|
67
|
+
}`}
|
|
68
|
+
key={header.id}
|
|
69
|
+
onClick={header.column.getToggleSortingHandler()}
|
|
70
|
+
>
|
|
71
|
+
{flexRender(
|
|
72
|
+
header.column.columnDef.header,
|
|
73
|
+
header.getContext()
|
|
74
|
+
)}
|
|
75
|
+
</TableHeadData>
|
|
76
|
+
))}
|
|
89
77
|
</TableRow>
|
|
90
78
|
))}
|
|
91
79
|
</TableHead>
|
|
92
80
|
<TableBody>
|
|
93
|
-
{rows
|
|
94
|
-
rows
|
|
95
|
-
<TableRow
|
|
96
|
-
{row.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
81
|
+
{rows?.length > 0 ? (
|
|
82
|
+
rows?.map(row => (
|
|
83
|
+
<TableRow
|
|
84
|
+
key={row.id}
|
|
85
|
+
className={`${
|
|
86
|
+
selectedRows?.length > 0 &&
|
|
87
|
+
selectedRows?.filter(
|
|
88
|
+
(f: any) => f?.id === (row?.original as any)?.id
|
|
89
|
+
)?.length
|
|
90
|
+
? 'isSelectedRow'
|
|
91
|
+
: ''
|
|
92
|
+
}`}
|
|
93
|
+
>
|
|
94
|
+
{row.getVisibleCells().map(cell => (
|
|
95
|
+
<TableData
|
|
96
|
+
className={`col
|
|
97
|
+
${
|
|
98
|
+
noFlexColumns.includes(cell?.column.id)
|
|
99
|
+
? 'noFlex'
|
|
100
|
+
: smallColumns.includes(cell?.column.id)
|
|
101
|
+
? 'sm'
|
|
102
|
+
: mediumColumns.includes(cell?.column.id)
|
|
103
|
+
? 'md'
|
|
104
|
+
: largeColumns.includes(cell?.column.id)
|
|
105
|
+
? 'lg'
|
|
106
|
+
: ''
|
|
107
|
+
} ${cell?.column.id}`}
|
|
108
|
+
key={cell.id}
|
|
109
|
+
>
|
|
110
|
+
{flexRender(cell.column.columnDef.cell, {
|
|
111
|
+
...cell.getContext(),
|
|
112
|
+
action,
|
|
113
|
+
})}
|
|
114
|
+
</TableData>
|
|
115
|
+
))}
|
|
118
116
|
</TableRow>
|
|
119
117
|
))
|
|
120
118
|
) : (
|
|
121
|
-
|
|
119
|
+
<TableRow>
|
|
120
|
+
<TableData colSpan={columns.length}>
|
|
121
|
+
No entries found.
|
|
122
|
+
</TableData>
|
|
123
|
+
</TableRow>
|
|
122
124
|
)}
|
|
123
125
|
</TableBody>
|
|
124
126
|
</Table>
|
|
@@ -129,11 +131,6 @@ function DynamicTable({ columns, data }: DynamicTableProps) {
|
|
|
129
131
|
);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
// const ChevronUpIcon = styled(ChevronDownIcon)`
|
|
133
|
-
// transform: rotate(180deg);
|
|
134
|
-
// cursor: pointer;
|
|
135
|
-
// `;
|
|
136
|
-
|
|
137
134
|
const Container = styled.div`
|
|
138
135
|
height: 30vh;
|
|
139
136
|
pointer-events: initial;
|
|
@@ -151,7 +148,7 @@ const TableWrapper = styled.div`
|
|
|
151
148
|
`;
|
|
152
149
|
|
|
153
150
|
const TableHeadData = styled.th`
|
|
154
|
-
padding:
|
|
151
|
+
padding: 10px 5px;
|
|
155
152
|
font-family: 'Roboto', sans-serif;
|
|
156
153
|
font-size: 14px;
|
|
157
154
|
font-weight: 500;
|
|
@@ -161,7 +158,7 @@ const TableHeadData = styled.th`
|
|
|
161
158
|
|
|
162
159
|
const TableData = styled.td`
|
|
163
160
|
border-spacing: 0px;
|
|
164
|
-
padding:
|
|
161
|
+
padding: 10px 5px;
|
|
165
162
|
font-family: 'Lato', sans-serif;
|
|
166
163
|
font-size: 13px;
|
|
167
164
|
font-weight: 400;
|
|
@@ -201,29 +198,57 @@ const Table = styled.table`
|
|
|
201
198
|
`;
|
|
202
199
|
|
|
203
200
|
const MainContainer = styled.div`
|
|
204
|
-
// width: 40%;
|
|
205
201
|
.col {
|
|
206
|
-
flex: 2;
|
|
207
|
-
// padding: 0 0 0 10px;
|
|
208
|
-
word-break: break-all;
|
|
209
202
|
display: flex;
|
|
210
|
-
color: #3a3630;
|
|
211
203
|
align-items: center;
|
|
212
|
-
|
|
204
|
+
color: #3a3630;
|
|
205
|
+
padding: 10px 5px;
|
|
206
|
+
text-align: left;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.col.noFlex {
|
|
210
|
+
flex: 0;
|
|
213
211
|
}
|
|
214
212
|
|
|
215
213
|
.col.sm {
|
|
216
|
-
flex: 1
|
|
217
|
-
|
|
214
|
+
flex: 1;
|
|
215
|
+
min-width: 100px;
|
|
218
216
|
}
|
|
217
|
+
|
|
219
218
|
.col.md {
|
|
220
|
-
flex: 2
|
|
221
|
-
|
|
219
|
+
flex: 2;
|
|
220
|
+
justify-content: flex-start;
|
|
221
|
+
min-width: 85px;
|
|
222
222
|
}
|
|
223
|
+
|
|
223
224
|
.col.lg {
|
|
224
|
-
flex:
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
flex: 4;
|
|
226
|
+
justify-content: flex-start;
|
|
227
|
+
min-width: 180px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.col.date {
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.col.amount,
|
|
234
|
+
.col.price {
|
|
235
|
+
justify-content: flex-end;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.TableHeadData,
|
|
239
|
+
.TableData {
|
|
240
|
+
padding: 10px 5px;
|
|
241
|
+
text-align: left;
|
|
242
|
+
white-space: nowrap;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.TableRow {
|
|
246
|
+
display: flex;
|
|
247
|
+
width: 100%;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.Table {
|
|
251
|
+
width: 100%;
|
|
227
252
|
}
|
|
228
253
|
`;
|
|
229
254
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ChargeLogData } from './types';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export const bjsMenu = [
|
|
5
4
|
// {
|
|
6
5
|
// label: 'Add Order Resources',
|
|
@@ -17,7 +16,10 @@ export const optionsMenu = [
|
|
|
17
16
|
{ label: 'Confirm', value: 'confirm-order' },
|
|
18
17
|
{ label: 'Hold', value: 'hold-order' },
|
|
19
18
|
{ label: 'Cancel', value: 'cancel-order' },
|
|
20
|
-
{label:
|
|
19
|
+
{ label: 'Un Hold', value: 'unhold-order' },
|
|
20
|
+
{
|
|
21
|
+
label: 'Un-Cancel',
|
|
22
|
+
value: 'uncancel-order',
|
|
21
23
|
},
|
|
22
24
|
// { label: 'Charge Log', value: 'charge-log' },
|
|
23
25
|
];
|
|
@@ -2,69 +2,53 @@ import styled from 'styled-components';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Skeleton } from 'antd';
|
|
4
4
|
import { formatDateTime } from '@bjsdistribution/dms-component-library';
|
|
5
|
-
import { usegetNotes } from '../store';
|
|
5
|
+
import { useAuditLogLoadingState, usegetNotes } from '../store';
|
|
6
6
|
import { NotesTableData } from '../notes/logs/fakeData';
|
|
7
|
-
import {
|
|
8
|
-
IconCover,
|
|
9
|
-
Td as BaseTd,
|
|
10
|
-
Th,
|
|
11
|
-
Table,
|
|
12
|
-
} from '../../order-daily-overview/common/css/TableStyle';
|
|
13
7
|
|
|
14
8
|
const GenericAuditLogsTable = () => {
|
|
15
9
|
const tableHeadData = NotesTableData[0].tableHead; // Assuming NotesTableData contains table header information
|
|
16
10
|
const [getNotes] = usegetNotes();
|
|
17
|
-
|
|
18
|
-
// const [isLoading] = UseNotesLoading();
|
|
19
|
-
// console.log(getNotes,'getNotesgetNotes');
|
|
11
|
+
const [auditLogLoadingStatus] = useAuditLogLoadingState();
|
|
20
12
|
|
|
21
13
|
return (
|
|
22
14
|
<ScrollableTableWrapper>
|
|
23
15
|
<AuditTableWrapper>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
))}
|
|
33
|
-
</tr>
|
|
34
|
-
</thead>
|
|
35
|
-
</StyledTable>
|
|
36
|
-
</StickyHeaderWrapper>
|
|
37
|
-
<StyledTable>
|
|
16
|
+
<table>
|
|
17
|
+
<thead>
|
|
18
|
+
<tr>
|
|
19
|
+
{tableHeadData?.map(column => (
|
|
20
|
+
<th key={column.key}>{column.label}</th>
|
|
21
|
+
))}
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
38
24
|
<tbody>
|
|
39
|
-
{
|
|
25
|
+
{auditLogLoadingStatus ? (
|
|
40
26
|
<tr>
|
|
41
27
|
<td className="noBoder" colSpan={tableHeadData?.length}>
|
|
42
28
|
<Skeleton />
|
|
43
29
|
</td>
|
|
44
30
|
</tr>
|
|
45
|
-
) : getNotes
|
|
46
|
-
getNotes?.
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
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}>
|
|
50
36
|
{note?.created_by}
|
|
51
|
-
</
|
|
37
|
+
</div>
|
|
52
38
|
<div>{formatDateTime(note?.created_at)}</div>
|
|
53
|
-
</
|
|
54
|
-
<
|
|
39
|
+
</td>
|
|
40
|
+
<td
|
|
55
41
|
dangerouslySetInnerHTML={{ __html: note?.description }}
|
|
56
|
-
></
|
|
57
|
-
</
|
|
42
|
+
></td>
|
|
43
|
+
</tr>
|
|
58
44
|
))
|
|
59
45
|
) : (
|
|
60
46
|
<tr>
|
|
61
|
-
<
|
|
62
|
-
No data found
|
|
63
|
-
</NoDataFound>
|
|
47
|
+
<td colSpan={tableHeadData?.length}>No data found</td>
|
|
64
48
|
</tr>
|
|
65
49
|
)}
|
|
66
50
|
</tbody>
|
|
67
|
-
</
|
|
51
|
+
</table>
|
|
68
52
|
</AuditTableWrapper>
|
|
69
53
|
</ScrollableTableWrapper>
|
|
70
54
|
);
|
|
@@ -109,52 +93,10 @@ export const AuditTableWrapper = styled.div`
|
|
|
109
93
|
}
|
|
110
94
|
`;
|
|
111
95
|
|
|
112
|
-
const DateTd = styled(BaseTd)`
|
|
113
|
-
color: #6d6d6d;
|
|
114
|
-
`;
|
|
115
|
-
|
|
116
|
-
const NoDataFound = styled(BaseTd)`
|
|
117
|
-
text-align: center;
|
|
118
|
-
padding: 16px;
|
|
119
|
-
font-size: 16px;
|
|
120
|
-
color: #999;
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
const StyledTable = styled(Table)`
|
|
124
|
-
width: 100%;
|
|
125
|
-
table-layout: fixed;
|
|
126
|
-
td.noBoder {
|
|
127
|
-
background: none !important;
|
|
128
|
-
border: none !important;
|
|
129
|
-
padding: 0;
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
132
|
-
|
|
133
|
-
const StyledTr = styled.tr`
|
|
134
|
-
&:nth-child(even) {
|
|
135
|
-
background-color: #f3fbff;
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
138
|
-
|
|
139
|
-
const StyledTd = styled(BaseTd)`
|
|
140
|
-
padding: 10px;
|
|
141
|
-
`;
|
|
142
|
-
|
|
143
|
-
const CreatedBy = styled.div`
|
|
144
|
-
font-weight: bold;
|
|
145
|
-
`;
|
|
146
|
-
|
|
147
96
|
const ScrollableTableWrapper = styled.div`
|
|
148
97
|
height: 250px;
|
|
149
98
|
min-height: 200px;
|
|
150
99
|
overflow: auto;
|
|
151
100
|
`;
|
|
152
101
|
|
|
153
|
-
const StickyHeaderWrapper = styled.div`
|
|
154
|
-
position: sticky;
|
|
155
|
-
top: 0;
|
|
156
|
-
z-index: 1;
|
|
157
|
-
background-color: #fff;
|
|
158
|
-
`;
|
|
159
|
-
|
|
160
102
|
export default GenericAuditLogsTable;
|
|
@@ -34,6 +34,7 @@ import { notification } from 'antd';
|
|
|
34
34
|
// import { useAssignData } from '../store';
|
|
35
35
|
import DetailsFilters from './details-filters/DetailsFilters';
|
|
36
36
|
import { useVisibilityData } from '../store';
|
|
37
|
+
import Notification from './notification';
|
|
37
38
|
|
|
38
39
|
interface ApiResponse {
|
|
39
40
|
message: string;
|
|
@@ -136,13 +137,6 @@ function OrderView() {
|
|
|
136
137
|
performAction: false,
|
|
137
138
|
});
|
|
138
139
|
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
if (orderId) {
|
|
141
|
-
orderUpdate(true);
|
|
142
|
-
liveRecalling ? setLivePerformAction(false) : setLivePerformAction(true);
|
|
143
|
-
}
|
|
144
|
-
}, [orderId, liveRecalling]);
|
|
145
|
-
|
|
146
140
|
const { data: fetchedStaticData, loading: staticDataLoading } = useApiHook<{
|
|
147
141
|
data: ApiResponse[];
|
|
148
142
|
}>({
|
|
@@ -169,6 +163,12 @@ function OrderView() {
|
|
|
169
163
|
method: 'GET',
|
|
170
164
|
filters: [{ field: 'visibility', op: '=', value: true }],
|
|
171
165
|
});
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (orderId) {
|
|
168
|
+
orderUpdate(true);
|
|
169
|
+
liveRecalling ? setLivePerformAction(false) : setLivePerformAction(true);
|
|
170
|
+
}
|
|
171
|
+
}, [orderId, liveRecalling]);
|
|
172
172
|
|
|
173
173
|
useEffect(() => {
|
|
174
174
|
setLoading(staticDataLoading);
|
|
@@ -355,7 +355,9 @@ function OrderView() {
|
|
|
355
355
|
return (
|
|
356
356
|
<MainContainer>
|
|
357
357
|
<GeneralHeader />
|
|
358
|
+
|
|
358
359
|
<DetailsFilters />
|
|
360
|
+
<Notification />
|
|
359
361
|
<OrderDetails />
|
|
360
362
|
<ProductsInfo />
|
|
361
363
|
<SplitLayout>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { RadioButtonGroup } from '@bjsdistribution/dms-component-library';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useSelectedData, useVisibilityData } from '../../store';
|
|
@@ -7,6 +7,17 @@ function NoteType() {
|
|
|
7
7
|
const [visibilityData] = useVisibilityData();
|
|
8
8
|
const [selected, setSelected] = useSelectedData();
|
|
9
9
|
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (visibilityData && !selected) {
|
|
12
|
+
const defaultOption = visibilityData?.find(
|
|
13
|
+
(option: any) => option.type === 'Private'
|
|
14
|
+
);
|
|
15
|
+
if (defaultOption) {
|
|
16
|
+
setSelected(defaultOption.value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}, [visibilityData, selected, setSelected]);
|
|
20
|
+
|
|
10
21
|
const handleRadioButtonChange = (
|
|
11
22
|
event: React.ChangeEvent<HTMLInputElement>
|
|
12
23
|
) => {
|
|
@@ -15,16 +15,9 @@ import {
|
|
|
15
15
|
function Notes() {
|
|
16
16
|
const [moduleIds, setModuleIds] = usemoduleIds();
|
|
17
17
|
const [orderId] = useOrderId();
|
|
18
|
-
// const location = useLocation();
|
|
19
|
-
// const pathname = location.pathname;
|
|
20
|
-
// const orderIdLocaation = pathname.split('/')[1];
|
|
21
|
-
|
|
22
|
-
const [recallAuditLog] = useGlobalStateHitAuditLog();
|
|
23
|
-
|
|
24
|
-
const [, setAuditLogLoading] = useAuditLogLoadingState();
|
|
25
|
-
|
|
26
18
|
const [, setNotes] = usegetNotes();
|
|
27
|
-
|
|
19
|
+
const [, setAuditLogLoading] = useAuditLogLoadingState();
|
|
20
|
+
const [recallAuditLog, setAuditLogs] = useGlobalStateHitAuditLog();
|
|
28
21
|
|
|
29
22
|
// Fetch module IDs
|
|
30
23
|
const { data: fetchedData, loading: apiLoading } = useApiHook<{ data: any }>({
|
|
@@ -38,22 +31,21 @@ function Notes() {
|
|
|
38
31
|
fetchedData?.data
|
|
39
32
|
.filter((item: any) => item?.name === 'ORDER')
|
|
40
33
|
.flatMap((item: any) =>
|
|
41
|
-
item?.static_child_mappings
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
item?.static_child_mappings
|
|
35
|
+
?.filter(
|
|
36
|
+
(child: any) => child?.child_module?.name === 'ORDER-NOTE'
|
|
37
|
+
)
|
|
38
|
+
.map((child: any) => ({
|
|
39
|
+
id: child?.child_module?.id,
|
|
40
|
+
parentId: child?.parent_module?.id,
|
|
41
|
+
}))
|
|
47
42
|
) || [];
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
(module: any) => module?.name === 'ORDER-NOTE'
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
setModuleIds(orderNoteModule || modules[0] || null);
|
|
44
|
+
setModuleIds(modules[0] || null);
|
|
54
45
|
}
|
|
55
46
|
}, [apiLoading, fetchedData]);
|
|
56
47
|
|
|
48
|
+
// Fetch Notes Data
|
|
57
49
|
const {
|
|
58
50
|
data: NotesData,
|
|
59
51
|
loading: NotesLoading,
|
|
@@ -69,13 +61,7 @@ function Notes() {
|
|
|
69
61
|
setShouldPerformAction(true);
|
|
70
62
|
}
|
|
71
63
|
if (!NotesLoading && NotesData?.data) {
|
|
72
|
-
|
|
73
|
-
// .filter((item: any) => item['ORDER-NOTE'] || item['ORDER'])
|
|
74
|
-
// .map((item: any) => [item['ORDER-NOTE'], item['ORDER']])
|
|
75
|
-
// .flat()
|
|
76
|
-
// .filter(Boolean);
|
|
77
|
-
|
|
78
|
-
const updatedData = NotesData.data
|
|
64
|
+
const updatedData = NotesData?.data
|
|
79
65
|
.filter(
|
|
80
66
|
(item: any) =>
|
|
81
67
|
item['ORDER-NOTE'] || item['ORDER'] || item['ORDER-RETURN']
|
|
@@ -84,12 +70,11 @@ function Notes() {
|
|
|
84
70
|
item['ORDER-NOTE'],
|
|
85
71
|
item['ORDER'],
|
|
86
72
|
item['ORDER-RETURN'],
|
|
87
|
-
])
|
|
73
|
+
])
|
|
74
|
+
.flat()
|
|
75
|
+
.filter(Boolean);
|
|
88
76
|
|
|
89
|
-
|
|
90
|
-
// const orderNotesData = NotesData?.data[1]?.['ORDER-NOTE'] || [];
|
|
91
|
-
// const allNotes = [...orderData, ...orderNotesData];
|
|
92
|
-
const combinedArray = updatedData.flat();
|
|
77
|
+
const combinedArray = updatedData?.flat();
|
|
93
78
|
combinedArray.sort(
|
|
94
79
|
(a: any, b: any) =>
|
|
95
80
|
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
|
@@ -102,9 +87,19 @@ function Notes() {
|
|
|
102
87
|
setAuditLogLoading(NotesLoading);
|
|
103
88
|
}, [moduleIds, orderId, NotesLoading, recallAuditLog]);
|
|
104
89
|
|
|
90
|
+
const handleGetLogs = () => {
|
|
91
|
+
setAuditLogs(true);
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
setAuditLogs(false);
|
|
94
|
+
}, 1000);
|
|
95
|
+
};
|
|
96
|
+
|
|
105
97
|
return (
|
|
106
98
|
<Container>
|
|
107
|
-
<CardHeader>
|
|
99
|
+
<CardHeader>
|
|
100
|
+
NOTES
|
|
101
|
+
<SmallButton onClick={handleGetLogs}>UPDATE LOGS</SmallButton>
|
|
102
|
+
</CardHeader>
|
|
108
103
|
<CustomizedFormSection>
|
|
109
104
|
<AddNote />
|
|
110
105
|
<AuditLogs />
|
|
@@ -129,6 +124,9 @@ const CardHeader = styled.div`
|
|
|
129
124
|
text-transform: uppercase;
|
|
130
125
|
font-family: 'Roboto', sans-serif;
|
|
131
126
|
font-weight: 600;
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: space-between;
|
|
129
|
+
align-items: center;
|
|
132
130
|
`;
|
|
133
131
|
|
|
134
132
|
const CustomizedFormSection = styled.div`
|
|
@@ -142,4 +140,19 @@ const CustomizedFormSection = styled.div`
|
|
|
142
140
|
border-bottom-left-radius: 8px;
|
|
143
141
|
box-shadow: 0px 4px 30px 0px rgba(46, 45, 116, 0.05);
|
|
144
142
|
`;
|
|
143
|
+
|
|
144
|
+
const SmallButton = styled.button`
|
|
145
|
+
background-color: #363a30;
|
|
146
|
+
color: #ffffff;
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
padding: 4px 8px;
|
|
149
|
+
border: none;
|
|
150
|
+
border-radius: 4px;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
transition: background-color 0.3s;
|
|
153
|
+
|
|
154
|
+
&:hover {
|
|
155
|
+
background-color: #feba30;
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
145
158
|
export default Notes;
|