@bjsdistribution/dms-client-return 0.1.28-prod → 0.1.29-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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.28-prod",
2
+ "version": "0.1.29-prod",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -11,7 +11,9 @@ function AuditLogs() {
11
11
  }
12
12
 
13
13
  const Container = styled.div`
14
- height: 550px; /* Set height to limit container size */
14
+ height: 500px;
15
+ min-height: 200px;
16
+ max-height: 500px;
15
17
  overflow: auto; /* Enable scrolling */
16
18
  scrollbar-width: thin;
17
19
  `;
@@ -267,7 +267,15 @@ function ForceDebriefModal(props: IProps) {
267
267
  orderDetails
268
268
  );
269
269
 
270
- const serviceKeys = [
270
+ type ServiceKey =
271
+ | 'assemble'
272
+ | 'disassemble'
273
+ | 'unpack_items'
274
+ | 'collect_disposal'
275
+ | 'take_packaging_away'
276
+ | 'assembly_type';
277
+
278
+ const serviceKeys: ServiceKey[] = [
271
279
  'assemble',
272
280
  'disassemble',
273
281
  'unpack_items',
@@ -276,28 +284,21 @@ function ForceDebriefModal(props: IProps) {
276
284
  'assembly_type',
277
285
  ];
278
286
 
279
- let orderServicesPayload: Record<string, any> = {};
280
-
281
- const includesKey = serviceKeys.some(key => key in ordersApiPayload);
282
-
283
- if (includesKey) {
284
- for (const key of serviceKeys) {
285
- orderServicesPayload[key as keyof typeof ordersApiPayload] =
286
- key in ordersApiPayload
287
- ? ordersApiPayload[key as keyof typeof ordersApiPayload]
288
- : orderDetails[key as keyof OrdersType];
289
- delete ordersApiPayload[key as keyof typeof ordersApiPayload];
290
- if (
291
- orderServicesPayload?.assemble === false &&
292
- orderServicesPayload?.disassemble === false
293
- ) {
294
- orderServicesPayload.assembly_type = null;
295
- }
287
+ for (const key of serviceKeys) {
288
+ if (key in ordersApiPayload) {
289
+ (ordersApiPayload as Record<ServiceKey, any>)[key] =
290
+ ordersApiPayload[key as keyof typeof ordersApiPayload];
291
+ } else if (key in orderDetails) {
292
+ (ordersApiPayload as Record<ServiceKey, any>)[key] =
293
+ orderDetails[key as keyof OrdersType];
296
294
  }
297
295
  }
298
296
 
299
- if (Object.keys(orderServicesPayload).length > 0) {
300
- ordersApiPayload.order_services = [orderServicesPayload];
297
+ if (
298
+ ordersApiPayload?.assemble === false &&
299
+ ordersApiPayload?.disassemble === false
300
+ ) {
301
+ ordersApiPayload.assembly_type = null;
301
302
  }
302
303
 
303
304
  try {
@@ -11,6 +11,8 @@ import {
11
11
  useGlobalStateHitAuditLog,
12
12
  useGlobalStateHitOrder,
13
13
  useLiveRecalling,
14
+ useOrderAlertsData,
15
+ useStatusDetails,
14
16
  } from '../../../store';
15
17
  // import useUpdateOrder from '../../../hooks/useUpdateOrder';
16
18
  import { compareOrderDetailsStates, filterObject } from '../../../utils';
@@ -28,6 +30,24 @@ function OrderDetailsFooter() {
28
30
  const [, setRecallOrders] = useGlobalStateHitOrder();
29
31
  const [isClientPortal] = useClientPortal();
30
32
  const [, setRecalling] = useLiveRecalling();
33
+ const [, setOrderAlertsData] = useOrderAlertsData();
34
+ const [, setOrderStatus] = useStatusDetails();
35
+
36
+ // call alerts api
37
+ const { fetchData: callOrderAlertsApi } = useAxios<{
38
+ data: ApiResponse[];
39
+ }>({
40
+ endpoint: `v1/orders/alerts/?order_id=${orderDetails?.id}`,
41
+ method: 'GET',
42
+ });
43
+
44
+ //Order status api
45
+ const { fetchData: callOrderStatusApi } = useAxios<{
46
+ data: ApiResponse[];
47
+ }>({
48
+ endpoint: `/orders/get_live_status/${orderDetails?.id}`,
49
+ method: 'GET',
50
+ });
31
51
  //update order
32
52
  const { fetchData: callUpdateOrderAPI } = useAxios<{
33
53
  data: ApiResponse[];
@@ -38,12 +58,12 @@ function OrderDetailsFooter() {
38
58
 
39
59
  const errorFound = () => {
40
60
  const isError =
41
- errorState.w3wError.length > 0 ||
42
- errorState.emailError.length > 0 ||
43
- errorState.homeContactError.length > 0 ||
44
- errorState.workCOntanctError.length > 0 ||
45
- errorState.mobileError.length > 0 ||
46
- errorState.postCodeError.length > 0;
61
+ errorState?.w3wError?.length > 0 ||
62
+ errorState?.emailError?.length > 0 ||
63
+ errorState?.homeContactError?.length > 0 ||
64
+ errorState?.workCOntanctError?.length > 0 ||
65
+ errorState?.mobileError?.length > 0 ||
66
+ errorState?.postCodeError?.length > 0;
47
67
 
48
68
  return isError;
49
69
  };
@@ -76,7 +96,15 @@ function OrderDetailsFooter() {
76
96
  setRecalling(false);
77
97
  const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
78
98
 
79
- const serviceKeys = [
99
+ type ServiceKey =
100
+ | 'assemble'
101
+ | 'disassemble'
102
+ | 'unpack_items'
103
+ | 'collect_disposal'
104
+ | 'take_packaging_away'
105
+ | 'assembly_type';
106
+
107
+ const serviceKeys: ServiceKey[] = [
80
108
  'assemble',
81
109
  'disassemble',
82
110
  'unpack_items',
@@ -85,28 +113,18 @@ function OrderDetailsFooter() {
85
113
  'assembly_type',
86
114
  ];
87
115
 
88
- let orderServicesPayload: Record<string, any> = {};
89
-
90
- const includesKey = serviceKeys.some(key => key in payload);
91
-
92
- if (includesKey) {
93
- for (const key of serviceKeys) {
94
- orderServicesPayload[key as keyof typeof payload] =
95
- key in payload
96
- ? payload[key as keyof typeof payload]
97
- : orderDetails[key as keyof OrdersType];
98
- delete payload[key as keyof typeof payload];
99
- if (
100
- orderServicesPayload?.assemble === false &&
101
- orderServicesPayload?.disassemble === false
102
- ) {
103
- orderServicesPayload.assembly_type = null;
104
- }
116
+ for (const key of serviceKeys) {
117
+ if (key in payload) {
118
+ (payload as Record<ServiceKey, any>)[key] =
119
+ payload[key as keyof typeof payload];
120
+ } else if (key in orderDetails) {
121
+ (payload as Record<ServiceKey, any>)[key] =
122
+ orderDetails[key as keyof OrdersType];
105
123
  }
106
124
  }
107
125
 
108
- if (Object.keys(orderServicesPayload).length > 0) {
109
- payload.order_services = [orderServicesPayload];
126
+ if (payload?.assemble === false && payload?.disassemble === false) {
127
+ payload.assembly_type = null;
110
128
  }
111
129
 
112
130
  let response = (await callUpdateOrderAPI({
@@ -133,8 +151,26 @@ function OrderDetailsFooter() {
133
151
  } else {
134
152
  setOrderDetails(prevOrderDetails);
135
153
  }
136
- };
137
154
 
155
+ const alertsApiRes = (await callOrderAlertsApi()) as {
156
+ code: number | null;
157
+ error?: string | null | undefined;
158
+ [key: string]: any;
159
+ };
160
+ if (alertsApiRes?.code === 200 && alertsApiRes?.data) {
161
+ setOrderAlertsData(alertsApiRes?.data);
162
+ }
163
+
164
+ const orderStatusApiRes = (await callOrderStatusApi()) as {
165
+ code: number | null;
166
+ error?: string | null | undefined;
167
+ [key: string]: any;
168
+ };
169
+ if (orderStatusApiRes?.code === 200 && orderStatusApiRes?.data) {
170
+ setOrderStatus(orderStatusApiRes?.data);
171
+ }
172
+ };
173
+ //here changes needed
138
174
  return (
139
175
  <Container>
140
176
  <AllowTracking />
@@ -157,7 +157,7 @@ export interface OrdersType {
157
157
  vehicle_type: string | null;
158
158
  order_recipient: OrderRecipientType | null;
159
159
  order_services_detail: OrderServicesDetailType | null;
160
- order_services: OrderServiceType[];
160
+ order_services?: OrderServiceType[];
161
161
  order_routes?: OrderRouteType | null;
162
162
  order_eta_updates: any[];
163
163
  order_delivery_declined_dates: any[];