@bjsdistribution/dms-client-return 0.1.7-prod → 0.1.8-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 (83) hide show
  1. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  2. package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
  3. package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
  4. package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
  5. package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
  6. package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
  7. package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
  8. package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
  9. package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
  10. package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
  11. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
  12. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
  13. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
  14. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
  15. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
  16. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
  17. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
  18. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
  19. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
  20. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
  21. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
  22. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
  23. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
  24. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
  25. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
  26. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
  27. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
  28. package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
  29. package/dist/components/order-view/products-info/expanded-content/index.d.ts +4 -1
  30. package/dist/components/order-view/return-client-products/ProductTable.d.ts +4 -1
  31. package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +4 -1
  32. package/dist/components/order-view/store.d.ts +14 -2
  33. package/dist/components/order-view/types.d.ts +49 -1
  34. package/dist/components/order-view/utils.d.ts +3 -0
  35. package/dist/dms-client-return.cjs.development.js +2636 -335
  36. package/dist/dms-client-return.cjs.development.js.map +1 -1
  37. package/dist/dms-client-return.cjs.production.min.js +1 -1
  38. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  39. package/dist/dms-client-return.esm.js +2700 -399
  40. package/dist/dms-client-return.esm.js.map +1 -1
  41. package/package.json +5 -3
  42. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +43 -15
  43. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +24 -11
  44. package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
  45. package/src/components/order-view/index.tsx +29 -0
  46. package/src/components/order-view/notes/AddNote.tsx +14 -34
  47. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
  48. package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
  49. package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +620 -0
  50. package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
  51. package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
  52. package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
  53. package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
  54. package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
  55. package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
  56. package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
  57. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
  58. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
  59. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
  60. package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
  61. package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
  62. package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
  63. package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
  64. package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
  65. package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +201 -0
  66. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
  67. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
  68. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
  69. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
  70. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
  71. package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
  72. package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
  73. package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
  74. package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
  75. package/src/components/order-view/order-actions/index.tsx +10 -0
  76. package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
  77. package/src/components/order-view/products-info/expanded-content/index.tsx +27 -11
  78. package/src/components/order-view/products-info/index.tsx +4 -4
  79. package/src/components/order-view/return-client-products/ProductTable.tsx +6 -2
  80. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +54 -15
  81. package/src/components/order-view/store.ts +106 -0
  82. package/src/components/order-view/types.ts +54 -1
  83. package/src/components/order-view/utils.ts +37 -0
@@ -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
+ `;
@@ -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();
@@ -237,6 +238,15 @@ function OrderActions() {
237
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':
@@ -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
  >
@@ -2,6 +2,7 @@ import { atom, useAtom } from 'jotai';
2
2
  import { atomWithReducer } from 'jotai/utils';
3
3
  import {
4
4
  CancelOrderProductsType,
5
+ ChargesType,
5
6
  CreateProduct,
6
7
  OrderActionsType,
7
8
  OrdersType,
@@ -109,6 +110,9 @@ export const ordersInitialValue: OrdersType = {
109
110
  id: null,
110
111
  name: '',
111
112
  carrier_id: null,
113
+ order_type: {
114
+ type: null,
115
+ },
112
116
  };
113
117
 
114
118
  export const orderProductInitialvalue: CreateProduct = {
@@ -140,6 +144,42 @@ export const updateOrderProducts: UpdateOrderProduct = {
140
144
  return_reason_id: 0,
141
145
  };
142
146
 
147
+ //force debrief
148
+ const chargesIntialValue: ChargesType = {
149
+ base_charge_type: 1,
150
+ base_charge: 0,
151
+ weight: 0,
152
+ drop_time: 0,
153
+ timed_service: 0,
154
+ wait_time: 0,
155
+ extra_floor: 0,
156
+ bulky_items: 0,
157
+ re_label: 0,
158
+ extra_cube: 0,
159
+ additional_box: 0,
160
+ additional_item: 0,
161
+ weekend: 0,
162
+ re_allocation: 0,
163
+ pre_dated: 0,
164
+ re_package: 0,
165
+ disassemble: 0,
166
+ qc: 0,
167
+ collection_qc: 0,
168
+ return_to_client: 0,
169
+ roc: 0,
170
+ unpack: 0,
171
+ packaging_disposal: 0,
172
+ assembly: 0,
173
+ debrief_notes: '',
174
+ recycle: 0,
175
+ admin: 0,
176
+ disposal: 0,
177
+ disposal_recycling: 0,
178
+ debrief_status: '',
179
+ new_order_status: '',
180
+ adhoc_charges: [],
181
+ };
182
+
143
183
  export const usedate = () => {
144
184
  return useAtom(date);
145
185
  };
@@ -243,6 +283,11 @@ export function useOrderAlertsData() {
243
283
  return useAtom(orderAlertsData);
244
284
  }
245
285
 
286
+ const customerList = atom<any>([]);
287
+ export function useOrderCustomersList() {
288
+ return useAtom(customerList);
289
+ }
290
+
246
291
  export {
247
292
  useTabType,
248
293
  useInfoType,
@@ -558,6 +603,67 @@ export function useGlobalStateHitOrder() {
558
603
  return useAtom(globalOrderGetApi);
559
604
  }
560
605
 
606
+ //force debrief states
607
+ const globalEscData = atom<any>([]);
608
+ export function useGlobalEscData() {
609
+ return useAtom(globalEscData);
610
+ }
611
+
612
+ const activeTab = atom<any>('success');
613
+
614
+ export function useActiveTab() {
615
+ return useAtom(activeTab);
616
+ }
617
+
618
+ const chargesStateAtom = atom<ChargesType>(chargesIntialValue);
619
+
620
+ export function useChargesState() {
621
+ return useAtom(chargesStateAtom);
622
+ }
623
+
624
+ const failureReasonAtom = atom<any>('');
625
+ export function useFailureReason() {
626
+ return useAtom(failureReasonAtom);
627
+ }
628
+
629
+ const escalationCategoryAtom = atom<any>('');
630
+
631
+ export function useEscalationCategory() {
632
+ return useAtom(escalationCategoryAtom);
633
+ }
634
+
635
+ const escalationLevelAtom = atom<any>('');
636
+
637
+ export function useEscalationLevel() {
638
+ return useAtom(escalationLevelAtom);
639
+ }
640
+
641
+ const escalationReasonAtom = atom<any>('');
642
+
643
+ export function useEscalationReason() {
644
+ return useAtom(escalationReasonAtom);
645
+ }
646
+
647
+ const newStatusAtom = atom<any>('');
648
+ export function useNewStatus() {
649
+ return useAtom(newStatusAtom);
650
+ }
651
+
652
+ const orderCancelReasonAtom = atom<any>('');
653
+ export function useOrderCancelReason() {
654
+ return useAtom(orderCancelReasonAtom);
655
+ }
656
+
657
+ const orderHoldReasonAtom = atom<any>('');
658
+ export function useOrderHoldReason() {
659
+ return useAtom(orderHoldReasonAtom);
660
+ }
661
+
662
+ const isFailureReasonChangedAtom = atom<boolean>(false);
663
+ export function useIsFailureReasonChanged() {
664
+ return useAtom(isFailureReasonChangedAtom);
665
+ }
666
+
561
667
  // Popup state Manage
562
668
  const initialState = null;
563
669