@bjsdistribution/dms-client-return 0.0.81 → 0.0.83

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 (37) hide show
  1. package/dist/components/order-view/DynamicTable.d.ts +4 -1
  2. package/dist/components/order-view/notification/ReminderTemplate.d.ts +1 -1
  3. package/dist/components/order-view/notification/Tabs.d.ts +1 -1
  4. package/dist/components/order-view/order-actions/Dropdown.d.ts +1 -0
  5. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +3 -0
  6. package/dist/components/store.d.ts +2 -1
  7. package/dist/dms-client-return.cjs.development.js +948 -400
  8. package/dist/dms-client-return.cjs.development.js.map +1 -1
  9. package/dist/dms-client-return.cjs.production.min.js +1 -1
  10. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  11. package/dist/dms-client-return.esm.js +983 -435
  12. package/dist/dms-client-return.esm.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +1 -1
  15. package/src/components/order-view/DynamicTable.tsx +115 -90
  16. package/src/components/order-view/fakedata.ts +4 -2
  17. package/src/components/order-view/generic-table/AuditLogs.tsx +23 -81
  18. package/src/components/order-view/index.tsx +9 -7
  19. package/src/components/order-view/notes/NoteType.tsx +12 -1
  20. package/src/components/order-view/notes/index.tsx +46 -33
  21. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +17 -4
  22. package/src/components/order-view/notification/ReminderTemplate.tsx +10 -11
  23. package/src/components/order-view/notification/Tabs.tsx +26 -6
  24. package/src/components/order-view/notification/index.tsx +47 -13
  25. package/src/components/order-view/order-actions/Dropdown.tsx +10 -1
  26. package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +21 -2
  27. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +51 -48
  28. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +3 -0
  29. package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +28 -19
  30. package/src/components/order-view/order-actions/actions/split-order/index.tsx +24 -2
  31. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +166 -0
  32. package/src/components/order-view/order-actions/index.tsx +3 -2
  33. package/src/components/order-view/order-actions/store.ts +1 -2
  34. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +9 -6
  35. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +16 -4
  36. package/src/components/order-view/view-reminder/reminder-styles.tsx +1 -0
  37. package/src/components/store.ts +7 -1
@@ -0,0 +1,166 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import {
3
+ AntSelect,
4
+ TextArea,
5
+ useApiHook,
6
+ } from '@bjsdistribution/dms-component-library';
7
+ import {
8
+ useCurrentAction,
9
+ useCustomerInfo,
10
+ useOrderDetails,
11
+ useOrderId,
12
+ useOrderStaticData,
13
+ usePrevOrderDetails,
14
+ } from '../../../store';
15
+ import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
16
+ import { HoldContentContainer, HoldRow, Label, SplitText } from '../modalstyle';
17
+ import { ApiResponse, OrdersType } from '../../../types';
18
+ import styled from 'styled-components';
19
+ import { useLoading } from '../../../../order-daily-overview/store/store';
20
+ import { notification } from 'antd';
21
+
22
+ function UncancelOrder() {
23
+ const [orderId] = useOrderId();
24
+ const [, setCurrentAction] = useCurrentAction();
25
+
26
+ const onClose = () => {
27
+ setCurrentAction(undefined);
28
+ };
29
+
30
+ const [orderStaticData] = useOrderStaticData();
31
+ const [unCancelReason, setUncancelReason] = useState<string | undefined>(
32
+ undefined
33
+ );
34
+ const [unCancelNotes, setUncancelNotes] = useState<string>('');
35
+ const [, setOrderDetails] = useOrderDetails();
36
+ const [, setPrevOrderDetails] = usePrevOrderDetails();
37
+ const [, setLoading] = useLoading();
38
+ const [customerInfo] = useCustomerInfo();
39
+ const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
40
+
41
+ const unCancelReasonOptions = orderStaticData?.uncancel_reasons?.map(
42
+ (item: any) => {
43
+ return {
44
+ label: item?.reason,
45
+ value: item?.reason,
46
+ };
47
+ }
48
+ );
49
+
50
+ const {
51
+ data: response,
52
+ setShouldPerformAction: setPerformAction,
53
+ } = useApiHook<{
54
+ data: ApiResponse[];
55
+ }>({
56
+ endpoint: `orders/${orderId}/uncancel/?uncancelled_reason=${unCancelReason}&uncancelled_notes=${unCancelNotes}`,
57
+ method: 'POST',
58
+ performAction: false,
59
+ });
60
+
61
+ const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
62
+ data: OrdersType[];
63
+ }>({
64
+ endpoint: `orders/${orderId}`,
65
+ method: 'GET',
66
+ performAction: false,
67
+ });
68
+
69
+ useEffect(() => {
70
+ setLoading(loading);
71
+ if (fetchedData && fetchedData.data) {
72
+ const requiredData = fetchedData?.data;
73
+ setOrderDetails(requiredData[0]);
74
+ setPrevOrderDetails(requiredData[0]);
75
+ setCurrentAction(undefined);
76
+ }
77
+ if (
78
+ (fetchedData && fetchedData?.data === null) ||
79
+ fetchedData?.data?.length === 0
80
+ ) {
81
+ setCurrentAction(undefined);
82
+ }
83
+ }, [loading]);
84
+
85
+ useEffect(() => {
86
+ if (response) {
87
+ //@ts-ignore
88
+ if (response?.data && response?.code === 200) {
89
+ setShouldPerformAction(true);
90
+ notification.success({
91
+ message: 'Success',
92
+ description:
93
+ //@ts-ignore
94
+ response?.message || 'Sucess',
95
+ });
96
+ } else {
97
+ notification.error({
98
+ message: 'Error',
99
+ description:
100
+ //@ts-ignore
101
+ response?.error_traceback ||
102
+ 'An error has occurred. Please try again later.',
103
+ });
104
+ setCurrentAction(undefined);
105
+ }
106
+ }
107
+ }, [response]);
108
+
109
+ const onChange = (event: any) => {
110
+ setUncancelNotes(event.target.value);
111
+ };
112
+
113
+ const onChangeUnCancelReason = (value: string) => {
114
+ setUncancelReason(value);
115
+ };
116
+
117
+ const onSubmit = () => {
118
+ if (orderId) {
119
+ setPerformAction(true);
120
+ }
121
+ };
122
+
123
+ const showSubmitBtn =
124
+ unCancelReason !== undefined && unCancelNotes?.length > 0;
125
+
126
+ return (
127
+ <OrderActionModal
128
+ headerTitle="Un-Cancel order"
129
+ onCloseHeader={onClose}
130
+ onSubmit={onSubmit}
131
+ showAdditionalInfo
132
+ infoText={infoText}
133
+ submitBtnTitle="Save Details"
134
+ isSubmitDisabled={!showSubmitBtn}
135
+ >
136
+ <HoldContentContainer>
137
+ <SplitText>
138
+ <HoldRow>
139
+ <Label>Un-cancel Reason</Label>
140
+ <AntSelect
141
+ options={unCancelReasonOptions || []}
142
+ placeholder="Select un-cancel Reason"
143
+ onChange={onChangeUnCancelReason}
144
+ disabled={false}
145
+ style={{ width: '346px', height: 40 }}
146
+ showSearch={true}
147
+ popupClassName={'dropDownStyle'}
148
+ selectWrapperClass={'rounded'}
149
+ defaultValue={unCancelReason}
150
+ />
151
+ </HoldRow>
152
+ <HoldRow>
153
+ <Label>Un-cancel Note</Label>
154
+ <CustomTextArea rows={5} onChange={onChange} />
155
+ </HoldRow>
156
+ </SplitText>
157
+ </HoldContentContainer>
158
+ </OrderActionModal>
159
+ );
160
+ }
161
+
162
+ const CustomTextArea = styled(TextArea)`
163
+ width: 346px;
164
+ `;
165
+
166
+ export default UncancelOrder;
@@ -18,6 +18,7 @@ import TaskReminderModal from './actions/create-task-reminder';
18
18
  import OrderLock from './actions/order-lock';
19
19
  import ViewFlag from '../flags-action-modal/index';
20
20
  import ReleaseOrder from './actions/release-order/ReleaseOrder';
21
+ import UncancelOrder from './actions/uncancel-order/UncancelOrder';
21
22
 
22
23
  function OrderActions() {
23
24
  const [currentAction] = useCurrentAction();
@@ -36,8 +37,8 @@ function OrderActions() {
36
37
  return <LogServiceRefusal />;
37
38
  case 'cancel-order':
38
39
  return <CancelOrder />;
39
- // case 'uncancel-order':
40
- // return <UncancelOrder />;
40
+ case 'uncancel-order':
41
+ return <UncancelOrder />;
41
42
  case 'confirm-order':
42
43
  return <ConfirmOrder />;
43
44
  case 'send-sms':
@@ -107,7 +107,7 @@ const resolvedModalPayload = atom<SingleResolvedPayload>(resolvedValue);
107
107
 
108
108
  const routeDetails = atom<any>({});
109
109
 
110
- const orderNotifyCount = atom<number>(2);
110
+ const orderNotifyCount = atom<number>(0);
111
111
 
112
112
  //errors
113
113
  const errorMessage = atom<any>({
@@ -178,7 +178,6 @@ export function useSelectedSplit() {
178
178
  return useAtom(selectedSplitList);
179
179
  }
180
180
 
181
-
182
181
  export function useLoadingText() {
183
182
  return useAtom(loadingText);
184
183
  }
@@ -9,6 +9,8 @@ import {
9
9
  errorAtom,
10
10
  useCustomerInfo,
11
11
  useUpdateApiCall,
12
+ useLiveRecalling,
13
+ useGlobalStateHitAuditLog,
12
14
  } from '../../../store';
13
15
  import useUpdateOrder from '../../../hooks/useUpdateOrder';
14
16
  import { compareOrderDetailsStates, filterObject } from '../../../utils';
@@ -21,6 +23,8 @@ function OrderDetailsFooter() {
21
23
  const updateOrder = useUpdateOrder();
22
24
  const [errorState] = useAtom(errorAtom);
23
25
  const [, setCallApi] = useUpdateApiCall(); //single detail
26
+ const [, setRecalling] = useLiveRecalling();
27
+ const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
24
28
  const errorFound = () => {
25
29
  const isError =
26
30
  errorState?.w3wError.length > 0 ||
@@ -84,14 +88,13 @@ function OrderDetailsFooter() {
84
88
  recipient_name: response?.data[0]?.order_recipient?.recipient_name,
85
89
  postcode: response?.data[0]?.order_recipient?.postcode,
86
90
  });
87
- // setNoteLoadingStore(true);
88
- // setTimeout(() => {
89
- // setLogsCallAPi(true);
91
+ setRecalling(true);
92
+ setTimeout(() => {
93
+ setRecalling(false);
94
+ setRecallAuditLog(false);
95
+ }, 1000);
90
96
  setCallApi(true);
91
- // }, 2000);
92
97
  } else {
93
- // setLogsCallAPi(false);
94
- // setCallApi(false);
95
98
  setOrderDetails(prevOrderDetails);
96
99
  }
97
100
  };
@@ -10,7 +10,8 @@ import { useOrderId, useOrderStaticData, useProductDetails } from '../../store';
10
10
  import { ApiResponse } from '../../types';
11
11
  import Loader from '../../../order-daily-overview/header/loader/Loader';
12
12
  import { notification } from 'antd';
13
- import { useSelectedProducts } from '../../../store';
13
+ import { useNewReturnOrderData, useSelectedProducts } from '../../../store';
14
+ import styled from 'styled-components';
14
15
 
15
16
  const ReturnProductTable = () => {
16
17
  const [selectedProducts, setSelectedProducts] = useSelectedProducts();
@@ -18,6 +19,7 @@ const ReturnProductTable = () => {
18
19
  const [productData, setProductData] = useProductDetails();
19
20
  const [selectedRowId, setSelectedRowId] = useState<number | null>(null);
20
21
  const [orderId] = useOrderId();
22
+ const [returnOrderData] = useNewReturnOrderData();
21
23
 
22
24
  const handleActionClick = (id: number) => {
23
25
  setSelectedRowId(id);
@@ -93,7 +95,8 @@ const ReturnProductTable = () => {
93
95
  return matchedReason ? matchedReason.label : 'N/A';
94
96
  };
95
97
 
96
- const disableCheckbox = productData?.length == 0;
98
+ const disableCheckbox =
99
+ productData?.length == 0 || returnOrderData?.length == 0;
97
100
 
98
101
  return (
99
102
  <div>
@@ -103,7 +106,7 @@ const ReturnProductTable = () => {
103
106
  <thead>
104
107
  <tr>
105
108
  <th className="emailproductsCheckbox">
106
- <Checkbox
109
+ <StyleCheckbox
107
110
  disabled={disableCheckbox}
108
111
  checked={selectAll}
109
112
  onChange={handleSelectAll}
@@ -123,9 +126,10 @@ const ReturnProductTable = () => {
123
126
  productData?.map((product: any) => (
124
127
  <tr key={product.id}>
125
128
  <td>
126
- <Checkbox
129
+ <StyleCheckbox
127
130
  checked={selectedProducts?.includes(product?.id)}
128
131
  onChange={() => handleSelectProduct(product?.id)}
132
+ disabled={disableCheckbox}
129
133
  />
130
134
  </td>
131
135
  <td>{product?.orders_products_stock?.location || 'N/A'}</td>
@@ -164,4 +168,12 @@ const ReturnProductTable = () => {
164
168
  );
165
169
  };
166
170
 
171
+ const StyleCheckbox = styled(Checkbox)`
172
+ &:disabled {
173
+ background-color: gray;
174
+ cursor: not-allowed;
175
+ opacity: -0.4;
176
+ }
177
+ `;
178
+
167
179
  export default ReturnProductTable;
@@ -10,6 +10,7 @@ export const ReferenceContainer = styled.div`
10
10
  border-radius: 40px;
11
11
  border: 1px solid rgba(0, 0, 0, 0.1);
12
12
  background: #fff;
13
+ margin-top: 15px;
13
14
  `;
14
15
  export const InnerContainer = styled.div`
15
16
  display: flex;
@@ -76,6 +76,8 @@ const locationOptions = atom<any[]>([]);
76
76
 
77
77
  const selectedProductsMove = atom<any>([]);
78
78
 
79
+ const newReturnOrderData = atom<any>([]);
80
+
79
81
  function useReminderData() {
80
82
  return useAtom(reminderTableData);
81
83
  }
@@ -197,6 +199,10 @@ export function useSelectedData() {
197
199
  return useAtom(selectedAssignee);
198
200
  }
199
201
 
202
+ export function useNewReturnOrderData() {
203
+ return useAtom(newReturnOrderData);
204
+ }
205
+
200
206
  export {
201
207
  useAtom,
202
208
  useFilter,
@@ -226,5 +232,5 @@ export {
226
232
  useActionTypeOptions,
227
233
  useLocationOptions,
228
234
  useSelectedProducts,
229
- useVisibilityData
235
+ useVisibilityData,
230
236
  };