@bjsdistribution/dms-client-return 0.0.81 → 0.0.82

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 (24) hide show
  1. package/dist/components/order-view/DynamicTable.d.ts +4 -1
  2. package/dist/components/order-view/order-actions/Dropdown.d.ts +1 -0
  3. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +3 -0
  4. package/dist/dms-client-return.cjs.development.js +510 -341
  5. package/dist/dms-client-return.cjs.development.js.map +1 -1
  6. package/dist/dms-client-return.cjs.production.min.js +1 -1
  7. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  8. package/dist/dms-client-return.esm.js +510 -341
  9. package/dist/dms-client-return.esm.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/components/order-view/DynamicTable.tsx +115 -90
  12. package/src/components/order-view/fakedata.ts +4 -2
  13. package/src/components/order-view/generic-table/AuditLogs.tsx +23 -81
  14. package/src/components/order-view/index.tsx +6 -7
  15. package/src/components/order-view/notes/NoteType.tsx +12 -1
  16. package/src/components/order-view/notes/index.tsx +46 -33
  17. package/src/components/order-view/order-actions/Dropdown.tsx +10 -1
  18. package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +21 -2
  19. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +51 -48
  20. package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +28 -19
  21. package/src/components/order-view/order-actions/actions/split-order/index.tsx +24 -2
  22. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +166 -0
  23. package/src/components/order-view/order-actions/index.tsx +3 -2
  24. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +9 -6
@@ -84,6 +84,12 @@ function CancelOrder() {
84
84
  //@ts-ignore
85
85
  if (response?.data && response?.code === 200) {
86
86
  setShouldPerformAction(true);
87
+ notification.success({
88
+ message: 'Success',
89
+ description:
90
+ //@ts-ignore
91
+ response?.message || 'Sucess',
92
+ });
87
93
  } else {
88
94
  // alert(response?.error_traceback);
89
95
  notification.error({
@@ -132,6 +138,7 @@ function CancelOrder() {
132
138
  <Top>
133
139
  <TopLeft>
134
140
  <OrderActionsDropdown
141
+ required
135
142
  label="Cancelation Reason"
136
143
  placeholder="Select Cancelation Reason"
137
144
  options={cancelReasonOptions || []}
@@ -145,8 +152,11 @@ function CancelOrder() {
145
152
  </TopLeft>
146
153
  <TopRight>
147
154
  <Container>
148
- <Label>Cancelation Note</Label>
149
- <TextArea
155
+ <div style={{ display: 'flex', flexDirection: 'row' }}>
156
+ <Label>Cancelation Note</Label>{' '}
157
+ <RequiredAsterisk>*</RequiredAsterisk>
158
+ </div>
159
+ <TArea
150
160
  rows={5}
151
161
  onChange={onChangeNotes}
152
162
  value={cancelNotes}
@@ -162,6 +172,15 @@ function CancelOrder() {
162
172
  </OrderActionModal>
163
173
  );
164
174
  }
175
+ const RequiredAsterisk = styled.span`
176
+ color: red;
177
+ margin-left: 2px;
178
+ font-size: x-small;
179
+ `;
180
+
181
+ const TArea = styled(TextArea)`
182
+ resize: none;
183
+ `;
165
184
 
166
185
  const Label = styled.label`
167
186
  color: #6a7378;
@@ -5,6 +5,7 @@ import { useOrderId } from '../../../../store';
5
5
 
6
6
  import { Empty, Skeleton } from 'antd';
7
7
  import { format } from 'date-fns';
8
+ import CustomScrollBar from '../../../../../../common/scrollbar';
8
9
  import {
9
10
  EmptyDataContainer,
10
11
  StyledTable,
@@ -56,7 +57,7 @@ function NotesTable() {
56
57
  });
57
58
  useEffect(() => {
58
59
  setNoteLoadingStore(true);
59
- if (moduleIds && orderId) {
60
+ if (moduleIds) {
60
61
  setShouldPerformAction(true);
61
62
  }
62
63
  if (!NotesLoading && NotesData?.data) {
@@ -76,56 +77,58 @@ function NotesTable() {
76
77
  <Container>
77
78
  <Title>Notes ({notes?.length})</Title>
78
79
  <StyledTableWrapper>
79
- <StyledTable className="scrollClass">
80
- <thead>
81
- <tr>
82
- <th>Created</th>
83
- <th>Notes</th>
84
- </tr>
85
- </thead>
86
- <tbody>
87
- {loading ? (
80
+ <CustomScrollBar>
81
+ <StyledTable className="scrollClass">
82
+ <thead>
88
83
  <tr>
89
- <td colSpan={6}>
90
- <Skeleton active />
91
- </td>
92
- <td colSpan={6}></td>
84
+ <th>Created</th>
85
+ <th>Notes</th>
93
86
  </tr>
94
- ) : notes?.length === 0 ? (
95
- <tr>
96
- <td className="emptyTd" colSpan={7}>
97
- <EmptyDataContainer>
98
- <Empty />
99
- </EmptyDataContainer>
100
- </td>
101
- </tr>
102
- ) : (
103
- notes?.map((order: any) => (
104
- <tr key={order.id}>
105
- <td>
106
- <div
107
- style={{
108
- fontWeight: 'bold',
109
- textTransform: 'capitalize',
110
- }}
111
- >
112
- {order?.created_by}
113
- </div>
114
- <div>
115
- {format(
116
- new Date(order?.created_at),
117
- "dd/MM/yyyy '@' HH:mm"
118
- )}
119
- </div>
87
+ </thead>
88
+ <tbody>
89
+ {loading ? (
90
+ <tr>
91
+ <td colSpan={6}>
92
+ <Skeleton active />
93
+ </td>
94
+ <td colSpan={6}></td>
95
+ </tr>
96
+ ) : notes?.length === 0 ? (
97
+ <tr>
98
+ <td className="emptyTd" colSpan={7}>
99
+ <EmptyDataContainer>
100
+ <Empty />
101
+ </EmptyDataContainer>
120
102
  </td>
121
- <td
122
- dangerouslySetInnerHTML={{ __html: order?.description }}
123
- ></td>
124
103
  </tr>
125
- ))
126
- )}
127
- </tbody>
128
- </StyledTable>
104
+ ) : (
105
+ notes?.map((order: any) => (
106
+ <tr key={order.id}>
107
+ <td>
108
+ <div
109
+ style={{
110
+ fontWeight: 'bold',
111
+ textTransform: 'capitalize',
112
+ }}
113
+ >
114
+ {order?.created_by}
115
+ </div>
116
+ <div>
117
+ {format(
118
+ new Date(order?.created_at),
119
+ "dd/MM/yyyy '@' HH:mm"
120
+ )}
121
+ </div>
122
+ </td>
123
+ <td
124
+ dangerouslySetInnerHTML={{ __html: order?.description }}
125
+ ></td>
126
+ </tr>
127
+ ))
128
+ )}
129
+ </tbody>
130
+ </StyledTable>
131
+ </CustomScrollBar>
129
132
  </StyledTableWrapper>
130
133
  </Container>
131
134
  );
@@ -147,7 +150,7 @@ const Container = styled.div`
147
150
  flex-direction: column;
148
151
  gap: 8px;
149
152
  > div {
150
- min-height: 165px;
153
+ min-height: 350px;
151
154
  }
152
155
  `;
153
156
 
@@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react';
2
2
  import { useProductDetails } from '../../../store';
3
3
 
4
4
  import { Empty, Skeleton } from 'antd';
5
- import { useLoading } from '../../../../order-daily-overview/store/store';
6
5
  import { Checkbox } from '@bjsdistribution/dms-component-library';
6
+ import { useLoading } from '../../../../order-daily-overview/store/store';
7
7
  import { useSelectedSplit, useSplitOrderPayload } from '../../store';
8
8
  import {
9
9
  EmptyDataContainer,
@@ -18,13 +18,14 @@ function SplitOrderTable() {
18
18
  const [selectAll, setSelectAll] = useState(false);
19
19
  const [payload, setPayload] = useSplitOrderPayload();
20
20
 
21
+ // Handle Select All
21
22
  const handleSelectAll = (e: any) => {
22
- setSelectAll(e.target.checked);
23
- if (e.target.checked) {
23
+ const isChecked = e.target.checked;
24
+ setSelectAll(isChecked);
25
+
26
+ if (isChecked) {
24
27
  setSelectedSplit(
25
- orderProductDetails.map((order: any) => ({
26
- id: order.id,
27
- }))
28
+ orderProductDetails?.map((order: any) => ({ id: order.id }))
28
29
  );
29
30
  } else {
30
31
  setSelectedSplit([]);
@@ -32,16 +33,16 @@ function SplitOrderTable() {
32
33
  };
33
34
 
34
35
  const handleSelectedSplitList = (id: any) => {
35
- setSelectedSplit((prevSelectedOrder: any) => {
36
- const isSelected = prevSelectedOrder?.some(
37
- (order: any) => order.id === id
38
- );
36
+ setSelectedSplit(prevSelectedOrder => {
37
+ const isSelected = prevSelectedOrder?.some(order => order.id === id);
38
+
39
+ const updatedSelection = isSelected
40
+ ? prevSelectedOrder?.filter(order => order.id !== id)
41
+ : [...prevSelectedOrder, { id }];
42
+
43
+ setSelectAll(updatedSelection?.length === orderProductDetails?.length);
39
44
 
40
- if (isSelected) {
41
- return prevSelectedOrder?.filter((order: any) => order.id !== id);
42
- } else {
43
- return [...prevSelectedOrder, { id: id }];
44
- }
45
+ return updatedSelection;
45
46
  });
46
47
  };
47
48
 
@@ -52,7 +53,7 @@ function SplitOrderTable() {
52
53
  products: selectedSplits?.map(order => order.id),
53
54
  force: true,
54
55
  });
55
- }, [orderProductDetails, selectedSplits]);
56
+ }, [selectedSplits, setPayload]);
56
57
 
57
58
  return (
58
59
  <StyledTableWrapper id="tableScrolling">
@@ -60,7 +61,14 @@ function SplitOrderTable() {
60
61
  <thead>
61
62
  <tr>
62
63
  <th>
63
- <Checkbox checked={selectAll} onChange={handleSelectAll} />
64
+ <Checkbox
65
+ checked={selectAll}
66
+ onChange={handleSelectAll}
67
+ disabled={
68
+ orderProductDetails?.length === 0 ||
69
+ orderProductDetails?.length === null
70
+ }
71
+ />
64
72
  </th>
65
73
  <th>Type</th>
66
74
  <th>Code</th>
@@ -82,17 +90,18 @@ function SplitOrderTable() {
82
90
  <tr>
83
91
  <td className="emptyTd" colSpan={7}>
84
92
  <EmptyDataContainer>
85
- <Empty />
93
+ <Empty description="No Data Found" />
86
94
  </EmptyDataContainer>
87
95
  </td>
88
96
  </tr>
89
97
  ) : (
98
+ orderProductDetails?.length > 0 &&
90
99
  orderProductDetails?.map((order: any) => (
91
100
  <tr key={order.id}>
92
101
  <td>
93
102
  <Checkbox
94
103
  checked={selectedSplits?.some(
95
- (selectedInvoice: any) => selectedInvoice?.id === order.id
104
+ selectedOrder => selectedOrder.id === order.id
96
105
  )}
97
106
  onChange={() => handleSelectedSplitList(order.id)}
98
107
  />
@@ -7,6 +7,7 @@ import { useApiHook } from '@bjsdistribution/dms-component-library';
7
7
  import { ApiResponse } from '../../../types';
8
8
 
9
9
  import { useSelectedSplit, useSplitOrderPayload } from '../../store';
10
+ import { notification } from 'antd';
10
11
 
11
12
  function SplitOrder() {
12
13
  const [, setCurrentAction] = useCurrentAction();
@@ -21,7 +22,10 @@ function SplitOrder() {
21
22
  setCurrentAction(undefined);
22
23
  };
23
24
 
24
- const { setShouldPerformAction: setPerformAction } = useApiHook<{
25
+ const {
26
+ data: response,
27
+ setShouldPerformAction: setPerformAction,
28
+ } = useApiHook<{
25
29
  data: ApiResponse[];
26
30
  }>({
27
31
  endpoint: `orders/split_order/${orderId}`,
@@ -33,8 +37,26 @@ function SplitOrder() {
33
37
  const onSubmitSplitOrder = () => {
34
38
  if (orderId) {
35
39
  setPerformAction(true);
40
+ //@ts-ignore
41
+ if (response?.data && response?.code === 200) {
42
+ notification.success({
43
+ message: 'Success',
44
+ description:
45
+ //@ts-ignore
46
+ response?.message || 'Sucess',
47
+ });
48
+ } else {
49
+ // alert(response?.error_traceback);
50
+ notification.error({
51
+ message: 'Error',
52
+ description:
53
+ //@ts-ignore
54
+ response?.message ||
55
+ 'An error has occurred. Please try again later.',
56
+ });
57
+ }
58
+ setSelectedSplit([]);
36
59
  }
37
- setSelectedSplit([]);
38
60
  };
39
61
 
40
62
  const isSubmitDisabled = () => {
@@ -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':
@@ -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
  };