@bjsdistribution/dms-client-return 0.0.94-prod → 0.0.95-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.
Files changed (138) hide show
  1. package/dist/assets/icons/ArrowDownIcon.d.ts +6 -0
  2. package/dist/assets/icons/DeliverProductIcon.d.ts +3 -0
  3. package/dist/assets/icons/ReturnProductIcon.d.ts +3 -0
  4. package/dist/common/checkbox/index.d.ts +2 -0
  5. package/dist/common/modals/order-action-modal/OrderActionModal.d.ts +3 -1
  6. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.d.ts +1 -0
  7. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.d.ts +2 -2
  8. package/dist/components/order-view/flags-action-modal/Actions.d.ts +6 -2
  9. package/dist/components/order-view/flags-action-modal/Dropdowns.d.ts +1 -0
  10. package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
  11. package/dist/components/order-view/notification/FlagTemplate.d.ts +1 -1
  12. package/dist/components/order-view/notification/OrderTemplate.d.ts +1 -1
  13. package/dist/components/order-view/notification/Tabs.d.ts +1 -1
  14. package/dist/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.d.ts +5 -0
  15. package/dist/components/order-view/order-actions/actions/cancel-order/index.d.ts +7 -1
  16. package/dist/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.d.ts +4 -1
  17. package/dist/components/order-view/order-actions/actions/charge-log/index.d.ts +11 -0
  18. package/dist/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.d.ts +1 -13
  19. package/dist/components/order-view/order-actions/actions/create-task-reminder/TaskModal.d.ts +5 -1
  20. package/dist/components/order-view/order-actions/actions/create-task-reminder/index.d.ts +6 -2
  21. package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +6 -1
  22. package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +5 -1
  23. package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +5 -3
  24. package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +5 -1
  25. package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +1 -1
  26. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +7 -1
  27. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.d.ts +5 -0
  28. package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +6 -1
  29. package/dist/components/order-view/order-actions/store.d.ts +10 -8
  30. package/dist/components/order-view/order-actions/types.d.ts +38 -60
  31. package/dist/components/order-view/order-actions/utils.d.ts +2 -1
  32. package/dist/components/order-view/store.d.ts +48 -3
  33. package/dist/components/order-view/types.d.ts +11 -0
  34. package/dist/components/order-view/utils.d.ts +1 -0
  35. package/dist/components/order-view/view-reminder/ViewReminder.d.ts +5 -1
  36. package/dist/components/order-view/view-reminder/reminder-styles.d.ts +3 -1
  37. package/dist/components/store.d.ts +2 -1
  38. package/dist/dms-client-return.cjs.development.js +4812 -3095
  39. package/dist/dms-client-return.cjs.development.js.map +1 -1
  40. package/dist/dms-client-return.cjs.production.min.js +1 -1
  41. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  42. package/dist/dms-client-return.esm.js +4815 -3098
  43. package/dist/dms-client-return.esm.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/assets/icons/ArrowDownIcon.tsx +28 -0
  46. package/src/assets/icons/DeliverProductIcon.tsx +42 -0
  47. package/src/assets/icons/ReturnProductIcon.tsx +23 -0
  48. package/src/common/checkbox/index.tsx +60 -17
  49. package/src/common/modals/order-action-modal/OrderActionModal.tsx +13 -7
  50. package/src/common/radio-group/RadioButtonGroup.tsx +3 -4
  51. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +29 -26
  52. package/src/components/order-daily-overview/header-filters/filterStore.ts +6 -8
  53. package/src/components/order-daily-overview/index.tsx +20 -7
  54. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +2 -2
  55. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +19 -19
  56. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +11 -9
  57. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +19 -4
  58. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +41 -59
  59. package/src/components/order-daily-overview/table/ReturnTable.tsx +1 -30
  60. package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +52 -2
  61. package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +37 -43
  62. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +75 -44
  63. package/src/components/order-view/fakedata.ts +7 -6
  64. package/src/components/order-view/flags-action-modal/Actions.tsx +51 -25
  65. package/src/components/order-view/flags-action-modal/DetailSection.tsx +5 -5
  66. package/src/components/order-view/flags-action-modal/Dropdowns.tsx +75 -89
  67. package/src/components/order-view/flags-action-modal/Header.tsx +32 -23
  68. package/src/components/order-view/flags-action-modal/TextSection.tsx +9 -6
  69. package/src/components/order-view/flags-action-modal/index.tsx +54 -67
  70. package/src/components/order-view/general-information/dropdowns/Print.tsx +136 -70
  71. package/src/components/order-view/generic-table/AuditLogs.tsx +5 -4
  72. package/src/components/order-view/index.tsx +9 -42
  73. package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +20 -18
  74. package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -10
  75. package/src/components/order-view/notes/logs/index.tsx +1 -1
  76. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +5 -7
  77. package/src/components/order-view/notification/FlagTemplate.tsx +8 -8
  78. package/src/components/order-view/notification/OrderTemplate.tsx +169 -175
  79. package/src/components/order-view/notification/ReminderTemplate.tsx +23 -14
  80. package/src/components/order-view/notification/Tabs.tsx +15 -14
  81. package/src/components/order-view/notification/index.tsx +164 -92
  82. package/src/components/order-view/order-actions/actions/add-resources/index.tsx +19 -29
  83. package/src/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.tsx +345 -0
  84. package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -71
  85. package/src/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.tsx +95 -32
  86. package/src/components/order-view/order-actions/actions/charge-log/index.tsx +395 -0
  87. package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +1 -1
  88. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +34 -17
  89. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +2 -3
  90. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +2 -3
  91. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +2 -3
  92. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +39 -25
  93. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +1 -1
  94. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +4 -2
  95. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +1 -1
  96. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +254 -66
  97. package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +1 -1
  98. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +13 -9
  99. package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +1 -1
  100. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +213 -117
  101. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +97 -152
  102. package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +30 -87
  103. package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +77 -83
  104. package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +57 -65
  105. package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +10 -16
  106. package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +21 -4
  107. package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +39 -11
  108. package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +79 -8
  109. package/src/components/order-view/order-actions/actions/send-email/SendEmailModal.tsx +114 -17
  110. package/src/components/order-view/order-actions/actions/send-sms/SendSmsModal.tsx +115 -7
  111. package/src/components/order-view/order-actions/actions/split-order/index.tsx +14 -4
  112. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +176 -87
  113. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.tsx +352 -0
  114. package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +35 -59
  115. package/src/components/order-view/order-actions/index.tsx +237 -22
  116. package/src/components/order-view/order-actions/store.ts +50 -48
  117. package/src/components/order-view/order-actions/types.ts +40 -65
  118. package/src/components/order-view/order-actions/utils.ts +15 -8
  119. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +2 -1
  120. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +80 -39
  121. package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +10 -14
  122. package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +10 -1
  123. package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +2 -1
  124. package/src/components/order-view/products-info/expanded-content/index.tsx +3 -2
  125. package/src/components/order-view/products-info/index.tsx +14 -11
  126. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +26 -24
  127. package/src/components/order-view/store.ts +59 -2
  128. package/src/components/order-view/system-event-logs/columns/Date.tsx +4 -2
  129. package/src/components/order-view/system-event-logs/columns/Event.tsx +9 -9
  130. package/src/components/order-view/system-event-logs/columns/Note.tsx +1 -1
  131. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +25 -25
  132. package/src/components/order-view/types.ts +13 -0
  133. package/src/components/order-view/utils.ts +4 -0
  134. package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +183 -12
  135. package/src/components/order-view/view-reminder/ViewReminder.tsx +234 -143
  136. package/src/components/order-view/view-reminder/reminder-styles.tsx +14 -8
  137. package/src/components/store.ts +6 -0
  138. package/src/index.tsx +28 -18
@@ -0,0 +1,352 @@
1
+ import React from 'react';
2
+ import { useCancelOrderProducts, useOrderStaticData } from '../../../store';
3
+ import { useLoading } from '../../../../order-daily-overview/store/store';
4
+ import { Empty, Select, Skeleton } from 'antd';
5
+ import { CancelOrderProductsType } from '../../../types';
6
+ import OrderActionsDropdown from '../../Dropdown';
7
+ import styled from 'styled-components';
8
+ import { EmptyDataContainer } from '../confirm-order/tables/ReminderStyles';
9
+ import DeliverProductIcon from '../../../../../assets/icons/DeliverProductIcon';
10
+ import ReturnProductIcon from '../../../../../assets/icons/ReturnProductIcon';
11
+
12
+ const deliverTypeOptions = [
13
+ {
14
+ label: 'Deliver',
15
+ value: 'deliver',
16
+ icon: <DeliverProductIcon />,
17
+ },
18
+ {
19
+ label: 'Return',
20
+ value: 'return',
21
+ icon: <ReturnProductIcon />,
22
+ },
23
+ ];
24
+
25
+ const collectTypeOptions = [
26
+ {
27
+ label: 'Return',
28
+ value: 'return',
29
+ icon: <ReturnProductIcon />,
30
+ },
31
+ ];
32
+
33
+ const UnCancelOrderTable = () => {
34
+ const [
35
+ cancelOrderProducts,
36
+ setCancelOrderProducts,
37
+ ] = useCancelOrderProducts();
38
+
39
+ const [loading] = useLoading();
40
+ const [orderStaticData] = useOrderStaticData();
41
+
42
+ if (!cancelOrderProducts?.length) {
43
+ return null;
44
+ }
45
+
46
+ const returnReasonsOptions = orderStaticData?.return_reasons?.map(
47
+ (option: any) => ({
48
+ label: option?.reason,
49
+ value: option?.reason,
50
+ })
51
+ );
52
+
53
+ const returnActionOptions = orderStaticData?.order_product_return_action?.map(
54
+ (option: any) => ({
55
+ label: option?.value,
56
+ value: option?.value,
57
+ })
58
+ );
59
+
60
+ const onChange = (
61
+ selectedVal: string,
62
+ id: number,
63
+ type: keyof CancelOrderProductsType
64
+ ) => {
65
+ console.log(selectedVal, id, type);
66
+ const updatedList = cancelOrderProducts?.map(
67
+ (item: CancelOrderProductsType) => {
68
+ const newItem =
69
+ item.order_product_id === id
70
+ ? {
71
+ ...item,
72
+ [type]: selectedVal,
73
+ }
74
+ : item;
75
+ return newItem;
76
+ }
77
+ );
78
+ setCancelOrderProducts(updatedList);
79
+ };
80
+
81
+ return (
82
+ <div>
83
+ <StyledTableWrapper>
84
+ <StyledTable className="scrollClass">
85
+ <thead>
86
+ <tr>
87
+ <th>Status</th>
88
+ <th>Original Type</th>
89
+ <th>Code</th>
90
+ <th>Description</th>
91
+ <th>SKU</th>
92
+ </tr>
93
+ </thead>
94
+ <tbody>
95
+ {loading ? (
96
+ <tr>
97
+ <td colSpan={5}>
98
+ <Skeleton active />
99
+ </td>
100
+ </tr>
101
+ ) : cancelOrderProducts?.length === 0 ? (
102
+ <tr>
103
+ <td className="emptyTd" colSpan={5}>
104
+ <EmptyDataContainer>
105
+ <Empty />
106
+ </EmptyDataContainer>
107
+ </td>
108
+ </tr>
109
+ ) : (
110
+ cancelOrderProducts?.map((product: CancelOrderProductsType) => {
111
+ const dropdownOptions =
112
+ product?.product_type === 'deliver'
113
+ ? deliverTypeOptions
114
+ : collectTypeOptions;
115
+
116
+ const isReturn = product?.action === 'return';
117
+
118
+ return (
119
+ <tr
120
+ key={product?.order_product_id}
121
+ style={{
122
+ boxShadow: '0px 1px 3px 0px rgba(16, 24, 40, 0.1)',
123
+ }}
124
+ >
125
+ <td colSpan={5}>
126
+ <table style={{ width: '100%' }}>
127
+ <tbody>
128
+ <tr>
129
+ <td style={{ width: '20%' }}>
130
+ <CustomSelectDropdown
131
+ options={dropdownOptions}
132
+ placeholder="Select"
133
+ onChange={(val: any) =>
134
+ onChange(
135
+ val,
136
+ product?.order_product_id!,
137
+ 'action'
138
+ )
139
+ }
140
+ prefix={
141
+ product?.action === 'deliver' ? (
142
+ <DeliverProductIcon />
143
+ ) : product?.action === 'return' ? (
144
+ <ReturnProductIcon />
145
+ ) : (
146
+ <></>
147
+ )
148
+ }
149
+ style={{ width: '100%' }}
150
+ // popupClassName={'dropDownStyle'}
151
+ // selectWrapperClass={'rounded'}
152
+ value={dropdownOptions?.filter(
153
+ (item: any) => item?.value === product?.action
154
+ )}
155
+ optionRender={(option: any) => (
156
+ <div
157
+ style={{
158
+ display: 'flex',
159
+ gap: '8px',
160
+ alignItems: 'center',
161
+ }}
162
+ >
163
+ <span
164
+ style={{ display: 'flex' }}
165
+ aria-label={option.data.label}
166
+ >
167
+ {option.data.icon}
168
+ </span>
169
+ <span style={{ color: '#8D8F90' }}>
170
+ {option.data.label}
171
+ </span>
172
+ </div>
173
+ )}
174
+ />
175
+ </td>
176
+ <td style={{ width: '20%' }}>
177
+ {product?.previous_product_type === null
178
+ ? 'N/A'
179
+ : product?.previous_product_type}
180
+ </td>
181
+ <td style={{ width: '20%' }}>{product?.code}</td>
182
+ <td style={{ width: '20%' }}>
183
+ {product?.description}
184
+ </td>
185
+ <td style={{ width: '20%' }}>{product?.sku}</td>
186
+ </tr>
187
+
188
+ {isReturn && (
189
+ <tr>
190
+ <td colSpan={5}>
191
+ <ReturnRowWrapper>
192
+ <StyledDropdown
193
+ label="Return Action"
194
+ required
195
+ placeholder="Select action"
196
+ options={returnActionOptions}
197
+ onSelect={(val: any) =>
198
+ onChange(
199
+ val,
200
+ product?.order_product_id!,
201
+ 'return_action'
202
+ )
203
+ }
204
+ value={returnActionOptions?.filter(
205
+ (option: any) =>
206
+ option.value === product?.return_action
207
+ )}
208
+ />
209
+ <StyledDropdown
210
+ label="Return Reason"
211
+ required
212
+ placeholder="Select reason"
213
+ options={returnReasonsOptions}
214
+ onSelect={(val: any) =>
215
+ onChange(
216
+ val,
217
+ product?.order_product_id!,
218
+ 'return_reason'
219
+ )
220
+ }
221
+ value={returnReasonsOptions?.filter(
222
+ (option: any) =>
223
+ option.value === product?.return_reason
224
+ )}
225
+ />
226
+ </ReturnRowWrapper>
227
+ </td>
228
+ </tr>
229
+ )}
230
+ </tbody>
231
+ </table>
232
+ </td>
233
+ </tr>
234
+ );
235
+ })
236
+ )}
237
+ </tbody>
238
+ </StyledTable>
239
+ </StyledTableWrapper>
240
+ </div>
241
+ );
242
+ };
243
+
244
+ const CustomSelectDropdown: any = styled(Select)`
245
+ .ant-select-selector {
246
+ border-radius: 25px !important;
247
+ /* border: none !important; */
248
+ min-width: 100px;
249
+ padding: 0 10px;
250
+ display: flex;
251
+ gap: 8px;
252
+ align-items: center !important;
253
+
254
+ .ant-select-prefix {
255
+ margin-top: 4px;
256
+ }
257
+ }
258
+ .ant-select-selection-item {
259
+ font-weight: 400;
260
+ font-size: 13px;
261
+ }
262
+ `;
263
+
264
+ export const StyledTableWrapper = styled.div`
265
+ width: 100%;
266
+ overflow-x: auto;
267
+ background-color: #fff;
268
+ border-radius: 12px;
269
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
270
+ padding: 16px;
271
+ `;
272
+
273
+ const StyledDropdown = styled(OrderActionsDropdown)`
274
+ flex: 1;
275
+ `;
276
+
277
+ export const StyledTable = styled.table`
278
+ width: 100%;
279
+ font-size: 14px;
280
+ color: #333;
281
+ border-spacing: 0 10px;
282
+
283
+ th,
284
+ td {
285
+ padding: 12px 16px;
286
+ background: #fff;
287
+ }
288
+
289
+ th {
290
+ background: #f0f2f2;
291
+
292
+ &:first-child {
293
+ border-top-left-radius: 40px;
294
+ border-bottom-left-radius: 40px;
295
+ }
296
+
297
+ &:last-child {
298
+ border-top-right-radius: 40px;
299
+ border-bottom-right-radius: 40px;
300
+ }
301
+ }
302
+
303
+ // This affects ONLY top-level rows
304
+ > tbody > tr {
305
+ background: #fff;
306
+ border-radius: 40px;
307
+ box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1);
308
+ }
309
+
310
+ // Round the outer row's corners only on first/last td
311
+ > tbody > tr > td:first-child {
312
+ border-top-left-radius: 40px;
313
+ border-bottom-left-radius: 40px;
314
+ }
315
+
316
+ > tbody > tr > td:last-child {
317
+ border-top-right-radius: 40px;
318
+ border-bottom-right-radius: 40px;
319
+ }
320
+
321
+ .scrollClass {
322
+ overflow-x: auto;
323
+ }
324
+
325
+ .emptyTd {
326
+ text-align: center;
327
+ padding: 40px 0;
328
+ color: #999;
329
+ background: transparent;
330
+ box-shadow: none;
331
+ }
332
+
333
+ td table {
334
+ border-spacing: 0;
335
+ width: 100%;
336
+ }
337
+
338
+ td table td {
339
+ background: transparent;
340
+ padding: 8px 12px;
341
+ }
342
+ `;
343
+
344
+ const ReturnRowWrapper = styled.div`
345
+ display: flex;
346
+ flex-direction: row;
347
+ gap: 12px;
348
+ padding: 0 12px;
349
+ width: 100%;
350
+ `;
351
+
352
+ export default UnCancelOrderTable;
@@ -1,84 +1,60 @@
1
1
  import {
2
2
  CancelAndCompleteAction,
3
3
  CancelationModal,
4
- useApiHook,
4
+ useAxios,
5
5
  } from '@bjsdistribution/dms-component-library';
6
- import React, { useEffect } from 'react';
6
+ import React from 'react';
7
7
  import styled from 'styled-components';
8
- import {
9
- useCurrentAction,
10
- useOrderDetails,
11
- useOrderId,
12
- usePrevOrderDetails,
13
- } from '../../../store';
14
- import { ApiResponse, OrdersType } from '../../../types';
15
- import { useLoading } from '../../../../order-daily-overview/store/store';
8
+ import { useCurrentAction, useOrderId } from '../../../store';
9
+ import { ApiResponse } from '../../../types';
16
10
  import { notification } from 'antd';
11
+ import { useClientPortal } from '../../../../store';
12
+ interface IProps {
13
+ callOrderAlertsApi: any;
14
+ callOrdersApi?: any;
15
+ callUnresolvedTaskApi?: any;
16
+ }
17
17
 
18
- const UnholdOrder = () => {
18
+ const UnholdOrder = (props: IProps) => {
19
19
  const [orderId] = useOrderId();
20
20
  const [, setCurrentAction] = useCurrentAction();
21
- const [, setOrderDetails] = useOrderDetails();
22
- const [, setPrevOrderDetails] = usePrevOrderDetails();
23
- const [, setLoading] = useLoading();
21
+ const [isClientPortal] = useClientPortal();
24
22
 
25
- const {
26
- data: response,
27
- setShouldPerformAction: setPerformAction,
28
- } = useApiHook<{
23
+ const { fetchData: fetchUnholdData } = useAxios<{
29
24
  data: ApiResponse[];
30
25
  }>({
26
+ // remove the date from the params as requested by backend
31
27
  endpoint: `orders/${orderId}/unhold/`,
32
28
  method: 'POST',
33
- performAction: false,
34
- });
35
-
36
- const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
37
- data: OrdersType[];
38
- }>({
39
- endpoint: `orders/${orderId}`,
40
- method: 'GET',
41
- performAction: false,
42
29
  });
43
30
 
44
- useEffect(() => {
45
- setLoading(loading);
46
- if (fetchedData && fetchedData.data) {
47
- const requiredData = fetchedData?.data;
48
- setOrderDetails(requiredData[0]);
49
- setPrevOrderDetails(requiredData[0]);
50
- setCurrentAction(undefined);
51
- }
52
- if (
53
- (fetchedData && fetchedData?.data === null) ||
54
- fetchedData?.data?.length === 0
55
- ) {
56
- setCurrentAction(undefined);
57
- }
58
- }, [loading]);
59
-
60
- useEffect(() => {
61
- if (response) {
62
- //@ts-ignore
63
- if (response?.data && response?.code === 200) {
64
- setShouldPerformAction(true);
65
- } else {
31
+ const saveButton = async () => {
32
+ if (orderId) {
33
+ const response = (await fetchUnholdData()) as {
34
+ code: number | null;
35
+ error?: string | null | undefined;
36
+ [key: string]: any;
37
+ };
38
+ if (response?.code === 200) {
39
+ notification.success({
40
+ message: 'Success',
41
+ description: `${response.message}`,
42
+ });
43
+ // call orders api to update status
44
+ if (isClientPortal) {
45
+ await props?.callUnresolvedTaskApi();
46
+ }
47
+ await props?.callOrderAlertsApi();
48
+ await props?.callOrdersApi();
49
+ }
50
+ if (response?.code !== 200) {
66
51
  notification.error({
67
52
  message: 'Error',
68
- description:
69
- //@ts-ignore
70
- response?.error_traceback ||
71
- 'An error has occurred. Please try again later.',
53
+ description: `${response.error}`,
72
54
  });
73
55
  setCurrentAction(undefined);
74
56
  }
75
57
  }
76
- }, [response]);
77
-
78
- const saveButton = () => {
79
- if (orderId) {
80
- setPerformAction(true);
81
- }
82
58
  };
83
59
 
84
60
  const closeModal = () => {