@bjsdistribution/dms-client-return 0.1.21-prod → 0.1.22-dev

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 (49) hide show
  1. package/dist/common/custom-input/CustomInput.d.ts +5 -0
  2. package/dist/components/order-view/order-actions/actions/send-sms/SendSmsModal.d.ts +1 -0
  3. package/dist/components/order-view/order-actions/actions/what3words/What3WordsModal.tsx.d.ts +3 -0
  4. package/dist/components/order-view/store.d.ts +1 -1
  5. package/dist/components/order-view/types.d.ts +5 -4
  6. package/dist/components/order-view/utils.d.ts +2 -1
  7. package/dist/components/store.d.ts +2 -1
  8. package/dist/dms-client-return.cjs.development.js +1278 -903
  9. package/dist/dms-client-return.cjs.development.js.map +1 -1
  10. package/dist/dms-client-return.cjs.production.min.js +1 -1
  11. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  12. package/dist/dms-client-return.esm.js +1280 -905
  13. package/dist/dms-client-return.esm.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/common/custom-input/CustomInput.tsx +24 -0
  16. package/src/components/client-portal/DateFilterStore.ts +57 -9
  17. package/src/components/client-portal/OutstandingTable.tsx +1 -1
  18. package/src/components/client-portal/ReturnStatus.tsx +84 -44
  19. package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +5 -6
  20. package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +21 -2
  21. package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +45 -23
  22. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +3 -2
  23. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +5 -3
  24. package/src/components/order-daily-overview/index.tsx +12 -5
  25. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +53 -4
  26. package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +48 -12
  27. package/src/components/order-view/general-information/dropdowns/Print.tsx +13 -17
  28. package/src/components/order-view/modalsPopup/ModalManager.tsx +9 -1
  29. package/src/components/order-view/notes/logs/index.tsx +3 -1
  30. package/src/components/order-view/order-actions/actions/add-resources/DocFileUpload.tsx +4 -4
  31. package/src/components/order-view/order-actions/actions/charge-log/index.tsx +26 -1
  32. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +1 -3
  33. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +7 -4
  34. package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +21 -20
  35. package/src/components/order-view/order-actions/actions/send-sms/SendSmsModal.tsx +104 -51
  36. package/src/components/order-view/order-actions/actions/what3words/What3WordsModal.tsx.tsx +306 -0
  37. package/src/components/order-view/order-actions/index.tsx +34 -13
  38. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +6 -3
  39. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +6 -3
  40. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +9 -3
  41. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Latitude.tsx +5 -7
  42. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Longitude.tsx +1 -1
  43. package/src/components/order-view/order-details/expanded-content/customer-section/location-info/What3words.tsx +45 -13
  44. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +63 -27
  45. package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +1 -1
  46. package/src/components/order-view/products-info/index.tsx +1 -0
  47. package/src/components/order-view/types.ts +6 -4
  48. package/src/components/store.ts +8 -1
  49. package/src/index.tsx +6 -4
@@ -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 />
@@ -62,7 +62,7 @@ function DeliveryDate() {
62
62
  onChange={onChange}
63
63
  value={actionDate === null ? actionDate : dayjs(actionDate)}
64
64
  format="DD/MM/YY"
65
- disabledDate={current => current && current < dayjs().startOf('day')}
65
+ disabledDate={() => false}
66
66
  allowClear={false}
67
67
  disabled={
68
68
  isClientPortal
@@ -31,6 +31,7 @@ function ProductsInfo({ locationloading }: any) {
31
31
  }>({
32
32
  endpoint: `/v1/return/products/${returnOrder?.id}`,
33
33
  method: 'GET',
34
+ pagination: { is_pagination: false },
34
35
  });
35
36
 
36
37
  useEffect(() => {
@@ -51,7 +51,8 @@ export type OrderActionsType =
51
51
  | 'clear-date'
52
52
  | 'uncancel-order'
53
53
  | 'remove-from-route'
54
- | 'force-debrief';
54
+ | 'force-debrief'
55
+ | 'what3Words';
55
56
 
56
57
  export interface ChargeLogData {
57
58
  id: number;
@@ -76,8 +77,8 @@ export type OrderRecipientType = {
76
77
  postcode?: string | null;
77
78
  postcode_district?: string | null;
78
79
  postcode_short?: string | null;
79
- latitude?: number | null;
80
- longitude?: number | null;
80
+ latitude?: string | null;
81
+ longitude?: string | null;
81
82
  what_3words_address?: string | null;
82
83
  contact_home?: string | null;
83
84
  contact_work?: string | null;
@@ -157,7 +158,7 @@ export interface OrdersType {
157
158
  vehicle_type: string | null;
158
159
  order_recipient: OrderRecipientType | null;
159
160
  order_services_detail: OrderServicesDetailType | null;
160
- order_services: OrderServiceType[];
161
+ order_services?: OrderServiceType[];
161
162
  order_routes?: OrderRouteType | null;
162
163
  order_eta_updates: any[];
163
164
  order_delivery_declined_dates: any[];
@@ -180,6 +181,7 @@ export interface OrdersType {
180
181
  take_packaging_away: boolean;
181
182
  collect_disposal: boolean;
182
183
  assembly_type: string | null;
184
+ labels?: any;
183
185
  }
184
186
 
185
187
  export type DeleteProds = {
@@ -262,11 +262,17 @@ export function useSelectedData() {
262
262
  export function useNewReturnOrderData() {
263
263
  return useAtom(newReturnOrderData);
264
264
  }
265
-
265
+ //call
266
266
  const isClientPortalAtom = atom<boolean | undefined>(undefined);
267
267
  function useClientPortal() {
268
268
  return useAtom(isClientPortalAtom);
269
269
  }
270
+
271
+ const isClientLoading = atom<boolean>(true);
272
+ function useClientLoading() {
273
+ return useAtom(isClientLoading);
274
+ }
275
+
270
276
  const activeCardIdAtom = atom<number>(1);
271
277
  export const useActiveCardId = () => {
272
278
  return useAtom(activeCardIdAtom);
@@ -306,4 +312,5 @@ export {
306
312
  useStartDate,
307
313
  useEndDate,
308
314
  useSelectedClientAfterOrders,
315
+ useClientLoading,
309
316
  };
package/src/index.tsx CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  useActionType,
20
20
  useActionTypeOptions,
21
21
  useAssignData,
22
+ useClientLoading,
22
23
  useClientPortal,
23
24
  useLocationData,
24
25
  useStatusOrderData,
@@ -54,10 +55,11 @@ function ReturnClient() {
54
55
  const [, setOrderStaticData] = useOrderStaticData();
55
56
  const [clientPortal, setClientPortal] = useClientPortal();
56
57
  const location = useLocation();
57
- const userType = JSON.parse(localStorage.getItem('user_type')!);
58
-
58
+ const userType = JSON.parse(localStorage.getItem('user_type') ?? 'null');
59
+ const [, setLoading] = useClientLoading();
59
60
  useEffect(() => {
60
- setClientPortal(userType?.is_customer || false); // change it to false bydefault
61
+ setClientPortal(userType?.is_customer ? true : false); // change it to false bydefault
62
+ setLoading(false);
61
63
  }, []);
62
64
 
63
65
  const splitPath = (str: any) => {
@@ -134,7 +136,7 @@ function ReturnClient() {
134
136
  <Suspense fallback={<LoadingMessage />}>
135
137
  {clientPortal ? (
136
138
  <Routes>
137
- <Route path="" element={<Navigate to={'outstanding_return'} />} />
139
+ <Route path="" element={<Navigate to={'return_completed'} />} />
138
140
  <Route path=":status" element={<ReturnOverview />} />
139
141
  <Route
140
142
  path="view/:id"