@bjsdistribution/dms-client-return 0.1.7-prod → 0.1.8-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 (83) hide show
  1. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  2. package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
  3. package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
  4. package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
  5. package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
  6. package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
  7. package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
  8. package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
  9. package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
  10. package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
  11. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
  12. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
  13. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
  14. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
  15. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
  16. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
  17. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
  18. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
  19. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
  20. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
  21. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
  22. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
  23. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
  24. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
  25. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
  26. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
  27. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
  28. package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
  29. package/dist/components/order-view/products-info/expanded-content/index.d.ts +4 -1
  30. package/dist/components/order-view/return-client-products/ProductTable.d.ts +4 -1
  31. package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +4 -1
  32. package/dist/components/order-view/store.d.ts +14 -2
  33. package/dist/components/order-view/types.d.ts +49 -1
  34. package/dist/components/order-view/utils.d.ts +3 -0
  35. package/dist/dms-client-return.cjs.development.js +2636 -335
  36. package/dist/dms-client-return.cjs.development.js.map +1 -1
  37. package/dist/dms-client-return.cjs.production.min.js +1 -1
  38. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  39. package/dist/dms-client-return.esm.js +2700 -399
  40. package/dist/dms-client-return.esm.js.map +1 -1
  41. package/package.json +5 -3
  42. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +43 -15
  43. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +24 -11
  44. package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
  45. package/src/components/order-view/index.tsx +29 -0
  46. package/src/components/order-view/notes/AddNote.tsx +14 -34
  47. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
  48. package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
  49. package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +620 -0
  50. package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
  51. package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
  52. package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
  53. package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
  54. package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
  55. package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
  56. package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
  57. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
  58. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
  59. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
  60. package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
  61. package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
  62. package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
  63. package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
  64. package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
  65. package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +201 -0
  66. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
  67. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
  68. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
  69. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
  70. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
  71. package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
  72. package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
  73. package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
  74. package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
  75. package/src/components/order-view/order-actions/index.tsx +10 -0
  76. package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
  77. package/src/components/order-view/products-info/expanded-content/index.tsx +27 -11
  78. package/src/components/order-view/products-info/index.tsx +4 -4
  79. package/src/components/order-view/return-client-products/ProductTable.tsx +6 -2
  80. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +54 -15
  81. package/src/components/order-view/store.ts +106 -0
  82. package/src/components/order-view/types.ts +54 -1
  83. package/src/components/order-view/utils.ts +37 -0
@@ -0,0 +1,620 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
3
+ import {
4
+ useActiveTab,
5
+ useChargesState,
6
+ useCurrentAction,
7
+ useCustomerDetails,
8
+ useCustomerInfo,
9
+ useEscalationCategory,
10
+ useEscalationLevel,
11
+ useEscalationReason,
12
+ useFailureReason,
13
+ useGlobalEscData,
14
+ useGlobalStateHitAuditLog,
15
+ useGlobalStateHitOrder,
16
+ useNewStatus,
17
+ useOrderCancelReason,
18
+ useOrderCustomersList,
19
+ useOrderDetails,
20
+ useOrderHoldReason,
21
+ usePrevOrderDetails,
22
+ useProductDetails,
23
+ } from '../../../store';
24
+ import OrderCharges from './charges/order-charges';
25
+ import CollectionAddOns from './charges/collection-add-ons';
26
+ import DisposalCharge from './charges/disposal-charges';
27
+ import styled from 'styled-components';
28
+ import BaseCharges from './charges/base-charge';
29
+ import DeliveryAddOns from './charges/delivery-add-ons';
30
+ import AdhocSection from './charges/adhoc';
31
+ import OrderInfo from './order-info';
32
+ import {} from '../../store';
33
+ import ForceDebriefSelector from './Selector';
34
+ import {
35
+ Checkbox,
36
+ Label,
37
+ useApiHook,
38
+ useAxios,
39
+ } from '@bjsdistribution/dms-component-library';
40
+ import Escalation from './escalation';
41
+ import FDNotification from './notifications';
42
+
43
+ import { compareOrderDetailsStates, filterObject } from '../../../utils';
44
+ import { AdhocCharge, ApiResponse, OrderServiceType } from '../../../types';
45
+ import { notification } from 'antd';
46
+ import BaseChargeConfirmationModal from './BaseChargeConfirmationModal';
47
+ import { v4 as uuidv4 } from 'uuid';
48
+
49
+ interface IProps {
50
+ callOrdersApi: any;
51
+ callOrderStatusApi: any;
52
+ callOrderAlertsApi: any;
53
+ }
54
+
55
+ function ForceDebriefModal(props: IProps) {
56
+ const [customerInfo, setCustomerInfo] = useCustomerInfo();
57
+ const [allCustomers, setAllCustomers] = useOrderCustomersList();
58
+ const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
59
+ const [, setCurrentAction] = useCurrentAction();
60
+
61
+ const [activeTab, setActiveTab] = useActiveTab();
62
+ const handleSwitchChange = (newValue: any) => setActiveTab(newValue);
63
+ const [chargesState, setCharges] = useChargesState();
64
+ const [inputValue, setInputValue] = useState<Record<string, string>>({}); // only for UI purpose
65
+ const [staticData, setDebriefStaticData] = useState([]);
66
+ const [orderDetails, setOrderDetails] = useOrderDetails();
67
+ const [prevOrderDetails, setPrevOrderDetails] = usePrevOrderDetails();
68
+ const [isEscalationEnabled, setIsEscalationEnabled] = useState<boolean>(true);
69
+ const [newStatus, setNewStatus] = useNewStatus();
70
+ const [cancellationReason, setCancellationReason] = useOrderCancelReason();
71
+ const [orderHold, setOrderHold] = useOrderHoldReason();
72
+ const [failureReason, setFailureReason] = useFailureReason();
73
+ const [escalationCategory, setEscalationCategory] = useEscalationCategory();
74
+ const [escalationLevel, setEscalationLevel] = useEscalationLevel();
75
+ const [escalationReason, setEscalationReason] = useEscalationReason();
76
+ const [, setRecallOrders] = useGlobalStateHitOrder();
77
+ const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
78
+ const [, setGlobalEscData] = useGlobalEscData();
79
+
80
+ const [showAmountConfirmModal, setShowAmountConfirmModal] = useState<boolean>(
81
+ false
82
+ );
83
+
84
+ const [productdata] = useProductDetails();
85
+ const sortedProductData = productdata?.sort((a: any, b: any) => {
86
+ return a?.status === b?.status ? 0 : a?.status ? -1 : 1;
87
+ });
88
+
89
+ const isDeleted = Array.isArray(sortedProductData)
90
+ ? sortedProductData?.filter(item => item?.status === true)
91
+ : [];
92
+
93
+ //customers API
94
+ const [orderData] = useOrderDetails();
95
+ const customersData = orderData;
96
+ const id = customersData?.customer_id;
97
+
98
+ //Customers list API call
99
+ const {
100
+ data: fetchCustomerData,
101
+ loading: customerLoading,
102
+ fetchData,
103
+ } = useAxios<{
104
+ data: ApiResponse[];
105
+ }>({
106
+ endpoint: `/v1/customer/list`,
107
+ method: 'GET',
108
+ pagination: { is_pagination: false },
109
+ filters: [{ field: 'status', op: '=', value: '1' }],
110
+ });
111
+
112
+ useEffect(() => {
113
+ if (fetchCustomerData && fetchCustomerData?.data) {
114
+ const res = fetchCustomerData?.data;
115
+ setAllCustomers(res);
116
+ }
117
+ }, [fetchCustomerData, customerLoading]);
118
+
119
+ useEffect(() => {
120
+ fetchData();
121
+ }, []);
122
+
123
+ // For API Call
124
+ const [customerData, setCustomerData] = useCustomerDetails();
125
+ const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
126
+ data: ApiResponse[];
127
+ }>({
128
+ endpoint: `customers/${id}`,
129
+ method: 'GET',
130
+ performAction: false,
131
+ });
132
+
133
+ useEffect(() => {
134
+ if (id) {
135
+ setShouldPerformAction(true);
136
+ }
137
+ }, [id]);
138
+
139
+ useEffect(() => {
140
+ if (fetchedData && fetchedData?.data) {
141
+ const requiredData = fetchedData?.data;
142
+ setCustomerData(requiredData);
143
+ }
144
+ }, [fetchedData, loading]);
145
+ const selectedCustomer = allCustomers?.find(
146
+ (customer: any) => customer?.id === customerData?.id
147
+ );
148
+
149
+ const adhocChargesFields: AdhocCharge[] = Array.from({ length: 9 }, () => ({
150
+ id: uuidv4(),
151
+ adhoc_charges_description: '',
152
+ adhoc_charges: 0,
153
+ }));
154
+
155
+ const {
156
+ fetchData: fetchAllDebriefStaticData,
157
+ data: debriefStaticData,
158
+ loading: debriefLoading,
159
+ } = useAxios<{
160
+ data: any;
161
+ }>({
162
+ endpoint: `/finance/debrief/getData/all/`,
163
+ method: 'GET',
164
+ });
165
+
166
+ useEffect(() => {
167
+ setCharges(prev => ({
168
+ ...prev,
169
+ adhoc_charges: adhocChargesFields,
170
+ }));
171
+
172
+ // call debrief static api for getting base charges type
173
+ fetchAllDebriefStaticData();
174
+ }, []);
175
+
176
+ useEffect(() => {
177
+ if (debriefStaticData?.data) {
178
+ setDebriefStaticData(debriefStaticData?.data[0]);
179
+ }
180
+ }, [debriefLoading]);
181
+
182
+ const { fetchData: callUpdateOrderAPI } = useAxios<{
183
+ data: ApiResponse[];
184
+ }>({
185
+ endpoint: `/orders/update/`,
186
+ method: 'PUT',
187
+ });
188
+
189
+ const { fetchData: callForceDebriefApi } = useAxios<{
190
+ data: ApiResponse[];
191
+ }>({
192
+ endpoint: `/invoices/force-debrief/`,
193
+ method: 'POST',
194
+ });
195
+
196
+ const { fetchData: createEscalation } = useAxios<{
197
+ data: any;
198
+ }>({
199
+ endpoint: `/orders/escalations/create/`,
200
+ method: 'POST',
201
+ });
202
+
203
+ const initialValues = () => {
204
+ setOrderDetails(prevOrderDetails);
205
+ setNewStatus('');
206
+ setCancellationReason('');
207
+ setOrderHold('');
208
+ setFailureReason('');
209
+ setEscalationCategory('');
210
+ setEscalationLevel('');
211
+ setEscalationReason('');
212
+ setActiveTab('success');
213
+ };
214
+
215
+ const closeModal = () => {
216
+ initialValues();
217
+ setCurrentAction(undefined);
218
+ };
219
+
220
+ const isDifferent = () => {
221
+ const keysToRemovefromOrders = [
222
+ 'order_locked',
223
+ 'order_communications',
224
+ 'updated_at',
225
+ 'updated_by',
226
+ 'order_services',
227
+ ];
228
+ const filteredOrderDetails = filterObject(
229
+ orderDetails,
230
+ keysToRemovefromOrders
231
+ );
232
+ const filteredPrevOrderDetails = filterObject(
233
+ prevOrderDetails,
234
+ keysToRemovefromOrders
235
+ );
236
+
237
+ const newOrderServices =
238
+ orderDetails?.order_services?.length > 0 &&
239
+ orderDetails?.order_services?.sort(
240
+ (a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
241
+ );
242
+
243
+ const prevOrderServices =
244
+ prevOrderDetails?.order_services?.length > 0 &&
245
+ prevOrderDetails?.order_services.sort(
246
+ (a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
247
+ );
248
+
249
+ const newOrderServicesSorted = JSON.stringify(newOrderServices);
250
+ const prevOrderServicesSorted = JSON.stringify(prevOrderServices);
251
+ const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
252
+ const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
253
+ const isSame =
254
+ orderDetailsSorted === prevOrderDetailsSorted &&
255
+ newOrderServicesSorted === prevOrderServicesSorted;
256
+ return !isSame;
257
+ };
258
+
259
+ const debriefchargesApi = async (finalPayload: any, failurePayload: any) => {
260
+ try {
261
+ const responseForceDebrief = (await callForceDebriefApi({
262
+ payload: {
263
+ debrief_data: finalPayload,
264
+ ...(activeTab === 'failure'
265
+ ? { failure_data: failurePayload }
266
+ : { failure_data: {} }),
267
+ },
268
+ })) as {
269
+ code: number | null;
270
+ error?: string | null | undefined;
271
+ [key: string]: any;
272
+ };
273
+ if (responseForceDebrief.code === 200) {
274
+ notification.success({
275
+ message: 'Success',
276
+ description: `${responseForceDebrief?.message}`,
277
+ });
278
+ }
279
+ } catch (err) {}
280
+ };
281
+
282
+ const ordersUpdateApi = async () => {
283
+ const ordersApiPayload = compareOrderDetailsStates(
284
+ prevOrderDetails,
285
+ orderDetails
286
+ );
287
+
288
+ try {
289
+ let response = (await callUpdateOrderAPI({
290
+ payload: [ordersApiPayload],
291
+ })) as {
292
+ code: number | null;
293
+ error?: string | null | undefined;
294
+ [key: string]: any;
295
+ };
296
+ if (response.code === 200 && response?.data?.length > 0) {
297
+ notification.success({
298
+ message: 'Success',
299
+ description: `${response?.message}`,
300
+ });
301
+ setOrderDetails(response?.data[0]);
302
+ setPrevOrderDetails(response?.data[0]);
303
+ setCustomerInfo({
304
+ recipient_name: response?.data[0]?.order_recipient?.recipient_name,
305
+ postcode: response?.data[0]?.order_recipient?.postcode,
306
+ });
307
+ await setRecallOrders(true);
308
+ }
309
+ } catch (err) {
310
+ setOrderDetails(prevOrderDetails);
311
+ }
312
+ };
313
+
314
+ const escalationCreateApi = async (escalationPayload: any) => {
315
+ try {
316
+ const apiResponse = (await createEscalation({
317
+ payload: escalationPayload,
318
+ })) as {
319
+ code: number | null;
320
+ error?: string | null | undefined;
321
+ [key: string]: any;
322
+ };
323
+ if (apiResponse?.code === 200) {
324
+ notification.success({
325
+ message: 'Success',
326
+ description: `${apiResponse?.message}`,
327
+ });
328
+
329
+ setGlobalEscData(apiResponse?.data);
330
+ }
331
+ } catch (err) {}
332
+ };
333
+
334
+ const onSubmit = async () => {
335
+ setRecallOrders(false);
336
+ const ordersPayload = {
337
+ consignment: orderDetails?.consignment,
338
+ order_number: orderDetails?.order_number,
339
+ customer_id: customerData?.id,
340
+ customer_name: customerData?.customer_name,
341
+ client_name: selectedCustomer?.client_name,
342
+ recipient_name: orderDetails?.order_recipient?.recipient_name,
343
+ order_id: orderDetails?.id,
344
+ order_type: orderDetails?.order_type?.type,
345
+ legacy_order_id: orderDetails?.gsit_order_id,
346
+ postcode: orderDetails?.order_recipient?.postcode,
347
+ ...(activeTab === 'failure' && { failure_new_status: newStatus }),
348
+ };
349
+ const adhocCharges = chargesState?.adhoc_charges
350
+ ?.filter(
351
+ item =>
352
+ !(item.adhoc_charges === 0 && item.adhoc_charges_description === '')
353
+ )
354
+ .map(({ adhoc_charges_description, adhoc_charges }) => ({
355
+ adhoc_charges_description,
356
+ adhoc_charges,
357
+ }));
358
+ const chargesPayload: any = { ...chargesState };
359
+ chargesPayload.adhoc_charges = adhocCharges;
360
+ chargesPayload.debrief_status = activeTab;
361
+ if (activeTab === 'success') {
362
+ delete chargesPayload.new_order_status;
363
+ }
364
+
365
+ const failurePayload = {
366
+ failure_reason_id: failureReason?.id,
367
+ ...(newStatus === 'Cancelled' && {
368
+ cancelled_reason_id: cancellationReason?.value,
369
+ }),
370
+ ...(newStatus === 'On Hold' && { hold_reason_id: orderHold?.value }),
371
+ failure_order_status: newStatus,
372
+ status: activeTab,
373
+ };
374
+
375
+ const finalPayload = {
376
+ ...ordersPayload,
377
+ status: activeTab,
378
+ charges: [chargesPayload],
379
+ ...(activeTab === 'failure' && { failureData: failurePayload }),
380
+ }; // check adhoc charges if 0 and description is empty then
381
+
382
+ // APPLY ALL VALIDATIONS HERE BEFORE CALLING ANY API
383
+
384
+ if (activeTab === 'failure') {
385
+ if (!failureReason?.id) {
386
+ notification.error({
387
+ message: 'Error',
388
+ description: 'Failure reason is mandatory',
389
+ });
390
+ return;
391
+ }
392
+
393
+ if (newStatus?.length === 0) {
394
+ notification.error({
395
+ message: 'Error',
396
+ description: 'New status is mandatory',
397
+ });
398
+ return;
399
+ }
400
+
401
+ if (newStatus === 'On Hold' && orderHold?.length === 0) {
402
+ notification.error({
403
+ message: 'Error',
404
+ description: 'Hold reason is mandatory',
405
+ });
406
+ return;
407
+ }
408
+
409
+ if (newStatus === 'Cancelled' && cancellationReason?.length === 0) {
410
+ notification.error({
411
+ message: 'Error',
412
+ description: 'Cancel reason is mandatory',
413
+ });
414
+ return;
415
+ }
416
+ }
417
+
418
+ if (isDifferent()) {
419
+ await ordersUpdateApi();
420
+ }
421
+
422
+ if (activeTab === 'failure' && isEscalationEnabled) {
423
+ const escalationPayload = [
424
+ {
425
+ order_id: orderDetails?.id,
426
+ escalation_reason_id: escalationReason?.value,
427
+ escalation_category_id: escalationCategory?.value,
428
+ escalation_level_id: escalationLevel?.value,
429
+ is_deleted: false,
430
+ route_id: orderDetails?.order_routes?.route_id,
431
+ },
432
+ ];
433
+
434
+ await escalationCreateApi(escalationPayload);
435
+ }
436
+
437
+ await debriefchargesApi(finalPayload, failurePayload);
438
+ await setRecallAuditLog(true);
439
+ // call status api and alerts api
440
+ initialValues();
441
+ await props?.callOrderStatusApi();
442
+ await props?.callOrderAlertsApi();
443
+ await props?.callOrdersApi();
444
+ // closeModal();
445
+ };
446
+
447
+ const onForceDebrief = () => {
448
+ if (chargesState?.base_charge > 200) {
449
+ setShowAmountConfirmModal(true);
450
+ } else {
451
+ onSubmit();
452
+ }
453
+ };
454
+
455
+ return (
456
+ <OrderActionModal
457
+ headerTitle="Order Debrief"
458
+ onCloseHeader={closeModal}
459
+ infoText={infoText}
460
+ onSubmit={onForceDebrief}
461
+ submitBtnTitle={'Complete Order'}
462
+ // isSubmitDisabled={true}
463
+ maxWidth="95vw"
464
+ headerActions={
465
+ <ForceDebriefSelector onSwitchChange={handleSwitchChange} />
466
+ }
467
+ >
468
+ <MainContainer>
469
+ <FDNotification />
470
+ <ContentContainer>
471
+ <OrderInfo />
472
+ </ContentContainer>
473
+ <ContentContainer>
474
+ <Container>
475
+ <Label
476
+ label="Delivery Instructions"
477
+ htmlFor="deliveryInstruction"
478
+ />
479
+ <Text>{orderDetails?.delivery_instructions || 'N/A'}</Text>
480
+ </Container>
481
+
482
+ <Container>
483
+ <Label label="Other Instructions" htmlFor="otherInstruction" />
484
+ <Text>{orderDetails?.other_instructions || 'N/A'}</Text>
485
+ </Container>
486
+ </ContentContainer>
487
+ {/* ORDER-PRODUCT SECTION */}
488
+ {isDeleted?.length > 0 && (
489
+ <ProductDiv>
490
+ <Container>
491
+ {isDeleted?.map((item, index) => (
492
+ <ProductContainer key={index}>
493
+ <Status>{'*'}</Status>
494
+ <Status>{item?.status_value || 'N/A'}</Status>
495
+ <Status>{item?.order_product_type?.type || 'N/A'}</Status>
496
+ <Status>{item?.sku || 'N/A'}</Status>
497
+ <Status>{`Part 1 of 1`}</Status>
498
+ <Status>{'Weight' + ':' + item?.weight || 'N/A'}</Status>
499
+ <Status>{'Cube' + ':' + item?.cube || 'N/A'}</Status>
500
+ </ProductContainer>
501
+ ))}
502
+ </Container>
503
+ </ProductDiv>
504
+ )}
505
+
506
+ {/* CHARGES SECTION */}
507
+ <ContentContainer>
508
+ <ContainerInner>
509
+ <BaseCharges
510
+ inputValue={inputValue}
511
+ setInputValue={setInputValue}
512
+ staticData={staticData}
513
+ />
514
+ <DeliveryAddOns
515
+ inputValue={inputValue}
516
+ setInputValue={setInputValue}
517
+ />
518
+ </ContainerInner>
519
+ <ContainerInner>
520
+ <CollectionAddOns
521
+ inputValue={inputValue}
522
+ setInputValue={setInputValue}
523
+ />
524
+ <DisposalCharge
525
+ inputValue={inputValue}
526
+ setInputValue={setInputValue}
527
+ />
528
+ </ContainerInner>
529
+ <OrderCharges inputValue={inputValue} setInputValue={setInputValue} />
530
+ <AdhocSection />
531
+ </ContentContainer>
532
+ {activeTab === 'failure' && (
533
+ <ContentContainer style={{ flexDirection: 'column', gap: '10px' }}>
534
+ <div style={{ display: 'flex', gap: '10px' }}>
535
+ Escalation
536
+ <Checkbox
537
+ checked={isEscalationEnabled}
538
+ onChange={event => setIsEscalationEnabled(event.target.checked)}
539
+ />
540
+ </div>
541
+ <Escalation />
542
+ </ContentContainer>
543
+ )}
544
+ </MainContainer>
545
+ {showAmountConfirmModal && (
546
+ <BaseChargeConfirmationModal
547
+ setConfirmationModal={setShowAmountConfirmModal}
548
+ onProceed={onSubmit}
549
+ />
550
+ )}
551
+ </OrderActionModal>
552
+ );
553
+ }
554
+
555
+ const Status = styled.span`
556
+ font-family: 'Roboto', sans-serif;
557
+ font-size: 14px;
558
+ font-weight: 400;
559
+ text-transform: capitalize;
560
+ color: #3a3630;
561
+ `;
562
+
563
+ const ProductContainer = styled.div`
564
+ display: flex;
565
+ flex-wrap: wrap;
566
+ gap: 16px;
567
+ `;
568
+
569
+ const MainContainer = styled.div`
570
+ padding: 10px;
571
+ display: flex;
572
+ flex-direction: column;
573
+ gap: 10px;
574
+ `;
575
+
576
+ const ContainerInner = styled.div`
577
+ display: flex;
578
+ flex-direction: column;
579
+ gap: 16px;
580
+ `;
581
+
582
+ const Container = styled.div`
583
+ width: 100%;
584
+ `;
585
+
586
+ const Text = styled.div`
587
+ color: #363a30;
588
+ font-size: 14px;
589
+ white-space: break-spaces;
590
+ `;
591
+
592
+ export const ContentContainer = styled.div`
593
+ display: flex;
594
+ padding: 12px;
595
+ flex-direction: row;
596
+ align-items: flex-start;
597
+ gap: 40px;
598
+ flex: 1 0 0;
599
+ border-radius: 15px;
600
+ background: #f8fafc;
601
+ width: 100%;
602
+ white-space: nowrap;
603
+ `;
604
+
605
+ export const ProductDiv = styled.div`
606
+ display: flex;
607
+ padding: 12px;
608
+ flex-direction: row;
609
+ align-items: flex-start;
610
+ gap: 40px;
611
+ flex: 1 0 0;
612
+ border-radius: 15px;
613
+ background: #f8fafc;
614
+ width: 100%;
615
+ white-space: nowrap;
616
+ min-height: 60px;
617
+ overflow: scroll;
618
+ max-height: 150px;
619
+ `;
620
+ export default React.memo(ForceDebriefModal);
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import SwitchSelector from 'react-switch-selector';
4
+ import { notification } from 'antd';
5
+
6
+ interface ForceDebriefSelectorProps {
7
+ onSwitchChange: (newValue: string) => void;
8
+ }
9
+
10
+ export const Options = [
11
+ {
12
+ label: 'Success',
13
+ value: 'success',
14
+ selectedBackgroundColor: '#57DB7A',
15
+ },
16
+ {
17
+ label: 'Failure',
18
+ value: 'failure',
19
+ selectedBackgroundColor: '#E95252',
20
+ },
21
+ ];
22
+
23
+ const ForceDebriefSelector: React.FC<ForceDebriefSelectorProps> = ({
24
+ onSwitchChange,
25
+ }) => {
26
+ const initialSelectedIndex = Options?.findIndex(
27
+ ({ value }) => value === 'success'
28
+ );
29
+
30
+ const handleSwitchChange = (selectedOptionValue: unknown) => {
31
+ if (typeof selectedOptionValue === 'string') {
32
+ onSwitchChange(selectedOptionValue);
33
+ } else {
34
+ notification.error({
35
+ message: 'Error',
36
+ description:
37
+ typeof selectedOptionValue ||
38
+ 'Unexpected type for selectedOptionValue:',
39
+ });
40
+ }
41
+ };
42
+
43
+ return (
44
+ <StyledSwitch>
45
+ <SwitchSelector
46
+ onChange={handleSwitchChange}
47
+ options={Options}
48
+ initialSelectedIndex={initialSelectedIndex}
49
+ backgroundColor={'#cbc8c2'}
50
+ fontColor={'#f5f6fa'}
51
+ optionBorderRadius={30}
52
+ />
53
+ </StyledSwitch>
54
+ );
55
+ };
56
+
57
+ const StyledSwitch = styled.div`
58
+ width: 25%;
59
+ height: 40px;
60
+ .react-switch-selector-wrapper {
61
+ background: #777777;
62
+ }
63
+ `;
64
+
65
+ export default ForceDebriefSelector;