@bjsdistribution/dms-client-return 0.1.5-prod → 0.1.6-prod
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/order-view/notes/AddNote.d.ts +1 -0
- package/dist/dms-client-return.cjs.development.js +179 -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 +180 -113
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/ActionIcon.tsx +1 -1
- package/src/assets/icons/ArrowDownIcon.tsx +2 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +4 -4
- package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
- package/src/components/order-view/notes/AddNote.tsx +111 -62
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.6-prod",
|
|
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": "0.3.
|
|
62
|
+
"@bjsdistribution/dms-component-library": "0.3.42-prod",
|
|
63
63
|
"@size-limit/preset-small-lib": "^11.0.1",
|
|
64
64
|
"@tippyjs/react": "^4.2.6",
|
|
65
65
|
"@types/react": "^18.2.47",
|
|
@@ -11,7 +11,7 @@ const ActionIcon = () => (
|
|
|
11
11
|
<path
|
|
12
12
|
d="M0.5 12.2432C0.5 5.61581 5.87258 0.243225 12.5 0.243225C19.1274 0.243225 24.5 5.61581 24.5 12.2432C24.5 18.8706 19.1274 24.2432 12.5 24.2432C5.87258 24.2432 0.5 18.8706 0.5 12.2432Z"
|
|
13
13
|
fill="#E95252"
|
|
14
|
-
|
|
14
|
+
fillOpacity="0.5"
|
|
15
15
|
/>
|
|
16
16
|
<path
|
|
17
17
|
d="M16.566 9.23825C16.6377 9.16909 16.6948 9.08636 16.7342 8.99488C16.7735 8.90339 16.7943 8.80499 16.7952 8.70541C16.7961 8.60582 16.7772 8.50705 16.7395 8.41486C16.7018 8.32267 16.6462 8.23891 16.5758 8.16846C16.5054 8.098 16.4217 8.04228 16.3295 8.00452C16.2374 7.96677 16.1386 7.94774 16.0391 7.94856C15.9395 7.94938 15.841 7.97002 15.7495 8.00929C15.658 8.04855 15.5752 8.10565 15.506 8.17725L12.5 11.1822L9.495 8.17725C9.42634 8.10356 9.34354 8.04446 9.25154 8.00347C9.15954 7.96247 9.06022 7.94043 8.95952 7.93865C8.85882 7.93688 8.75879 7.9554 8.6654 7.99312C8.57201 8.03084 8.48718 8.08699 8.41596 8.15821C8.34474 8.22943 8.2886 8.31426 8.25087 8.40765C8.21315 8.50104 8.19463 8.60107 8.19641 8.70177C8.19818 8.80247 8.22022 8.90178 8.26122 8.99378C8.30221 9.08578 8.36131 9.16858 8.435 9.23725L11.438 12.2432L8.433 15.2482C8.30052 15.3904 8.22839 15.5785 8.23182 15.7728C8.23525 15.9671 8.31396 16.1525 8.45138 16.2899C8.58879 16.4273 8.77417 16.506 8.96847 16.5094C9.16278 16.5128 9.35082 16.4407 9.493 16.3082L12.5 13.3032L15.505 16.3092C15.6472 16.4417 15.8352 16.5139 16.0295 16.5104C16.2238 16.507 16.4092 16.4283 16.5466 16.2909C16.684 16.1535 16.7627 15.9681 16.7662 15.7738C16.7696 15.5795 16.6975 15.3914 16.565 15.2492L13.562 12.2432L16.566 9.23825Z"
|
|
@@ -16,8 +16,8 @@ const ArrowDownIcon: React.FC<ArrowDownIconProps> = ({ fill = '#3A3630' }) => {
|
|
|
16
16
|
<rect width="24" height="24" fill={fill} />
|
|
17
17
|
<path
|
|
18
18
|
opacity="0.4"
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
fillRule="evenodd"
|
|
20
|
+
clipRule="evenodd"
|
|
21
21
|
d="M6.69104 9.8912C6.82604 9.75637 7.00903 9.68063 7.19984 9.68063C7.39064 9.68063 7.57363 9.75637 7.70864 9.8912L11.9998 14.1824L16.291 9.8912C16.4275 9.76402 16.608 9.69478 16.7946 9.69807C16.9811 9.70136 17.1591 9.77693 17.291 9.90884C17.4229 10.0408 17.4985 10.2187 17.5018 10.4053C17.5051 10.5918 17.4358 10.7723 17.3086 10.9088L12.5086 15.7088C12.3736 15.8436 12.1906 15.9194 11.9998 15.9194C11.809 15.9194 11.626 15.8436 11.491 15.7088L6.69104 10.9088C6.5562 10.7738 6.48047 10.5908 6.48047 10.4C6.48047 10.2092 6.5562 10.0262 6.69104 9.8912Z"
|
|
22
22
|
fill="#3A3630"
|
|
23
23
|
/>
|
package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx
CHANGED
|
@@ -40,7 +40,7 @@ function Options() {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const isReleased = orderStatus[0]?.released;
|
|
43
|
-
const routedValue = orderStatus[0]?.routed;
|
|
43
|
+
// const routedValue = orderStatus[0]?.routed;
|
|
44
44
|
const isRouted = orderStatus[0]?.routed && orderDetails?.order_routes?.id;
|
|
45
45
|
const isOrderOnHold = orderDetails?.status === 'OO';
|
|
46
46
|
const isOrderCancelled = orderDetails?.status === 'CO';
|
|
@@ -74,9 +74,9 @@ function Options() {
|
|
|
74
74
|
shouldExclude = true;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (routedValue && option.value === 'remove-from-route') {
|
|
78
|
-
|
|
79
|
-
}
|
|
77
|
+
// if (routedValue && option.value === 'remove-from-route') {
|
|
78
|
+
// shouldExclude = true;
|
|
79
|
+
// }
|
|
80
80
|
|
|
81
81
|
return !shouldExclude;
|
|
82
82
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
|
|
3
4
|
import { Skeleton } from 'antd';
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import {
|
|
6
|
+
PrivateIcon,
|
|
7
|
+
formatUtcToLocal,
|
|
8
|
+
} from '@bjsdistribution/dms-component-library';
|
|
6
9
|
import { NotesTableData } from '../notes/logs/fakeData';
|
|
10
|
+
import { useAuditLogLoadingState, usegetNotes } from '../store';
|
|
7
11
|
|
|
8
12
|
const GenericAuditLogsTable = () => {
|
|
9
|
-
const tableHeadData = NotesTableData[0]
|
|
13
|
+
const tableHeadData = NotesTableData[0]?.tableHead; // Assuming NotesTableData contains table header information
|
|
10
14
|
const [getNotes] = usegetNotes();
|
|
11
15
|
const [auditLogLoadingStatus] = useAuditLogLoadingState();
|
|
12
16
|
|
|
@@ -35,9 +39,23 @@ const GenericAuditLogsTable = () => {
|
|
|
35
39
|
<div className="bold" title={note?.created_by}>
|
|
36
40
|
{note?.created_by}
|
|
37
41
|
</div>
|
|
38
|
-
<div>
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
<div className="notesIcon">
|
|
43
|
+
{note?.is_private ? (
|
|
44
|
+
<>
|
|
45
|
+
<PrivateIcon />{' '}
|
|
46
|
+
<span className="datetime">{`${
|
|
47
|
+
formatUtcToLocal(note?.created_at).date
|
|
48
|
+
} @ ${
|
|
49
|
+
formatUtcToLocal(note?.created_at).time
|
|
50
|
+
}`}</span>
|
|
51
|
+
</>
|
|
52
|
+
) : (
|
|
53
|
+
<span className="datetime">{`${
|
|
54
|
+
formatUtcToLocal(note?.created_at).date
|
|
55
|
+
} @ ${formatUtcToLocal(note?.created_at).time}`}</span>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
<div>{note?.note_type || 'N/A'}</div>
|
|
41
59
|
</td>
|
|
42
60
|
<td
|
|
43
61
|
dangerouslySetInnerHTML={{ __html: note?.description }}
|
|
@@ -56,6 +74,8 @@ const GenericAuditLogsTable = () => {
|
|
|
56
74
|
);
|
|
57
75
|
};
|
|
58
76
|
|
|
77
|
+
const ScrollableTableWrapper = styled.div``;
|
|
78
|
+
|
|
59
79
|
export const AuditTableWrapper = styled.div`
|
|
60
80
|
height: 250px;
|
|
61
81
|
min-height: 200px;
|
|
@@ -82,22 +102,29 @@ export const AuditTableWrapper = styled.div`
|
|
|
82
102
|
color: #667085;
|
|
83
103
|
font-family: Lato;
|
|
84
104
|
font-size: 13px;
|
|
85
|
-
font-style: normal;
|
|
86
105
|
font-weight: 400;
|
|
87
106
|
line-height: 16px;
|
|
88
107
|
padding: 10px;
|
|
108
|
+
border-bottom: 1px solid #efe8e8;
|
|
109
|
+
word-break: break-word;
|
|
110
|
+
vertical-align: top;
|
|
111
|
+
|
|
89
112
|
.bold {
|
|
90
113
|
font-weight: 500;
|
|
91
114
|
font-size: 14px;
|
|
92
115
|
}
|
|
116
|
+
.notesIcon {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 5px;
|
|
120
|
+
|
|
121
|
+
.datetime {
|
|
122
|
+
min-width: 155px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
93
125
|
}
|
|
94
126
|
}
|
|
95
127
|
}
|
|
96
128
|
`;
|
|
97
129
|
|
|
98
|
-
const ScrollableTableWrapper = styled.div`
|
|
99
|
-
height: 550px;
|
|
100
|
-
overflow: auto;
|
|
101
|
-
`;
|
|
102
|
-
|
|
103
130
|
export default GenericAuditLogsTable;
|
|
@@ -1,42 +1,78 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
1
3
|
import {
|
|
2
4
|
Button,
|
|
3
5
|
Label,
|
|
4
6
|
useAxios,
|
|
5
|
-
// SelectDropdown,
|
|
6
7
|
} from '@bjsdistribution/dms-component-library';
|
|
7
|
-
import
|
|
8
|
-
import styled from 'styled-components';
|
|
9
|
-
import { useLocation } from 'react-router-dom';
|
|
8
|
+
import { Select, notification } from 'antd';
|
|
10
9
|
import { useGlobalStateHitAuditLog, usemoduleIds, useOrderId } from '../store';
|
|
11
|
-
import {
|
|
10
|
+
import { useLocation } from 'react-router-dom';
|
|
11
|
+
import { useClientPortal, useSelectedData } from '../../store';
|
|
12
12
|
import NoteType from './NoteType';
|
|
13
|
-
import { useSelectedData } from '../../store';
|
|
14
13
|
import { ApiResponse } from '../types';
|
|
14
|
+
const template = `REASON- \nSTC- \nACTION- `;
|
|
15
15
|
|
|
16
16
|
function AddNote() {
|
|
17
|
-
const [noteText, setNoteText] = useState(
|
|
17
|
+
const [noteText, setNoteText] = useState(template);
|
|
18
|
+
const [noteOptions, setNoteOptions] = useState<
|
|
19
|
+
{ label: string; value: string }[]
|
|
20
|
+
>([]);
|
|
21
|
+
const [selectedNoteType, setSelectedNoteType] = useState<string | null>(
|
|
22
|
+
'standard'
|
|
23
|
+
);
|
|
18
24
|
const [orderId] = useOrderId();
|
|
19
25
|
const location = useLocation();
|
|
20
26
|
const pathname = location.pathname;
|
|
21
27
|
const orderIdLocaation = pathname.split('/')[1];
|
|
28
|
+
const [isClientPortal] = useClientPortal();
|
|
22
29
|
const [moduleIds] = usemoduleIds();
|
|
23
30
|
const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
|
|
24
|
-
const [
|
|
31
|
+
const [selectedAssignee] = useSelectedData();
|
|
32
|
+
|
|
33
|
+
const { fetchData: getNoteType, data: fetchedData } = useAxios<any>({
|
|
34
|
+
endpoint: `audit_logs/order/type`,
|
|
35
|
+
method: 'GET',
|
|
36
|
+
});
|
|
37
|
+
console.log(selectedNoteType, 'selectedNoteType');
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
getNoteType();
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (fetchedData?.data) {
|
|
44
|
+
const options = fetchedData?.data?.map((item: any) => ({
|
|
45
|
+
label: item?.name,
|
|
46
|
+
value: item?.name,
|
|
47
|
+
}));
|
|
48
|
+
setNoteOptions(options);
|
|
49
|
+
|
|
50
|
+
const standardOption = options?.find(
|
|
51
|
+
(opt: any) => opt?.value?.toLowerCase() === 'standard'
|
|
52
|
+
);
|
|
53
|
+
if (standardOption) {
|
|
54
|
+
setSelectedNoteType(standardOption?.value);
|
|
55
|
+
} else if (options?.length > 0) {
|
|
56
|
+
setSelectedNoteType(options[0]?.value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [fetchedData]);
|
|
25
60
|
|
|
26
|
-
|
|
27
|
-
const { fetchData: callAuditLogs } = useAxios<{
|
|
28
|
-
data: ApiResponse[];
|
|
29
|
-
}>({
|
|
61
|
+
const { fetchData: callAuditLogs } = useAxios<{ data: ApiResponse[] }>({
|
|
30
62
|
endpoint: `/audit_logs/orders/`,
|
|
31
63
|
method: 'POST',
|
|
32
64
|
});
|
|
33
65
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
const isValidFormat = () => {
|
|
67
|
+
const lines = noteText.split('\n');
|
|
68
|
+
if (lines.length < 3) return false;
|
|
69
|
+
return (
|
|
70
|
+
lines[0].startsWith('REASON-') &&
|
|
71
|
+
lines[1].startsWith('STC-') &&
|
|
72
|
+
lines[2].startsWith('ACTION-')
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
const isDisabled = !noteText.trim() || !isValidFormat() || !selectedAssignee;
|
|
40
76
|
const saveNote = async () => {
|
|
41
77
|
setRecallAuditLog(false);
|
|
42
78
|
if (!noteText) return;
|
|
@@ -46,34 +82,38 @@ function AddNote() {
|
|
|
46
82
|
parent_object_id: orderId || orderIdLocaation,
|
|
47
83
|
parent_module_id: moduleIds?.parentId,
|
|
48
84
|
module_id: moduleIds?.id,
|
|
85
|
+
note_type: selectedNoteType,
|
|
49
86
|
module_object_id: orderId || orderIdLocaation,
|
|
50
87
|
action: 'create',
|
|
51
88
|
description: noteText,
|
|
52
89
|
data_dump: '{}',
|
|
53
90
|
manual: 1,
|
|
54
|
-
is_private:
|
|
91
|
+
is_private: isClientPortal
|
|
92
|
+
? false
|
|
93
|
+
: selectedAssignee === '0'
|
|
94
|
+
? true
|
|
95
|
+
: false,
|
|
55
96
|
},
|
|
56
97
|
],
|
|
57
98
|
};
|
|
58
99
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
code: number | null;
|
|
63
|
-
error?: string | null | undefined;
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
};
|
|
66
|
-
if (response.code == 200 && response?.data) {
|
|
100
|
+
const response = await callAuditLogs({ payload });
|
|
101
|
+
//@ts-ignore
|
|
102
|
+
if (response?.code === 200 && response?.data) {
|
|
67
103
|
notification.success({
|
|
68
104
|
message: 'Success',
|
|
69
|
-
|
|
105
|
+
//@ts-ignore
|
|
106
|
+
description: response?.message || 'Note saved successfully',
|
|
70
107
|
});
|
|
71
|
-
|
|
108
|
+
|
|
109
|
+
setNoteText(template);
|
|
110
|
+
setSelectedNoteType('Standard');
|
|
72
111
|
setRecallAuditLog(true);
|
|
73
112
|
} else {
|
|
74
113
|
notification.error({
|
|
75
114
|
message: 'Error',
|
|
76
|
-
|
|
115
|
+
//@ts-ignore
|
|
116
|
+
description: response?.error || 'Failed to save note',
|
|
77
117
|
});
|
|
78
118
|
}
|
|
79
119
|
} catch (error) {
|
|
@@ -83,38 +123,47 @@ function AddNote() {
|
|
|
83
123
|
});
|
|
84
124
|
}
|
|
85
125
|
};
|
|
126
|
+
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
127
|
+
const val = e.target.value;
|
|
128
|
+
const lines = val.split('\n');
|
|
86
129
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
message,
|
|
92
|
-
description,
|
|
93
|
-
duration: 5,
|
|
94
|
-
});
|
|
95
|
-
setNotificationData(null); // Clear notification data after showing
|
|
130
|
+
while (lines.length < 3) {
|
|
131
|
+
if (lines.length === 0) lines.push('REASON- ');
|
|
132
|
+
else if (lines.length === 1) lines.push('STC- ');
|
|
133
|
+
else if (lines.length === 2) lines.push('ACTION- ');
|
|
96
134
|
}
|
|
97
135
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
136
|
+
const enforcedLines = lines.map((line, idx) => {
|
|
137
|
+
if (idx === 0) {
|
|
138
|
+
if (!line.startsWith('REASON-')) return 'REASON- ';
|
|
139
|
+
}
|
|
140
|
+
if (idx === 1) {
|
|
141
|
+
if (!line.startsWith('STC-')) return 'STC- ';
|
|
142
|
+
}
|
|
143
|
+
if (idx === 2) {
|
|
144
|
+
if (!line.startsWith('ACTION-')) return 'ACTION- ';
|
|
145
|
+
}
|
|
146
|
+
return line;
|
|
101
147
|
});
|
|
102
|
-
|
|
148
|
+
|
|
149
|
+
setNoteText(enforcedLines.join('\n'));
|
|
150
|
+
};
|
|
103
151
|
|
|
104
152
|
return (
|
|
105
153
|
<Container>
|
|
106
|
-
<Label label="Add New Note" />
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
placeholder="
|
|
110
|
-
|
|
111
|
-
|
|
154
|
+
<Label label="Add New Note" required style={{ color: 'black' }} />
|
|
155
|
+
<StyledAntSelect
|
|
156
|
+
options={noteOptions}
|
|
157
|
+
placeholder="Select Note Type"
|
|
158
|
+
onChange={(value: string) => setSelectedNoteType(value)}
|
|
159
|
+
value={selectedNoteType}
|
|
112
160
|
/>
|
|
161
|
+
<StyledTextArea value={noteText} onChange={handleChange} rows={3} />
|
|
113
162
|
<SaveNoteContainer>
|
|
114
|
-
<Button disabled={
|
|
163
|
+
<Button disabled={isDisabled} onClick={saveNote}>
|
|
115
164
|
SAVE NOTE
|
|
116
165
|
</Button>
|
|
117
|
-
<NoteType />
|
|
166
|
+
{!isClientPortal && <NoteType />}
|
|
118
167
|
</SaveNoteContainer>
|
|
119
168
|
</Container>
|
|
120
169
|
);
|
|
@@ -137,20 +186,20 @@ const SaveNoteContainer = styled.div`
|
|
|
137
186
|
`;
|
|
138
187
|
|
|
139
188
|
const StyledTextArea = styled.textarea`
|
|
140
|
-
height:
|
|
141
|
-
border-radius: 12px;
|
|
142
|
-
background: #fff;
|
|
143
|
-
resize: none;
|
|
189
|
+
height: 65px;
|
|
144
190
|
border-radius: 8px;
|
|
145
|
-
|
|
146
|
-
|
|
191
|
+
background: #fff;
|
|
192
|
+
resize: vertical;
|
|
193
|
+
border: 1px solid #e0e2e7;
|
|
147
194
|
padding: 8px 12px;
|
|
195
|
+
font-family: monospace;
|
|
196
|
+
white-space: pre-wrap;
|
|
148
197
|
`;
|
|
149
198
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
199
|
+
export const StyledAntSelect: any = styled(Select)`
|
|
200
|
+
.ant-select-selector {
|
|
201
|
+
border-radius: 8px;
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
155
204
|
|
|
156
205
|
export default AddNote;
|