@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,201 @@
1
+ import { RadioButtonGroup } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { useOrderDetails, useOrderStaticData } from '../../../../store';
5
+ import { OrderServiceType } from '../../../../types';
6
+ import { capitalize } from '../../../../utils';
7
+
8
+ export const radioButtonFilterOptions = [
9
+ { label: 'Yes', value: 'true' },
10
+ { label: 'No', value: 'false' },
11
+ ];
12
+
13
+ function RadioButtonGroups() {
14
+ const [orderStaticData] = useOrderStaticData();
15
+ const [orderDetails, setOrderDetails] = useOrderDetails();
16
+
17
+ const serviceLevelOptions = orderStaticData?.order_service_levels?.map(
18
+ (x: any) => ({
19
+ label: capitalize(x.type.replaceAll('_', ' ')),
20
+ value: x.id.toString(),
21
+ })
22
+ );
23
+
24
+ const deliveryPointOptions = orderStaticData?.order_delivery_point?.map(
25
+ (x: any) => ({
26
+ label: capitalize(x.type.replaceAll('_', ' ')),
27
+ value: x.id.toString(),
28
+ })
29
+ );
30
+
31
+ const serviceTypeOptions = orderStaticData?.order_type?.map(
32
+ (option: any) => ({
33
+ label: capitalize(option.type.replaceAll('_', ' ')),
34
+ value: option.id.toString(),
35
+ })
36
+ );
37
+
38
+ const orderServicesOptions = orderStaticData?.order_service_list;
39
+ const orderServices = orderDetails?.order_services;
40
+ const deliveryPointId = orderDetails?.order_services_detail?.order_delivery_point_id?.toString();
41
+ const serviceLevelId = orderDetails?.order_services_detail?.order_service_level_id?.toString();
42
+ const orderTypeId = orderDetails?.order_type_id?.toString();
43
+
44
+ // ON CHANGE HANDLERS
45
+ const onChangeDeliveryPoint = (
46
+ event: React.ChangeEvent<HTMLInputElement>
47
+ ) => {
48
+ const updatedServices = {
49
+ ...orderDetails?.order_services_detail!,
50
+ order_delivery_point_id: +event.target.value,
51
+ };
52
+ const newData = { ...orderDetails, order_services_detail: updatedServices };
53
+ setOrderDetails(newData);
54
+ };
55
+
56
+ const onChangeServiceLevel = (event: React.ChangeEvent<HTMLInputElement>) => {
57
+ const updatedServices = {
58
+ ...orderDetails?.order_services_detail!,
59
+ order_service_level_id: +event.target.value,
60
+ };
61
+ const newData = { ...orderDetails, order_services_detail: updatedServices };
62
+ setOrderDetails(newData);
63
+ };
64
+
65
+ const onChangeServiceType = (event: React.ChangeEvent<HTMLInputElement>) => {
66
+ const newData = { ...orderDetails, order_type_id: +event.target.value };
67
+ setOrderDetails(newData);
68
+ };
69
+
70
+ const onChangeServices = (id: number) => {
71
+ const clone = [...orderServices];
72
+
73
+ // Check if the service already exists in the order
74
+ const selectedService = clone.find(
75
+ (s: OrderServiceType) => s.order_service_list_id === id
76
+ );
77
+
78
+ if (selectedService !== undefined) {
79
+ if (selectedService.new_id) {
80
+ // It's a newly added service, just remove it
81
+ const updatedOrderServices = clone.filter(
82
+ (service: OrderServiceType) => service.id !== selectedService.id
83
+ );
84
+ const newData = {
85
+ ...orderDetails,
86
+ order_services: updatedOrderServices,
87
+ };
88
+ setOrderDetails(newData);
89
+ } else {
90
+ // It's an existing (persisted) service, toggle its `is_deleted` flag
91
+ const updatedSelectedService = {
92
+ ...selectedService,
93
+ is_deleted: !selectedService.is_deleted,
94
+ };
95
+
96
+ const updatedOrderServices = clone
97
+ .filter(
98
+ (service: OrderServiceType) => service.id !== selectedService.id
99
+ )
100
+ .concat(updatedSelectedService);
101
+
102
+ const newData = {
103
+ ...orderDetails,
104
+ order_services: updatedOrderServices,
105
+ };
106
+ setOrderDetails(newData);
107
+ }
108
+ } else {
109
+ // Case 2: Service doesn't exist — add it as a new one
110
+ const newService: OrderServiceType = {
111
+ is_deleted: false,
112
+ order_service_list_id: id,
113
+ new_id: id,
114
+ id: id,
115
+ };
116
+
117
+ clone.push(newService);
118
+
119
+ const newData = {
120
+ ...orderDetails,
121
+ order_services: clone,
122
+ };
123
+
124
+ setOrderDetails(newData);
125
+ }
126
+ };
127
+
128
+ return (
129
+ <Container>
130
+ <Group>
131
+ <RadioButtonGroup
132
+ heading="Service Type"
133
+ onChange={onChangeServiceType}
134
+ options={serviceTypeOptions || []}
135
+ selectedValue={orderTypeId || ''}
136
+ direction="vertical"
137
+ required={false}
138
+ isDisabled
139
+ />
140
+ </Group>
141
+ <Group>
142
+ <RadioButtonGroup
143
+ heading="Service Level"
144
+ onChange={onChangeServiceLevel}
145
+ options={serviceLevelOptions || []}
146
+ selectedValue={serviceLevelId || ''}
147
+ direction="vertical"
148
+ required={false}
149
+ isDisabled
150
+ />
151
+ </Group>
152
+ <Group>
153
+ <RadioButtonGroup
154
+ heading="Delivery Point"
155
+ onChange={onChangeDeliveryPoint}
156
+ options={deliveryPointOptions || []}
157
+ selectedValue={deliveryPointId || ''}
158
+ direction="vertical"
159
+ required={false}
160
+ isDisabled
161
+ />
162
+ </Group>
163
+
164
+ {orderServicesOptions?.map((service: any) => {
165
+ const selected = !!orderServices?.find(
166
+ (s: OrderServiceType) =>
167
+ s?.order_service_list_id === service?.id && s.is_deleted === false
168
+ );
169
+
170
+ return (
171
+ <Group>
172
+ <RadioButtonGroup
173
+ heading={service?.type?.replaceAll('_', ' ')}
174
+ onChange={() => onChangeServices(service?.id)}
175
+ options={radioButtonFilterOptions || []}
176
+ selectedValue={selected === false ? 'false' : 'true'}
177
+ direction="vertical"
178
+ required={false}
179
+ isDisabled
180
+ />
181
+ </Group>
182
+ );
183
+ })}
184
+ </Container>
185
+ );
186
+ }
187
+ const Container = styled.div`
188
+ display: flex;
189
+ flex-wrap: wrap;
190
+ gap: 16px;
191
+ padding: 8px;
192
+ width: 100%;
193
+ align-items: flex-start;
194
+ pointer-events: none;
195
+ `;
196
+
197
+ const Group = styled.div`
198
+ flex: 1;
199
+ `;
200
+
201
+ export default RadioButtonGroups;
@@ -0,0 +1,40 @@
1
+ import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { useOrderCancelReason, useOrderStaticData } from '../../../../../store';
5
+
6
+ function CancellationReasonDropdown() {
7
+ const [cancelationReason, setCancelationReason] = useOrderCancelReason();
8
+ const [orderStaticData] = useOrderStaticData();
9
+ const cancellationReasonOptions =
10
+ orderStaticData?.cancellation_reasons?.map((x: any) => ({
11
+ label: x.reason,
12
+ value: x.id,
13
+ })) || [];
14
+ return (
15
+ <Container>
16
+ <Label
17
+ label="Cancellation Reason"
18
+ htmlFor="cancellationreasondropdown"
19
+ required
20
+ />
21
+ <SelectDropdown
22
+ placeholder="Select Reason"
23
+ options={cancellationReasonOptions || []}
24
+ inputId="cancellationreasondropdown"
25
+ openMenuOnFocus
26
+ value={cancelationReason}
27
+ onChange={selectedOption => setCancelationReason(selectedOption)}
28
+ />
29
+ </Container>
30
+ );
31
+ }
32
+
33
+ const Container = styled.div`
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: 6px;
37
+ flex: 1;
38
+ `;
39
+
40
+ export default CancellationReasonDropdown;
@@ -0,0 +1,108 @@
1
+ import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import {
5
+ useFailureReason,
6
+ useIsFailureReasonChanged,
7
+ useOrderStaticData,
8
+ } from '../../../../../store';
9
+
10
+ function FailureReasonDropdown() {
11
+ const [orderStaticData] = useOrderStaticData();
12
+ const [failureReasonState, setFailureReason] = useFailureReason();
13
+ const [, setIsFailureReasonChanged] = useIsFailureReasonChanged(); // to map esc reason properly
14
+ const failureReasons = orderStaticData?.failure_reasons;
15
+ const escalationCategory = orderStaticData?.escalation_category;
16
+ const escalationTypes = orderStaticData?.escalation_types;
17
+ const faultNonFaultReasons = orderStaticData?.fault_non_fault_reasons;
18
+
19
+ // Step 1: Get IDs of "Failure-Non_Fault" and "Failure-Fault"
20
+ const failureNonFaultId = escalationCategory?.find(
21
+ (category: any) => category?.type === 'Failure - Non Fault'
22
+ )?.id;
23
+ const failureFaultId = escalationCategory?.find(
24
+ (category: any) => category?.type === 'Failure - Fault'
25
+ )?.id;
26
+
27
+ // Step 2: Map to get escalation type IDs
28
+
29
+ const failureNonFaultEscTypeId = escalationTypes?.filter(
30
+ (type: any) => type?.escalation_category_id === failureNonFaultId
31
+ )[0]?.id;
32
+ const failureFaultEscTypeId = escalationTypes?.filter(
33
+ (type: any) => type?.escalation_category_id === failureFaultId
34
+ )[0]?.id;
35
+
36
+ // Step 3: Separate fault and non-fault reasons
37
+ const nonFaultReasons = faultNonFaultReasons?.filter(
38
+ (reason: any) => reason?.escalation_type_id === failureNonFaultEscTypeId
39
+ );
40
+ const faultReasons = faultNonFaultReasons?.filter(
41
+ (reason: any) => reason?.escalation_type_id === failureFaultEscTypeId
42
+ );
43
+
44
+ // Step 4: Simplified mapping to failureReasons
45
+ const mapReasonsToFailures = (reasons: any) => {
46
+ const reasonIds = new Set(
47
+ reasons?.map((reason: any) => reason?.order_reason_id)
48
+ );
49
+ return failureReasons
50
+ ?.filter((failure: any) => reasonIds?.has(failure?.id))
51
+ ?.map((failure: any) => ({
52
+ value: failure?.reason,
53
+ label: failure?.title,
54
+ id: failure?.id,
55
+ }));
56
+ };
57
+
58
+ const faultReasonOptions = mapReasonsToFailures(faultReasons);
59
+ const nonFaultReasonOptions = mapReasonsToFailures(nonFaultReasons);
60
+
61
+ const groupedOptions: any = [
62
+ {
63
+ label: 'Fault Reasons',
64
+ options: faultReasonOptions,
65
+ },
66
+ {
67
+ label: 'Non-Fault Reasons',
68
+ options: nonFaultReasonOptions,
69
+ },
70
+ ];
71
+
72
+ const onChangeOption = (option: any) => {
73
+ setFailureReason(option);
74
+ setIsFailureReasonChanged(true);
75
+ };
76
+
77
+ const formatGroupLabel = (data: any) => (
78
+ <div style={{ color: 'rgba(0,0,0,0.8)' }}>
79
+ <span>{data?.label}</span>
80
+ {/* <span>{data?.options?.length}</span> */}
81
+ </div>
82
+ );
83
+
84
+ return (
85
+ <Container>
86
+ <Label label="Failure Reason" htmlFor="failurereasondropdown" required />
87
+ <SelectDropdown
88
+ placeholder="Select Reason"
89
+ options={groupedOptions || []}
90
+ inputId="failurereasondropdown"
91
+ openMenuOnFocus
92
+ value={failureReasonState}
93
+ onChange={onChangeOption}
94
+ formatGroupLabel={formatGroupLabel}
95
+ isDisabled={false}
96
+ />
97
+ </Container>
98
+ );
99
+ }
100
+
101
+ const Container = styled.div`
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 6px;
105
+ flex: 1;
106
+ `;
107
+
108
+ export default FailureReasonDropdown;
@@ -0,0 +1,37 @@
1
+ import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { useOrderHoldReason, useOrderStaticData } from '../../../../../store';
5
+
6
+ function OrderHoldReasonDropdown() {
7
+ const [orderStaticData] = useOrderStaticData();
8
+ const [orderHold, setOrderHold] = useOrderHoldReason();
9
+ const holdReasonOptions =
10
+ orderStaticData?.onhold_reasons?.map((x: any) => ({
11
+ label: x.reason,
12
+ value: x.id,
13
+ })) || [];
14
+ return (
15
+ <Container>
16
+ <Label label="Hold Reason" htmlFor="holdreasondropdown" required />
17
+ <SelectDropdown
18
+ placeholder="Select Reason"
19
+ options={holdReasonOptions || []}
20
+ inputId="holdreasondropdown"
21
+ openMenuOnFocus
22
+ value={orderHold}
23
+ onChange={selectedOption => setOrderHold(selectedOption)}
24
+ // isDisabled={isDisable}
25
+ />
26
+ </Container>
27
+ );
28
+ }
29
+
30
+ const Container = styled.div`
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: 6px;
34
+ flex: 1;
35
+ `;
36
+
37
+ export default OrderHoldReasonDropdown;
@@ -0,0 +1,48 @@
1
+ import { Label, SelectDropdown } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import {
5
+ useChargesState,
6
+ useNewStatus,
7
+ useOrderStaticData,
8
+ } from '../../../../../store';
9
+
10
+ function StatusDropdown() {
11
+ const [orderStaticData] = useOrderStaticData();
12
+ const [newStatus, setNewStatus] = useNewStatus();
13
+ const [, setCharges] = useChargesState();
14
+ const newStatusOptions = orderStaticData?.new_status?.map((x: any) => ({
15
+ label: x.type,
16
+ value: x.id,
17
+ }));
18
+ const selectedOption =
19
+ newStatusOptions?.find((option: any) => option.label === newStatus) || null;
20
+
21
+ const onChange = (option: any) => {
22
+ setNewStatus(option?.label);
23
+ setCharges(prev => ({ ...prev, new_order_status: option?.label }));
24
+ };
25
+ return (
26
+ <Container>
27
+ <Label label="New Status" htmlFor="statusdropdown" required />
28
+ <SelectDropdown
29
+ placeholder="Select Status"
30
+ options={newStatusOptions || []}
31
+ inputId="statusdropdown"
32
+ value={selectedOption} // Set the selected option here
33
+ openMenuOnFocus
34
+ onChange={onChange}
35
+ isDisabled={false}
36
+ />
37
+ </Container>
38
+ );
39
+ }
40
+
41
+ const Container = styled.div`
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: 6px;
45
+ flex: 1;
46
+ `;
47
+
48
+ export default StatusDropdown;
@@ -0,0 +1,27 @@
1
+ import { Label } from '@bjsdistribution/dms-component-library';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { Input } from '../../styles';
5
+
6
+ function ZoneDropdown() {
7
+ return (
8
+ <Container>
9
+ <Label label="Zone" htmlFor="zoneDropdown" />
10
+ <Input
11
+ placeholder=""
12
+ value={''}
13
+ onChange={() => {}}
14
+ style={{ marginRight: '8px', flex: 1 }}
15
+ />
16
+ </Container>
17
+ );
18
+ }
19
+
20
+ const Container = styled.div`
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 6px;
24
+ flex: 1;
25
+ `;
26
+
27
+ export default ZoneDropdown;
@@ -0,0 +1,187 @@
1
+ import React from 'react';
2
+ import FailureReasonDropdown from '../dropdowns/FailureReasonDropdown';
3
+ import StatusDropdown from '../dropdowns/StatusDropdown';
4
+ import styled from 'styled-components';
5
+ import { Label, TextArea } from '@bjsdistribution/dms-component-library';
6
+ import CancellationReasonDropdown from '../dropdowns/CancellationReasonDropdown';
7
+ import OrderHoldReasonDropdown from '../dropdowns/OrderHoldReasonDropdown';
8
+ import {
9
+ useChargesState,
10
+ useNewStatus,
11
+ useOrderDetails,
12
+ useProductDetails,
13
+ } from '../../../../../store';
14
+ import { getBaseUrlSymbol } from '../../../../../utils';
15
+
16
+ function FailureContent() {
17
+ const [newStatus] = useNewStatus();
18
+ const [orderDetails] = useOrderDetails();
19
+ const [chargesState] = useChargesState();
20
+ const baseUrlSymbol = getBaseUrlSymbol();
21
+
22
+ const [productdata] = useProductDetails();
23
+ const sortedProductData = productdata?.sort((a: any, b: any) => {
24
+ return a?.status === b?.status ? 0 : a?.status ? -1 : 1;
25
+ });
26
+
27
+ const products = Array.isArray(sortedProductData)
28
+ ? sortedProductData?.filter(item => item?.status === true)
29
+ : [];
30
+
31
+ const excludedFields = [
32
+ 'debrief_notes',
33
+ 'new_order_status',
34
+ 'base_charge_type',
35
+ 'adhoc_charges',
36
+ 'debrief_status',
37
+ ]; // Fields to exclude
38
+ let totalChargesAmount = 0;
39
+
40
+ for (const [key, value] of Object.entries(chargesState)) {
41
+ if (!excludedFields.includes(key) && typeof value === 'number') {
42
+ totalChargesAmount += value;
43
+ }
44
+ }
45
+
46
+ const adhocTotalCharges =
47
+ chargesState?.adhoc_charges?.length > 0
48
+ ? chargesState?.adhoc_charges?.reduce(
49
+ (acc, item) => acc + item.adhoc_charges,
50
+ 0
51
+ )
52
+ : 0;
53
+
54
+ return (
55
+ <>
56
+ <DropdownGrid>
57
+ <DropdownGroup>
58
+ <FailureReasonDropdown />
59
+ </DropdownGroup>
60
+ <DropdownGroup>
61
+ <StatusDropdown />
62
+ </DropdownGroup>
63
+ {newStatus === 'Cancelled' && (
64
+ <DropdownGroup>
65
+ <CancellationReasonDropdown />
66
+ </DropdownGroup>
67
+ )}
68
+ {newStatus === 'On Hold' && (
69
+ <DropdownGroup>
70
+ <OrderHoldReasonDropdown />
71
+ </DropdownGroup>
72
+ )}
73
+ <GroupedFields>
74
+ <PairGroup>
75
+ <SmallGroup>
76
+ <Label label="Items" htmlFor="items" />
77
+ <Text>{products?.length}</Text>
78
+ </SmallGroup>
79
+ <SmallGroup>
80
+ <Label label="Total Charge" htmlFor="totalCharge" />
81
+ <div
82
+ style={{ display: 'flex', gap: '4px', alignItems: 'center' }}
83
+ >
84
+ <CurrencyWrapper>{baseUrlSymbol}</CurrencyWrapper>
85
+ <Text>{totalChargesAmount + adhocTotalCharges}</Text>
86
+ </div>
87
+ </SmallGroup>
88
+ </PairGroup>
89
+
90
+ <PairGroup>
91
+ <SmallGroup>
92
+ <Label label="Weight" htmlFor="weight" />
93
+ <Text>{orderDetails?.weight}Kg</Text>
94
+ </SmallGroup>
95
+ </PairGroup>
96
+ </GroupedFields>
97
+ </DropdownGrid>
98
+ <ContDropdownGrid>
99
+ <FieldGroup wide>
100
+ <Label label="Order Status Notes" htmlFor="notes" />
101
+ <TextInput
102
+ id="notes"
103
+ placeholder="Type notes here..."
104
+ value={orderDetails?.order_status_note || ''}
105
+ readOnly
106
+ />
107
+ </FieldGroup>
108
+
109
+ <FieldGroup wide>
110
+ <Label label="Charge Description" htmlFor="chargedescription" />
111
+ <TextInput
112
+ id="chargedescription"
113
+ placeholder="Type charge description here..."
114
+ onChange={() => {}}
115
+ />
116
+ </FieldGroup>
117
+ </ContDropdownGrid>
118
+ </>
119
+ );
120
+ }
121
+
122
+ const CurrencyWrapper = styled.span`
123
+ display: flex;
124
+ align-items: center;
125
+ color: #999;
126
+ `;
127
+
128
+ const Text = styled.div`
129
+ color: #363a30;
130
+ font-size: 14px;
131
+ `;
132
+ const GroupedFields = styled.div`
133
+ display: flex;
134
+ gap: 7px;
135
+ `;
136
+
137
+ const PairGroup = styled.div`
138
+ display: flex;
139
+ flex-direction: row;
140
+ gap: 20px;
141
+
142
+ @media (max-width: 768px) {
143
+ flex-direction: column;
144
+ }
145
+ `;
146
+
147
+ const SmallGroup = styled.div`
148
+ display: flex;
149
+ flex-direction: column;
150
+ gap: 6px;
151
+ min-width: 140px;
152
+ flex: 1;
153
+ `;
154
+ const FieldGroup = styled.div<{ wide?: boolean }>`
155
+ display: flex;
156
+ flex-direction: column;
157
+ gap: 6px;
158
+ flex: ${props => (props.wide ? 2 : 1)};
159
+ min-width: ${props => (props.wide ? '300px' : '220px')};
160
+ `;
161
+
162
+ const TextInput = styled(TextArea)`
163
+ resize: none;
164
+ width: 100%;
165
+ min-height: 180px;
166
+ `;
167
+
168
+ const DropdownGrid = styled.div`
169
+ display: flex;
170
+ flex-direction: column;
171
+ gap: 20px;
172
+ `;
173
+
174
+ const ContDropdownGrid = styled.div`
175
+ display: flex;
176
+ gap: 20px;
177
+ `;
178
+
179
+ const DropdownGroup = styled.div`
180
+ flex: 1 1 calc(50% - 10px);
181
+
182
+ @media (max-width: 768px) {
183
+ flex: 1 1 100%;
184
+ }
185
+ `;
186
+
187
+ export default FailureContent;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import FailureContent from './failure-content';
4
+ import SuccessContent from './success-content';
5
+ import RadioButtonGroups from './RadioButtons';
6
+ import { useActiveTab } from '../../../../store';
7
+
8
+ function OrderInfo() {
9
+ const [activeTab] = useActiveTab();
10
+ return (
11
+ <Container>
12
+ <Top>
13
+ {activeTab === 'success' ? <SuccessContent /> : <FailureContent />}
14
+ </Top>
15
+ <Middle>
16
+ <RadioButtonGroups />
17
+ </Middle>
18
+ {/* <Bottom>
19
+
20
+ </Bottom> */}
21
+ </Container>
22
+ );
23
+ }
24
+
25
+ // const DescriptionWrapper = styled.div`
26
+ // display: flex;
27
+ // gap: 20px;
28
+ // width: 100%;
29
+ // `;
30
+
31
+ const Middle = styled.div`
32
+ display: flex;
33
+ justify-content: space-between;
34
+ `;
35
+
36
+ // const Bottom = styled.div`
37
+ // display: flex;
38
+ // flex-direction: column;
39
+ // gap: 20px;
40
+ // `;
41
+
42
+ const Top = styled.div`
43
+ display: flex;
44
+ gap: 15px;
45
+ width: 100%;
46
+ `;
47
+
48
+ const Container = styled.div`
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 20px;
52
+ width: 100%;
53
+ `;
54
+
55
+ export default React.memo(OrderInfo);