@bjsdistribution/dms-client-return 0.0.89 → 0.0.90
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/flags-action-modal/Actions.d.ts +1 -1
- package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +1136 -1898
- 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 +1138 -1900
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +0 -3
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +1 -4
- package/src/components/order-daily-overview/table/ReturnTable.tsx +0 -2
- package/src/components/order-view/flags-action-modal/Actions.tsx +33 -17
- package/src/components/order-view/flags-action-modal/Header.tsx +34 -9
- package/src/components/order-view/flags-action-modal/index.tsx +44 -27
- package/src/components/order-view/index.tsx +28 -16
- package/src/components/order-view/notes/AddNote.tsx +1 -1
- package/src/components/order-view/notification/index.tsx +42 -15
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +40 -11
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +17 -5
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +0 -4
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +54 -14
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +57 -22
- package/src/components/order-view/order-actions/actions/order-lock/index.tsx +34 -9
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +22 -5
- package/src/components/order-view/order-resources/columns/actions/index.tsx +1 -1
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +1 -7
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +23 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +157 -118
- package/dist/components/order-view/hooks/AddResources.d.ts +0 -2
- package/dist/components/order-view/hooks/useGetEventNotes.d.ts +0 -2
- package/dist/components/order-view/hooks/useGetSystemLogs.d.ts +0 -2
- package/dist/components/order-view/hooks/useUpdateOrder.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useAllReminderData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useAllTaskData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useCreateReminder.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useCreateTask.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useFetchSingleFlagData.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useFetchSingleReminder.d.ts +0 -2
- package/dist/components/order-view/order-actions/hooks/useUpdateFlag.d.ts +0 -3
- package/dist/components/order-view/order-actions/hooks/useUpdateReminder.d.ts +0 -3
- package/src/components/order-view/hooks/AddResources.tsx +0 -54
- package/src/components/order-view/hooks/useGetEventNotes.tsx +0 -60
- package/src/components/order-view/hooks/useGetSystemLogs.tsx +0 -71
- package/src/components/order-view/hooks/useUpdateOrder.ts +0 -62
- package/src/components/order-view/order-actions/hooks/useAllReminderData.ts +0 -70
- package/src/components/order-view/order-actions/hooks/useAllTaskData.ts +0 -72
- package/src/components/order-view/order-actions/hooks/useCreateReminder.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useCreateTask.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useFetchSingleFlagData.ts +0 -58
- package/src/components/order-view/order-actions/hooks/useFetchSingleReminder.ts +0 -56
- package/src/components/order-view/order-actions/hooks/useUpdateFlag.ts +0 -54
- package/src/components/order-view/order-actions/hooks/useUpdateReminder.ts +0 -52
|
@@ -3,17 +3,14 @@ import OrderActionModal from '../../../common/modals/order-action-modal/OrderAct
|
|
|
3
3
|
import { useCurrentAction } from '../store';
|
|
4
4
|
import { DatePickerWrap, Label } from '../order-actions/actions/modalstyle';
|
|
5
5
|
import {
|
|
6
|
-
useFlagsLoading,
|
|
7
6
|
useReminderRefId,
|
|
8
7
|
useSingleReminderData,
|
|
9
8
|
useUpdateReminderData,
|
|
10
9
|
} from '../order-actions/store';
|
|
11
|
-
import Loader from '../../order-daily-overview/header/loader/Loader';
|
|
12
10
|
import StatusIndicator from '../flags-action-modal/StatusIndicator';
|
|
13
11
|
import styled from 'styled-components';
|
|
14
12
|
import { format, isValid } from 'date-fns';
|
|
15
|
-
import
|
|
16
|
-
import { DatePicker } from 'antd';
|
|
13
|
+
import { DatePicker, notification } from 'antd';
|
|
17
14
|
import dayjs from 'dayjs';
|
|
18
15
|
import {
|
|
19
16
|
ReferenceContainer,
|
|
@@ -29,35 +26,53 @@ import {
|
|
|
29
26
|
MiniContainer,
|
|
30
27
|
TimeWrapper,
|
|
31
28
|
} from './reminder-styles';
|
|
32
|
-
import useFetchSingleReminderData from '../order-actions/hooks/useFetchSingleReminder';
|
|
33
|
-
import useUpdateReminder from '../order-actions/hooks/useUpdateReminder';
|
|
34
29
|
import AssigneeDropdown from './AssigneeDropdown';
|
|
30
|
+
import { useAxios } from '@bjsdistribution/dms-component-library';
|
|
31
|
+
import { ApiResponse } from '../types';
|
|
35
32
|
|
|
36
33
|
const ViewReminderModal = () => {
|
|
37
34
|
const [, setCurrentAction] = useCurrentAction();
|
|
38
|
-
const fetchData = useFetchSingleReminderData();
|
|
39
|
-
const fetchRemindersData = useFetchReminders();
|
|
40
|
-
|
|
41
|
-
const updateReminder = useUpdateReminder();
|
|
42
35
|
const [, setDueDate] = useState<any | null>(null);
|
|
43
36
|
const [reminderData, setReminderData] = useSingleReminderData();
|
|
44
37
|
const [reminderRefId] = useReminderRefId();
|
|
45
|
-
const [loading, setLoading] = useFlagsLoading();
|
|
46
38
|
const [reminderPayload, setPayload] = useUpdateReminderData();
|
|
47
39
|
|
|
40
|
+
//reminder get
|
|
41
|
+
const {
|
|
42
|
+
data: fetchedReminderData,
|
|
43
|
+
loading: reminderLoading,
|
|
44
|
+
fetchData: callReminderApi,
|
|
45
|
+
} = useAxios<{
|
|
46
|
+
data: ApiResponse[];
|
|
47
|
+
}>({
|
|
48
|
+
endpoint: `/tasks/reminder/${reminderRefId}`,
|
|
49
|
+
method: 'GET',
|
|
50
|
+
pagination: { is_pagination: false },
|
|
51
|
+
filters: [{ field: 'order_id', op: '=', value: reminderRefId }],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//use Axios Reminder
|
|
55
|
+
const { fetchData: callReminderEditAPI } = useAxios<{
|
|
56
|
+
data: ApiResponse[];
|
|
57
|
+
}>({
|
|
58
|
+
endpoint: `/tasks/reminder/update/`,
|
|
59
|
+
method: 'PUT',
|
|
60
|
+
});
|
|
61
|
+
|
|
48
62
|
const closeModal = () => {
|
|
49
63
|
setCurrentAction(undefined);
|
|
50
64
|
};
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (fetchedReminderData && fetchedReminderData?.data) {
|
|
68
|
+
setReminderData(fetchedReminderData?.data);
|
|
69
|
+
}
|
|
70
|
+
}, [reminderLoading]);
|
|
58
71
|
|
|
59
72
|
useEffect(() => {
|
|
60
|
-
|
|
73
|
+
if (reminderRefId) {
|
|
74
|
+
callReminderApi();
|
|
75
|
+
}
|
|
61
76
|
}, [reminderRefId]);
|
|
62
77
|
|
|
63
78
|
useEffect(() => {
|
|
@@ -116,10 +131,33 @@ const ViewReminderModal = () => {
|
|
|
116
131
|
};
|
|
117
132
|
|
|
118
133
|
const handleEditReminder = async () => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
134
|
+
try {
|
|
135
|
+
const apiResponse = (await callReminderEditAPI({
|
|
136
|
+
payload: [reminderPayload],
|
|
137
|
+
})) as {
|
|
138
|
+
code: number | null;
|
|
139
|
+
error?: string | null | undefined;
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
};
|
|
142
|
+
if (apiResponse?.code === 200 && apiResponse?.data) {
|
|
143
|
+
notification.success({
|
|
144
|
+
message: 'Success',
|
|
145
|
+
description: apiResponse.message,
|
|
146
|
+
});
|
|
147
|
+
callReminderApi();
|
|
148
|
+
closeModal();
|
|
149
|
+
} else {
|
|
150
|
+
notification.error({
|
|
151
|
+
message: 'Failure',
|
|
152
|
+
description: apiResponse?.error || 'An error occurred.',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
notification.error({
|
|
157
|
+
message: 'Error',
|
|
158
|
+
description: 'Failed to update the reminder. Please try again later.',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
123
161
|
};
|
|
124
162
|
|
|
125
163
|
const isDisabled = reminderData?.reminder_status?.name_alias === 'resolved';
|
|
@@ -131,104 +169,105 @@ const ViewReminderModal = () => {
|
|
|
131
169
|
|
|
132
170
|
return (
|
|
133
171
|
<>
|
|
134
|
-
{reminderData &&
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/>
|
|
184
|
-
)}
|
|
185
|
-
</LabelText>
|
|
186
|
-
</MiniContainer>
|
|
187
|
-
</InnerContainer>
|
|
188
|
-
</ReferenceContainer>
|
|
189
|
-
<ContentsContainer>
|
|
190
|
-
<Left>
|
|
191
|
-
<AssigneeDropdown />
|
|
192
|
-
<DateTimeContainer>
|
|
193
|
-
<Label>Due </Label>
|
|
194
|
-
<Row>
|
|
195
|
-
<StyleContainer>
|
|
196
|
-
<DatePickerWrap>
|
|
197
|
-
<DatePicker
|
|
198
|
-
format="DD/MM/YYYY"
|
|
199
|
-
value={
|
|
200
|
-
reminderPayload?.due_date
|
|
201
|
-
? dayjs(reminderPayload?.due_date)
|
|
202
|
-
: null
|
|
203
|
-
}
|
|
204
|
-
onChange={handleDateChange}
|
|
172
|
+
{reminderData && (
|
|
173
|
+
<OrderActionModal
|
|
174
|
+
headerTitle="View Reminder"
|
|
175
|
+
onCloseHeader={closeModal}
|
|
176
|
+
onSubmit={handleEditReminder}
|
|
177
|
+
submitBtnTitle="Save Details"
|
|
178
|
+
isSubmitDisabled={isDisabled}
|
|
179
|
+
showAdditionalInfo
|
|
180
|
+
infoText={additional || 'NA'}
|
|
181
|
+
headerActions={
|
|
182
|
+
<OuterDiv>
|
|
183
|
+
{reminderData?.reminder_status?.name_alias === 'pending' ||
|
|
184
|
+
reminderData?.reminder_status?.name_alias === 'unresolved' ? (
|
|
185
|
+
<>
|
|
186
|
+
<StyledWrapper>
|
|
187
|
+
<StyledLabel>
|
|
188
|
+
<StyledCheckbox>
|
|
189
|
+
<input
|
|
190
|
+
type="checkbox"
|
|
191
|
+
onChange={() => handleResolved(2)}
|
|
192
|
+
/>
|
|
193
|
+
<RoundCheckbox />
|
|
194
|
+
</StyledCheckbox>
|
|
195
|
+
<StyledSpan>Mark As Complete</StyledSpan>
|
|
196
|
+
</StyledLabel>
|
|
197
|
+
</StyledWrapper>
|
|
198
|
+
</>
|
|
199
|
+
) : null}
|
|
200
|
+
</OuterDiv>
|
|
201
|
+
}
|
|
202
|
+
>
|
|
203
|
+
<ReferenceContainer style={{ marginTop: '20px' }}>
|
|
204
|
+
<InnerContainer>
|
|
205
|
+
<MiniContainer>
|
|
206
|
+
{' '}
|
|
207
|
+
<Label>Reference {} </Label>
|
|
208
|
+
<LabelText>{reminderData?.reference || 'N/A'}</LabelText>
|
|
209
|
+
</MiniContainer>
|
|
210
|
+
<MiniContainer>
|
|
211
|
+
{' '}
|
|
212
|
+
<Label>Status </Label>
|
|
213
|
+
<LabelText>
|
|
214
|
+
{reminderData?.reminder_status?.name_alias === 'pending' ||
|
|
215
|
+
reminderData?.reminder_status?.name_alias === 'unresolved' ? (
|
|
216
|
+
<StatusIndicator text="Incomplete" status="AD" />
|
|
217
|
+
) : (
|
|
218
|
+
<StatusIndicator
|
|
219
|
+
text={`Completed on ${reminderData?.completed} by ${reminderData?.completed_by}`}
|
|
220
|
+
status="SD"
|
|
205
221
|
/>
|
|
206
|
-
|
|
207
|
-
</
|
|
222
|
+
)}
|
|
223
|
+
</LabelText>
|
|
224
|
+
</MiniContainer>
|
|
225
|
+
</InnerContainer>
|
|
226
|
+
</ReferenceContainer>
|
|
227
|
+
<ContentsContainer>
|
|
228
|
+
<Left>
|
|
229
|
+
<AssigneeDropdown />
|
|
230
|
+
<DateTimeContainer>
|
|
231
|
+
<Label>Due </Label>
|
|
232
|
+
<Row>
|
|
233
|
+
<StyleContainer>
|
|
234
|
+
<DatePickerWrap>
|
|
235
|
+
<DatePicker
|
|
236
|
+
format="DD/MM/YYYY"
|
|
237
|
+
value={
|
|
238
|
+
reminderPayload?.due_date
|
|
239
|
+
? dayjs(reminderPayload?.due_date)
|
|
240
|
+
: null
|
|
241
|
+
}
|
|
242
|
+
onChange={handleDateChange}
|
|
243
|
+
/>
|
|
244
|
+
</DatePickerWrap>
|
|
245
|
+
</StyleContainer>
|
|
208
246
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
247
|
+
<TimeWrapper>
|
|
248
|
+
<StyledTime
|
|
249
|
+
onChange={handleTime}
|
|
250
|
+
value={reminderPayload?.due_time}
|
|
251
|
+
type="time"
|
|
252
|
+
/>
|
|
253
|
+
</TimeWrapper>
|
|
254
|
+
</Row>
|
|
255
|
+
</DateTimeContainer>
|
|
256
|
+
</Left>
|
|
257
|
+
<Right>
|
|
258
|
+
<DetailedContainer>
|
|
259
|
+
<Label>Details</Label>
|
|
260
|
+
<StyledText
|
|
261
|
+
name="text"
|
|
262
|
+
required
|
|
263
|
+
value={reminderPayload?.details}
|
|
264
|
+
onChange={onChangeDetails}
|
|
265
|
+
/>
|
|
266
|
+
</DetailedContainer>
|
|
267
|
+
</Right>
|
|
268
|
+
</ContentsContainer>
|
|
269
|
+
</OrderActionModal>
|
|
270
|
+
)}
|
|
232
271
|
</>
|
|
233
272
|
);
|
|
234
273
|
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { notification } from 'antd';
|
|
3
|
-
import { getCookie } from '../utils';
|
|
4
|
-
import {
|
|
5
|
-
selectedCategoryIdAtom,
|
|
6
|
-
selectedDocumentTypeAtom,
|
|
7
|
-
selectedTypeAtom,
|
|
8
|
-
selectedVisibilityAtom,
|
|
9
|
-
} from '../order-actions/store';
|
|
10
|
-
import { useAtom } from 'jotai';
|
|
11
|
-
import { useOrderId } from '../store';
|
|
12
|
-
|
|
13
|
-
function useUploadFiles() {
|
|
14
|
-
const ssoToken = getCookie('id_token');
|
|
15
|
-
|
|
16
|
-
const [selectedCategoryId] = useAtom(selectedCategoryIdAtom);
|
|
17
|
-
const [selectedDocumentType] = useAtom(selectedDocumentTypeAtom);
|
|
18
|
-
const [selectedType] = useAtom(selectedTypeAtom);
|
|
19
|
-
const [orderId] = useOrderId();
|
|
20
|
-
const [selectedVisibility] = useAtom(selectedVisibilityAtom);
|
|
21
|
-
|
|
22
|
-
const create = async (formData: FormData) => {
|
|
23
|
-
const endpoint = `${getBaseEndpoint()}/orders/${orderId}/order_resources/?document_type=${selectedDocumentType}&type=${selectedType}&category=${selectedCategoryId}&visibility=${selectedVisibility}`;
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const requestOptions = {
|
|
27
|
-
headers: {
|
|
28
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
29
|
-
},
|
|
30
|
-
method: 'POST',
|
|
31
|
-
body: formData,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const response = await fetch(endpoint, requestOptions);
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
throw new Error('Failed to upload files');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const json = await response.json();
|
|
40
|
-
return json;
|
|
41
|
-
} catch (err) {
|
|
42
|
-
notification.error({
|
|
43
|
-
message: 'Error',
|
|
44
|
-
//@ts-ignore
|
|
45
|
-
description: `${err.message}` || 'Upload error:', // Using err.message for clearer output
|
|
46
|
-
});
|
|
47
|
-
throw err;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return create;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default useUploadFiles;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { getCookie } from '../utils';
|
|
3
|
-
import { notification } from 'antd';
|
|
4
|
-
// import { useOrderDetails, useOrderProductSystemLogs } from '../store';
|
|
5
|
-
|
|
6
|
-
function useGetEventNotes() {
|
|
7
|
-
const ssoToken = getCookie('id_token');
|
|
8
|
-
|
|
9
|
-
const perform = async () => {
|
|
10
|
-
const endpoint = `${getBaseEndpoint()}/events/get/event_information/`;
|
|
11
|
-
// setLoading(true);
|
|
12
|
-
try {
|
|
13
|
-
const headers = {
|
|
14
|
-
accept: 'application/json',
|
|
15
|
-
'Content-Type': 'application/json',
|
|
16
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
17
|
-
'x-pagination': JSON.stringify({
|
|
18
|
-
is_pagination: false,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
const response = await fetch(endpoint, {
|
|
22
|
-
method: 'GET',
|
|
23
|
-
headers,
|
|
24
|
-
});
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
const json = await response.json();
|
|
27
|
-
const detail = json?.detail;
|
|
28
|
-
const msg = detail[0]?.msg;
|
|
29
|
-
// console.error('Error response:', msg);
|
|
30
|
-
|
|
31
|
-
notification.error({
|
|
32
|
-
message: 'Error',
|
|
33
|
-
description:
|
|
34
|
-
`${msg}` || 'An error has occurred. Please try again later.',
|
|
35
|
-
});
|
|
36
|
-
// setLoading(false);
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const json = await response.json();
|
|
40
|
-
if (json.code === 200) {
|
|
41
|
-
return json?.data;
|
|
42
|
-
}
|
|
43
|
-
return [];
|
|
44
|
-
} catch (err) {
|
|
45
|
-
// console.error('Error fetching data:', err);
|
|
46
|
-
notification.error({
|
|
47
|
-
message: 'Error',
|
|
48
|
-
description:
|
|
49
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return [];
|
|
53
|
-
} finally {
|
|
54
|
-
// setLoading(false);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
return perform;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default useGetEventNotes;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { getCookie } from '../utils';
|
|
3
|
-
import { useOrderDetails, useOrderProductSystemLogs } from '../store';
|
|
4
|
-
import { notification } from 'antd';
|
|
5
|
-
|
|
6
|
-
function useSystemLogs() {
|
|
7
|
-
const ssoToken = getCookie('id_token');
|
|
8
|
-
const [orderDetails] = useOrderDetails();
|
|
9
|
-
const gsitId = orderDetails?.gsit_order_id;
|
|
10
|
-
const [, setSystemLogsEvents] = useOrderProductSystemLogs();
|
|
11
|
-
|
|
12
|
-
const perform = async () => {
|
|
13
|
-
const endpoint = `${getBaseEndpoint()}/events/get/event/`;
|
|
14
|
-
// setLoading(true);
|
|
15
|
-
try {
|
|
16
|
-
const headers = {
|
|
17
|
-
accept: 'application/json',
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
20
|
-
'x-pagination': JSON.stringify({
|
|
21
|
-
is_pagination: false,
|
|
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
|
-
|
|
41
|
-
notification.error({
|
|
42
|
-
message: 'Error',
|
|
43
|
-
description:
|
|
44
|
-
`${msg}` || 'An error has occurred. Please try again later.',
|
|
45
|
-
});
|
|
46
|
-
// setLoading(false);
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const json = await response.json();
|
|
50
|
-
if (json.code === 200) {
|
|
51
|
-
// setLoading(false);
|
|
52
|
-
setSystemLogsEvents(json.data);
|
|
53
|
-
return json.data;
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
} catch (err) {
|
|
57
|
-
// console.error('Error fetching data:', err);
|
|
58
|
-
notification.error({
|
|
59
|
-
message: 'Error',
|
|
60
|
-
description:
|
|
61
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
62
|
-
});
|
|
63
|
-
return [];
|
|
64
|
-
} finally {
|
|
65
|
-
// setLoading(false);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
return perform;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default useSystemLogs;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { getBaseEndpoint } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import { getCookie } from '../utils';
|
|
3
|
-
import { notification } from 'antd';
|
|
4
|
-
import { useUpdateApiCall } from '../store';
|
|
5
|
-
|
|
6
|
-
function useUpdateOrder() {
|
|
7
|
-
let controller: AbortController;
|
|
8
|
-
const ssoToken = getCookie('id_token');
|
|
9
|
-
const [, setCallApi] = useUpdateApiCall(); //single detail
|
|
10
|
-
|
|
11
|
-
const update = async (data: any) => {
|
|
12
|
-
const endpoint = `${getBaseEndpoint()}/orders/update/`;
|
|
13
|
-
|
|
14
|
-
if (controller) {
|
|
15
|
-
controller.abort();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Create new AbortController
|
|
19
|
-
controller = new AbortController();
|
|
20
|
-
const signal = controller.signal;
|
|
21
|
-
// setLoading(true); // Set loading to true
|
|
22
|
-
try {
|
|
23
|
-
const requestOptions = {
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
Authorization: `Bearer ${ssoToken}`,
|
|
27
|
-
},
|
|
28
|
-
method: 'PUT',
|
|
29
|
-
body: JSON.stringify(data),
|
|
30
|
-
signal,
|
|
31
|
-
};
|
|
32
|
-
const response = await fetch(endpoint, requestOptions);
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
// setLoading(false);
|
|
35
|
-
throw new Error('response is not ok');
|
|
36
|
-
}
|
|
37
|
-
const json = await response.json();
|
|
38
|
-
// alert('Order has been updated');
|
|
39
|
-
notification.success({
|
|
40
|
-
message: 'Success',
|
|
41
|
-
description: 'Order has been updated.',
|
|
42
|
-
});
|
|
43
|
-
setCallApi(true);
|
|
44
|
-
return json;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
// setLoading(false);
|
|
47
|
-
// console.log(err, 'error');
|
|
48
|
-
|
|
49
|
-
notification.error({
|
|
50
|
-
message: 'Error',
|
|
51
|
-
description:
|
|
52
|
-
`${err}` || 'An error has occurred. Please try again later.',
|
|
53
|
-
});
|
|
54
|
-
} finally {
|
|
55
|
-
// setLoading(false); // Set loading to false after fetching
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return update;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default useUpdateOrder;
|