@bjsdistribution/dms-client-return 0.1.9-prod → 0.1.10-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 (135) hide show
  1. package/dist/components/client-portal/OutstandingTable.d.ts +3 -0
  2. package/dist/components/client-portal/ReturnAfterSearchBar.d.ts +4 -0
  3. package/dist/components/client-portal/ReturnOverview.d.ts +3 -0
  4. package/dist/components/client-portal/ReturnRTFilters.d.ts +5 -0
  5. package/dist/components/client-portal/ReturnSearchBar.d.ts +4 -0
  6. package/dist/components/client-portal/ReturnStatus.d.ts +8 -0
  7. package/dist/components/client-portal/return-confirm/ConfirmedMain.d.ts +3 -0
  8. package/dist/components/client-portal/return-confirm/ReturnConfirmedTable.d.ts +3 -0
  9. package/dist/components/order-daily-overview/common/fakedata.d.ts +1 -0
  10. package/dist/components/order-daily-overview/header/route-header/RouterHeader.d.ts +1 -0
  11. package/dist/components/order-view/notes/AddNote.d.ts +1 -0
  12. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  13. package/dist/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.d.ts +4 -1
  14. package/dist/components/order-view/order-actions/actions/confirm-order/index.d.ts +4 -1
  15. package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
  16. package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
  17. package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
  18. package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
  19. package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
  20. package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
  21. package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
  22. package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
  23. package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
  24. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
  25. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
  26. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
  27. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
  28. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
  29. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
  30. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
  31. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
  32. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
  33. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
  34. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
  35. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
  36. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
  37. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
  38. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
  39. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
  40. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
  41. package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
  42. package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +1 -0
  43. package/dist/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.d.ts +1 -1
  44. package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +1 -0
  45. package/dist/components/order-view/products-info/expanded-content/index.d.ts +4 -1
  46. package/dist/components/order-view/return-client-products/ProductTable.d.ts +4 -1
  47. package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +4 -1
  48. package/dist/components/order-view/store.d.ts +14 -2
  49. package/dist/components/order-view/types.d.ts +49 -1
  50. package/dist/components/order-view/utils.d.ts +3 -0
  51. package/dist/components/store.d.ts +12 -1
  52. package/dist/components/utils.d.ts +1 -0
  53. package/dist/dms-client-return.cjs.development.js +7053 -2711
  54. package/dist/dms-client-return.cjs.development.js.map +1 -1
  55. package/dist/dms-client-return.cjs.production.min.js +1 -1
  56. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  57. package/dist/dms-client-return.esm.js +7111 -2769
  58. package/dist/dms-client-return.esm.js.map +1 -1
  59. package/package.json +6 -4
  60. package/src/assets/icons/ActionIcon.tsx +1 -1
  61. package/src/assets/icons/ArrowDownIcon.tsx +2 -2
  62. package/src/components/client-portal/OutstandingTable.tsx +412 -0
  63. package/src/components/client-portal/ReturnAfterSearchBar.tsx +242 -0
  64. package/src/components/client-portal/ReturnOverview.tsx +185 -0
  65. package/src/components/client-portal/ReturnRTFilters.tsx +228 -0
  66. package/src/components/client-portal/ReturnSearchBar.tsx +294 -0
  67. package/src/components/client-portal/ReturnStatus.tsx +252 -0
  68. package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +235 -0
  69. package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +404 -0
  70. package/src/components/order-daily-overview/common/fakedata.tsx +18 -0
  71. package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +130 -1
  72. package/src/components/order-daily-overview/header-filters/HeaderFilter.tsx +15 -3
  73. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +100 -70
  74. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +4 -0
  75. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +86 -0
  76. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +12 -2
  77. package/src/components/order-daily-overview/return-after-table/table-filters/TableFilters.tsx +22 -1
  78. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnFilter.tsx +34 -6
  79. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +24 -11
  80. package/src/components/order-daily-overview/return-order-table/return-orders-filters/RightFilters.tsx +26 -6
  81. package/src/components/order-daily-overview/shared/elements/PrintDropDown.tsx +5 -3
  82. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +5 -0
  83. package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
  84. package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
  85. package/src/components/order-view/index.tsx +45 -0
  86. package/src/components/order-view/notes/AddNote.tsx +94 -65
  87. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
  88. package/src/components/order-view/notification/OrderTemplate.tsx +192 -41
  89. package/src/components/order-view/order-actions/actions/cancel-order/ReturnAction.tsx +25 -4
  90. package/src/components/order-view/order-actions/actions/cancel-order/ReturnReason.tsx +24 -4
  91. package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +9 -2
  92. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +12 -6
  93. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +2 -2
  94. package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
  95. package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +620 -0
  96. package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
  97. package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
  98. package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
  99. package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
  100. package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
  101. package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
  102. package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
  103. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
  104. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
  105. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
  106. package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
  107. package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
  108. package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
  109. package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
  110. package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
  111. package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +201 -0
  112. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
  113. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
  114. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
  115. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
  116. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
  117. package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
  118. package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
  119. package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
  120. package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
  121. package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +2 -0
  122. package/src/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.tsx +7 -2
  123. package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +2 -0
  124. package/src/components/order-view/order-actions/index.tsx +15 -3
  125. package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
  126. package/src/components/order-view/products-info/expanded-content/index.tsx +27 -11
  127. package/src/components/order-view/products-info/index.tsx +4 -4
  128. package/src/components/order-view/return-client-products/ProductTable.tsx +6 -2
  129. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +54 -15
  130. package/src/components/order-view/store.ts +106 -0
  131. package/src/components/order-view/types.ts +54 -1
  132. package/src/components/order-view/utils.ts +37 -0
  133. package/src/components/store.ts +62 -1
  134. package/src/components/utils.ts +13 -3
  135. package/src/index.tsx +26 -16
@@ -0,0 +1,221 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import {
4
+ CalendarIcon,
5
+ Label,
6
+ TextArea,
7
+ } from '@bjsdistribution/dms-component-library';
8
+ import { Input } from '../../styles';
9
+ import {
10
+ useChargesState,
11
+ useOrderDetails,
12
+ useProductDetails,
13
+ } from '../../../../../store';
14
+ import { getBaseUrlSymbol } from '../../../../../utils';
15
+
16
+ const formatDate = (date: any) => {
17
+ const padZero = (num: any) => num.toString().padStart(2, '0');
18
+ const year = new Date(date).getFullYear();
19
+ const month = padZero(new Date(date).getMonth() + 1);
20
+ const day = padZero(new Date(date).getDate());
21
+ return `${day}/${month}/${year}`;
22
+ };
23
+
24
+ function SuccessContent() {
25
+ const [orderDetails] = useOrderDetails();
26
+ const [chargesState] = useChargesState();
27
+ const baseUrlSymbol = getBaseUrlSymbol();
28
+
29
+ const [productdata] = useProductDetails();
30
+ const sortedProductData = productdata?.sort((a: any, b: any) => {
31
+ return a?.status === b?.status ? 0 : a?.status ? -1 : 1;
32
+ });
33
+
34
+ const products = Array.isArray(sortedProductData)
35
+ ? sortedProductData?.filter(item => item?.status === true)
36
+ : [];
37
+
38
+ const excludedFields = [
39
+ 'debrief_notes',
40
+ 'new_order_status',
41
+ 'base_charge_type',
42
+ 'adhoc_charges',
43
+ 'debrief_status',
44
+ ]; // Fields to exclude
45
+ let totalChargesAmount = 0;
46
+
47
+ for (const [key, value] of Object.entries(chargesState)) {
48
+ if (!excludedFields.includes(key) && typeof value === 'number') {
49
+ totalChargesAmount += value;
50
+ }
51
+ }
52
+
53
+ const formattedDate =
54
+ orderDetails?.action_date === null
55
+ ? ' '
56
+ : formatDate(orderDetails?.action_date);
57
+
58
+ const adhocTotalCharges =
59
+ chargesState?.adhoc_charges?.length > 0
60
+ ? chargesState?.adhoc_charges?.reduce(
61
+ (acc, item) => acc + item.adhoc_charges,
62
+ 0
63
+ )
64
+ : 0;
65
+
66
+ return (
67
+ <Wrapper>
68
+ <FieldGroup>
69
+ <Label label="Signed By" htmlFor="signedby" />
70
+ <StyledInput
71
+ id="signedby"
72
+ placeholder=""
73
+ value={orderDetails?.order_recipient?.recipient_name || ''}
74
+ onChange={() => {}}
75
+ disabled
76
+ />
77
+
78
+ <Label label="Date" htmlFor="datefield" />
79
+ <DateInput>
80
+ <Text>{formattedDate}</Text>
81
+ <CalendarIcon />
82
+ </DateInput>
83
+
84
+ <GroupedFields>
85
+ <PairGroup>
86
+ <SmallGroup>
87
+ <Label label="Items" htmlFor="items" />
88
+ <Text>{products?.length}</Text>
89
+ </SmallGroup>
90
+ <SmallGroup>
91
+ <Label label="Zone" htmlFor="zone" />
92
+ <Text>{orderDetails?.zone_code}</Text>
93
+ </SmallGroup>
94
+ </PairGroup>
95
+
96
+ <PairGroup>
97
+ <SmallGroup>
98
+ <Label label="Weight" htmlFor="weight" />
99
+ <Text>{orderDetails?.weight}Kg</Text>
100
+ </SmallGroup>
101
+
102
+ <SmallGroup>
103
+ <Label label="Total Charge" htmlFor="totalCharge" />
104
+ <div
105
+ style={{ display: 'flex', gap: '4px', alignItems: 'center' }}
106
+ >
107
+ <CurrencyWrapper>{baseUrlSymbol}</CurrencyWrapper>
108
+ <Text>{totalChargesAmount + adhocTotalCharges}</Text>
109
+ </div>
110
+ </SmallGroup>
111
+ </PairGroup>
112
+ </GroupedFields>
113
+ </FieldGroup>
114
+
115
+ <DropdownGrid>
116
+ <FieldGroup wide>
117
+ <Label label="Order Status Notes" htmlFor="notes" />
118
+ <TextInput
119
+ id="notes"
120
+ placeholder="Type notes here..."
121
+ value={orderDetails?.order_status_note || ''}
122
+ readOnly
123
+ />
124
+ </FieldGroup>
125
+
126
+ <FieldGroup wide>
127
+ <Label label="Charge Description" htmlFor="chargedescription" />
128
+ <TextInput
129
+ id="chargedescription"
130
+ placeholder="Type charge description here..."
131
+ onChange={() => {}}
132
+ />
133
+ </FieldGroup>
134
+ </DropdownGrid>
135
+ </Wrapper>
136
+ );
137
+ }
138
+
139
+ const CurrencyWrapper = styled.span`
140
+ display: flex;
141
+ align-items: center;
142
+ color: #999;
143
+ `;
144
+
145
+ const DropdownGrid = styled.div`
146
+ display: flex;
147
+ flex-wrap: wrap;
148
+ gap: 20px;
149
+ width: 48%;
150
+ `;
151
+
152
+ const GroupedFields = styled.div`
153
+ display: flex;
154
+ flex-direction: column;
155
+ gap: 7px;
156
+ `;
157
+
158
+ const PairGroup = styled.div`
159
+ display: flex;
160
+ flex-direction: row;
161
+ gap: 20px;
162
+
163
+ @media (max-width: 768px) {
164
+ flex-direction: column;
165
+ }
166
+ `;
167
+
168
+ const SmallGroup = styled.div`
169
+ display: flex;
170
+ flex-direction: column;
171
+ gap: 6px;
172
+ flex: 1;
173
+ width: 48%;
174
+ `;
175
+
176
+ const Wrapper = styled.div`
177
+ display: flex;
178
+ flex-wrap: wrap;
179
+ gap: 20px;
180
+ width: 100%;
181
+ padding: 10px 0;
182
+ `;
183
+
184
+ const FieldGroup = styled.div<{ wide?: boolean }>`
185
+ display: flex;
186
+ flex-direction: column;
187
+ gap: 6px;
188
+ flex: ${props => (props.wide ? 2 : 1)};
189
+ `;
190
+
191
+ const TextInput = styled(TextArea)`
192
+ resize: none;
193
+ width: 100%;
194
+ min-height: 180px;
195
+ `;
196
+
197
+ const StyledInput = styled(Input)`
198
+ width: 100%;
199
+ height: 38px;
200
+ `;
201
+
202
+ const DateInput = styled.div`
203
+ display: flex;
204
+ align-items: center;
205
+ justify-content: space-between;
206
+ padding: 0 12px;
207
+ border-radius: 6px;
208
+ border: 1px solid #e0e2e7;
209
+ background-color: #fff;
210
+ color: #363a30;
211
+ height: 38px;
212
+ font-size: 14px;
213
+ box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);
214
+ `;
215
+
216
+ const Text = styled.div`
217
+ color: #363a30;
218
+ font-size: 14px;
219
+ `;
220
+
221
+ export default SuccessContent;
@@ -0,0 +1,51 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const Title = styled.span`
4
+ font-family: 'Lato', sans-serif;
5
+ font-size: 16px;
6
+ font-weight: 600;
7
+ color: #6a7378;
8
+ `;
9
+
10
+ export const Container = styled.div`
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: 4px;
14
+ `;
15
+
16
+ export const FieldRow = styled.div`
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 8px;
20
+ width: 300px;
21
+ justify-content: space-between;
22
+ `;
23
+
24
+ export const Label = styled.label`
25
+ font-size: 14px;
26
+ color: #7b7874;
27
+ `;
28
+
29
+ export const Input = styled.input`
30
+ width: 70px;
31
+ padding: 6px;
32
+ font-size: 14px;
33
+ border: 1px solid #ccc;
34
+ border-radius: 4px;
35
+ &::-webkit-inner-spin-button,
36
+ &::-webkit-outer-spin-button {
37
+ -webkit-appearance: none;
38
+ -moz-appearance: none;
39
+ appearance: none;
40
+ margin: 0;
41
+ }
42
+ `;
43
+
44
+ export const MainContainer = styled.div`
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 4px;
48
+ `;
49
+ export const CurrencySymbol = styled.span`
50
+ color: #858d9d;
51
+ `;
@@ -25,6 +25,7 @@ import { useClientPortal } from '../../../../store';
25
25
  interface IProps {
26
26
  callOrderAlertsApi: any;
27
27
  callOrdersApi?: any;
28
+ callOrderStatusApi: any;
28
29
  callUnresolvedTaskApi?: any;
29
30
  }
30
31
 
@@ -93,6 +94,7 @@ function HoldOrderModal(props: IProps) {
93
94
  await props?.callUnresolvedTaskApi();
94
95
  }
95
96
  await props?.callOrderAlertsApi();
97
+ await props?.callOrderStatusApi();
96
98
  await props?.callOrdersApi();
97
99
  }
98
100
  if (response?.code !== 200) {
@@ -15,12 +15,16 @@ import {
15
15
  } from '../../../store';
16
16
  import { notification } from 'antd';
17
17
 
18
- function RemoveFromRoute() {
18
+ function RemoveFromRoute(props: any) {
19
19
  const [orderId] = useOrderId();
20
20
  const [, setCurrentAction] = useCurrentAction();
21
21
  const [, setRecalling] = useLiveRecalling();
22
22
  const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
23
23
 
24
+ const callOrdersApi = async () => {
25
+ await props?.callOrderAlertsApi();
26
+ };
27
+
24
28
  const { data: response, setShouldPerformAction: setAction } = useApiHook<{
25
29
  data: ApiResponse[];
26
30
  }>({
@@ -37,9 +41,10 @@ function RemoveFromRoute() {
37
41
  //@ts-ignore
38
42
  response?.message || 'Order has been removed successfully',
39
43
  });
40
- setCurrentAction(undefined);
44
+ callOrdersApi();
41
45
  setRecalling(true);
42
46
  setRecallAuditLog(true);
47
+ setCurrentAction(undefined);
43
48
  }
44
49
  if (response?.data === null) {
45
50
  notification.error({
@@ -13,6 +13,7 @@ interface IProps {
13
13
  callOrderAlertsApi: any;
14
14
  callOrdersApi?: any;
15
15
  callUnresolvedTaskApi?: any;
16
+ callOrderStatusApi: any;
16
17
  }
17
18
 
18
19
  const UnholdOrder = (props: IProps) => {
@@ -46,6 +47,7 @@ const UnholdOrder = (props: IProps) => {
46
47
  }
47
48
  await props?.callOrderAlertsApi();
48
49
  await props?.callOrdersApi();
50
+ await props?.callOrderStatusApi();
49
51
  }
50
52
  if (response?.code !== 200) {
51
53
  notification.error({
@@ -34,6 +34,7 @@ import { useReminderNotiData, useTasksData } from './store';
34
34
  import ChargeLog from './actions/charge-log';
35
35
  import ReminderModal from './actions/create-task-reminder';
36
36
  import TaskModal from './actions/create-task-reminder/TaskModal';
37
+ import ForceDebriefModal from './actions/force-debrief/ForceDebriefModal';
37
38
 
38
39
  function OrderActions() {
39
40
  const [currentAction, setCurrentAction] = useCurrentAction();
@@ -234,9 +235,18 @@ function OrderActions() {
234
235
  />
235
236
  );
236
237
  case 'confirm-order':
237
- return <ConfirmOrder />;
238
+ return <ConfirmOrder callOrderAlertsApi={callOrderAlertsApi} />;
238
239
  case 'send-sms':
239
240
  return <SendSmsModal />;
241
+
242
+ case 'force-debrief':
243
+ return (
244
+ <ForceDebriefModal
245
+ callOrdersApi={callOrdersApi}
246
+ callOrderStatusApi={fetchStatusData}
247
+ callOrderAlertsApi={callOrderAlertsApi}
248
+ />
249
+ );
240
250
  case 'send-email':
241
251
  return <SendEmailModal />;
242
252
  case 'change-customer-account':
@@ -247,6 +257,7 @@ function OrderActions() {
247
257
  <HoldOrderModal
248
258
  callOrdersApi={callOrdersApi}
249
259
  callOrderAlertsApi={callOrderAlertsApi}
260
+ callOrderStatusApi={fetchStatusData}
250
261
  callUnresolvedTaskApi={callUnresolvedTaskApi}
251
262
  />
252
263
  );
@@ -272,6 +283,7 @@ function OrderActions() {
272
283
  callOrdersApi={callOrdersApi}
273
284
  callOrderAlertsApi={callOrderAlertsApi}
274
285
  callUnresolvedTaskApi={callUnresolvedTaskApi}
286
+ callOrderStatusApi={fetchStatusData}
275
287
  />
276
288
  );
277
289
  case 'view-reminder':
@@ -281,9 +293,9 @@ function OrderActions() {
281
293
  case 'view-flag':
282
294
  return <ViewFlag />;
283
295
  case 'clear-date':
284
- return <ClearBookingStatus />;
296
+ return <ClearBookingStatus callOrderAlertsApi={callOrderAlertsApi} />;
285
297
  case 'remove-from-route':
286
- return <RemoveFromRoute />;
298
+ return <RemoveFromRoute callOrderAlertsApi={callOrderAlertsApi} />;
287
299
  default:
288
300
  return null;
289
301
  }
@@ -30,7 +30,7 @@ const CustomFormSection = styled(FormSection)`
30
30
  border-radius: 8px;
31
31
  background: #f8fafc;
32
32
  box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1);
33
- padding: 10px !important;
33
+ padding: 24px !important;
34
34
  `;
35
35
 
36
36
  export default InstructionSection;
@@ -3,8 +3,9 @@ import styled from 'styled-components';
3
3
  import ProductTable from '../../return-client-products/ProductTable';
4
4
  import NewReturnDropdown, {
5
5
  payloadAtom,
6
+ selectedOrderId,
6
7
  } from '../../notes/order-dropdown/NewReturnDropdown';
7
- import { Button, useApiHook } from '@bjsdistribution/dms-component-library';
8
+ import { Button, useAxios } from '@bjsdistribution/dms-component-library';
8
9
  import { useAtom } from 'jotai';
9
10
  import { ApiResponse } from '../../types';
10
11
  import { usePostLoading, useSelectedProducts } from '../../../store';
@@ -13,25 +14,30 @@ import { useNavigate } from 'react-router-dom';
13
14
  import { notification } from 'antd';
14
15
  import { useOrderId } from '../../store';
15
16
 
16
- function ExpandedContent() {
17
+ interface IPROS {
18
+ callReturnProducts: any;
19
+ }
20
+
21
+ function ExpandedContent(props: IPROS) {
17
22
  const [payload] = useAtom(payloadAtom);
18
23
  const [, setPostLoading] = usePostLoading();
19
24
  const [orderId] = useOrderId();
20
25
  const [isButtonDisabled, setIsButtonDisabled] = useState(true);
21
26
  const navigate = useNavigate();
22
27
  const [, setSelectedProducts] = useSelectedProducts();
28
+ const [, setSelectedOrderId] = useAtom(selectedOrderId);
23
29
 
24
30
  const {
25
31
  data: response,
26
- setShouldPerformAction,
32
+
27
33
  loading: confirmLoading,
28
- } = useApiHook<{
34
+ fetchData: callMoveProducts,
35
+ } = useAxios<{
29
36
  data: ApiResponse[];
30
37
  }>({
31
38
  endpoint: `/v1/return/product/move/?return_order_id=${orderId}`,
32
39
  method: 'POST',
33
40
  body: payload,
34
- performAction: false,
35
41
  });
36
42
 
37
43
  useEffect(() => {
@@ -46,12 +52,22 @@ function ExpandedContent() {
46
52
  }
47
53
  }, [payload]);
48
54
 
49
- const handleConfirmReturn = () => {
50
- if (!isButtonDisabled) {
51
- setShouldPerformAction(true);
52
- setPostLoading(confirmLoading);
53
- } else {
55
+ const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
56
+
57
+ const handleConfirmReturn = async () => {
58
+ if (isButtonDisabled) {
54
59
  console.error('Payload is incomplete:', payload);
60
+ return;
61
+ }
62
+
63
+ setPostLoading(true);
64
+
65
+ const response = await callMoveProducts();
66
+ //@ts-ignore
67
+ if (response?.code === 200) {
68
+ await sleep(2000);
69
+ props?.callReturnProducts();
70
+ setSelectedOrderId(null);
55
71
  }
56
72
  };
57
73
 
@@ -90,7 +106,7 @@ function ExpandedContent() {
90
106
 
91
107
  return (
92
108
  <Container>
93
- <ProductTable />
109
+ <ProductTable callReturnProducts={props?.callReturnProducts} />
94
110
  <MidContainer>
95
111
  <SaveNoteContainer>
96
112
  <Button
@@ -20,7 +20,7 @@ function ProductsInfo() {
20
20
  const returnOrder = data;
21
21
 
22
22
  // For API Call
23
- const [, setAPidata] = useProductDetails();
23
+ const [, setProductsData] = useProductDetails();
24
24
  const [, setLoading] = useLoading();
25
25
  const {
26
26
  data: returnOrdersData,
@@ -44,16 +44,16 @@ function ProductsInfo() {
44
44
  if (returnOrdersData && returnOrdersData.data) {
45
45
  const requiredData = returnOrdersData.data;
46
46
  if (requiredData.length > 0) {
47
- setAPidata(requiredData);
47
+ setProductsData(requiredData);
48
48
  } else {
49
- setAPidata(null);
49
+ setProductsData(null);
50
50
  }
51
51
  }
52
52
  }, [returnOrdersData, loading]);
53
53
 
54
54
  return (
55
55
  <CollapsableForm collapsedContent={<CollapsedContent />}>
56
- <ExpandedContent />
56
+ <ExpandedContent callReturnProducts={callReturnProducts} />
57
57
  </CollapsableForm>
58
58
  );
59
59
  }
@@ -2,10 +2,14 @@ import React from 'react';
2
2
  import ReturnProductTable from './product-table/ReturnProductTable';
3
3
  import styled from 'styled-components';
4
4
 
5
- const ProductTable = () => {
5
+ interface IPROS {
6
+ callReturnProducts: any;
7
+ }
8
+
9
+ const ProductTable = (props: IPROS) => {
6
10
  return (
7
11
  <Container>
8
- <ReturnProductTable />
12
+ <ReturnProductTable callReturnProducts={props?.callReturnProducts} />
9
13
  </Container>
10
14
  );
11
15
  };
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  Checkbox,
8
8
  displayValueOrNA,
9
- useApiHook,
9
+ useAxios,
10
10
  } from '@bjsdistribution/dms-component-library';
11
11
  import ActionIcon from '../../../../assets/icons/ActionIcon';
12
12
  import { useOrderId, useProductDetails } from '../../store';
@@ -16,7 +16,11 @@ import { useNewReturnOrderData, useSelectedProducts } from '../../../store';
16
16
  import styled from 'styled-components';
17
17
  import { NavLink } from 'react-router-dom';
18
18
 
19
- const ReturnProductTable = () => {
19
+ interface IPROS {
20
+ callReturnProducts: any;
21
+ }
22
+
23
+ const ReturnProductTable = (props: IPROS) => {
20
24
  const [selectedProducts, setSelectedProducts] = useSelectedProducts();
21
25
  const [selectAll, setSelectAll] = useState(false);
22
26
  const [productData, setProductData] = useProductDetails();
@@ -24,17 +28,16 @@ const ReturnProductTable = () => {
24
28
  const [orderId] = useOrderId();
25
29
  const [returnOrderData] = useNewReturnOrderData();
26
30
 
27
- const handleActionClick = (id: number) => {
28
- setSelectedRowId(id);
29
- };
31
+ // const handleActionClick = (id: number) => {
32
+ // setSelectedRowId(id);
33
+ // };
30
34
 
31
- const { data: isresponse, setShouldPerformAction: setAction } = useApiHook<{
35
+ const { data: isresponse, fetchData: callDeleteProduct } = useAxios<{
32
36
  data: ApiResponse[];
33
37
  }>({
34
- endpoint: `order/order_products/delete/`,
35
- method: 'DELETE',
36
- body: [{ id: selectedRowId, order_id: orderId }],
37
- performAction: false,
38
+ endpoint: `v1/return/product/remove/`,
39
+ method: 'POST',
40
+ body: { return_order_product_id: selectedRowId, return_order_id: +orderId },
38
41
  });
39
42
 
40
43
  useEffect(() => {
@@ -56,9 +59,9 @@ const ReturnProductTable = () => {
56
59
  }
57
60
  };
58
61
 
59
- const onDeleteProducts = () => {
60
- setAction(true);
61
- };
62
+ // const onDeleteProducts = () => {
63
+ // callDeleteProduct();
64
+ // };
62
65
 
63
66
  const handleSelectAll = () => {
64
67
  if (selectAll) {
@@ -78,6 +81,43 @@ const ReturnProductTable = () => {
78
81
  );
79
82
  };
80
83
 
84
+ //delete product API
85
+ const deleteProduct = async (selectedProductId: any) => {
86
+ try {
87
+ const response = (await callDeleteProduct({
88
+ payload: {
89
+ return_order_product_id: selectedProductId,
90
+ return_order_id: +orderId,
91
+ },
92
+ })) as {
93
+ code: number | null;
94
+ error?: string | null;
95
+ data?: any[];
96
+ message?: string;
97
+ };
98
+
99
+ if (response?.code === 200) {
100
+ notification.success({
101
+ message: 'Success',
102
+ description: response?.message || 'Product deleted successfully.',
103
+ });
104
+ props?.callReturnProducts();
105
+ } else {
106
+ notification.error({
107
+ message: 'Deletion Failed',
108
+ description: response?.message || 'Could not delete the product.',
109
+ });
110
+ }
111
+ } catch (error) {
112
+ console.error('Error deleting product:', error);
113
+ notification.error({
114
+ message: 'Error',
115
+ //@ts-ignore
116
+ description: error?.message || 'An unexpected error occurred.',
117
+ });
118
+ }
119
+ };
120
+
81
121
  const disableCheckbox =
82
122
  productData?.length == 0 || returnOrderData?.length == 0;
83
123
 
@@ -140,8 +180,7 @@ const ReturnProductTable = () => {
140
180
  <td>
141
181
  <div
142
182
  onClick={() => {
143
- handleActionClick(product?.id);
144
- onDeleteProducts();
183
+ deleteProduct(product?.id);
145
184
  }}
146
185
  style={{ cursor: 'pointer' }}
147
186
  >