@bjsdistribution/dms-client-return 0.1.20-dev → 0.1.20-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 (177) hide show
  1. package/dist/common/date-picker/header/ClearDate.d.ts +1 -1
  2. package/dist/components/client-portal/DateFilterStore.d.ts +15 -0
  3. package/dist/components/client-portal/ReturnRTFilters.d.ts +3 -0
  4. package/dist/components/order-daily-overview/header/route-header/ClientRouterHeader.d.ts +11 -0
  5. package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
  6. package/dist/components/order-view/DynamicTable.d.ts +2 -1
  7. package/dist/components/order-view/general-information/Status.d.ts +1 -1
  8. package/dist/components/order-view/general-information/index.d.ts +1 -1
  9. package/dist/components/order-view/index.d.ts +1 -1
  10. package/dist/components/order-view/notes/AddNote.d.ts +1 -0
  11. package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
  12. package/dist/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.d.ts +4 -1
  13. package/dist/components/order-view/order-actions/actions/confirm-order/index.d.ts +4 -1
  14. package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
  15. package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
  16. package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
  17. package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
  18. package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
  19. package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
  20. package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
  21. package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
  22. package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
  23. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
  24. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
  25. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
  26. package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
  27. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
  28. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
  29. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
  30. package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
  31. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
  32. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
  33. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
  34. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
  35. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
  36. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
  37. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
  38. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
  39. package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
  40. package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
  41. package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +1 -0
  42. package/dist/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.d.ts +1 -1
  43. package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +1 -0
  44. package/dist/components/order-view/order-actions/types.d.ts +3 -3
  45. package/dist/components/order-view/order-details/expanded-content/index.d.ts +1 -1
  46. package/dist/components/order-view/order-details/index.d.ts +1 -1
  47. package/dist/components/order-view/order-resources/expanded-content/index.d.ts +1 -1
  48. package/dist/components/order-view/products-info/expanded-content/index.d.ts +6 -1
  49. package/dist/components/order-view/products-info/index.d.ts +1 -1
  50. package/dist/components/order-view/return-client-products/ProductTable.d.ts +6 -1
  51. package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +6 -1
  52. package/dist/components/order-view/store.d.ts +15 -3
  53. package/dist/components/order-view/system-event-logs/expanded-content/index.d.ts +1 -1
  54. package/dist/components/order-view/types.d.ts +55 -1
  55. package/dist/components/order-view/utils.d.ts +11 -2
  56. package/dist/components/store.d.ts +1 -1
  57. package/dist/dms-client-return.cjs.development.js +7157 -4661
  58. package/dist/dms-client-return.cjs.development.js.map +1 -1
  59. package/dist/dms-client-return.cjs.production.min.js +1 -1
  60. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  61. package/dist/dms-client-return.esm.js +7173 -4677
  62. package/dist/dms-client-return.esm.js.map +1 -1
  63. package/package.json +6 -4
  64. package/src/assets/icons/ActionIcon.tsx +1 -1
  65. package/src/assets/icons/ArrowDownIcon.tsx +2 -2
  66. package/src/components/client-portal/DateFilterStore.ts +139 -0
  67. package/src/components/client-portal/OutstandingTable.tsx +16 -72
  68. package/src/components/client-portal/ReturnAfterSearchBar.tsx +42 -87
  69. package/src/components/client-portal/ReturnOverview.tsx +11 -2
  70. package/src/components/client-portal/ReturnRTFilters.tsx +140 -43
  71. package/src/components/client-portal/ReturnSearchBar.tsx +42 -153
  72. package/src/components/client-portal/ReturnStatus.tsx +33 -82
  73. package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +12 -23
  74. package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +9 -86
  75. package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +166 -0
  76. package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +2 -86
  77. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +46 -15
  78. package/src/components/order-daily-overview/index.tsx +23 -4
  79. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +6 -1
  80. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +3 -0
  81. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +36 -36
  82. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +12 -2
  83. package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +16 -0
  84. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +25 -11
  85. package/src/components/order-daily-overview/table/ReturnTable.tsx +8 -4
  86. package/src/components/order-view/DynamicTable.tsx +21 -8
  87. package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +1 -1
  88. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +9 -0
  89. package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
  90. package/src/components/order-view/flags-action-modal/Dropdowns.tsx +2 -0
  91. package/src/components/order-view/general-information/Status.tsx +92 -18
  92. package/src/components/order-view/general-information/index.tsx +2 -2
  93. package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
  94. package/src/components/order-view/index.tsx +50 -8
  95. package/src/components/order-view/modalsPopup/ModalManager.tsx +1 -1
  96. package/src/components/order-view/notes/AddNote.tsx +95 -65
  97. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
  98. package/src/components/order-view/notification/FlagTemplate.tsx +21 -10
  99. package/src/components/order-view/notification/OrderTemplate.tsx +192 -41
  100. package/src/components/order-view/notification/ReminderTemplate.tsx +28 -13
  101. package/src/components/order-view/notification/index.tsx +100 -55
  102. package/src/components/order-view/order-actions/actions/add-resources/DocFileUpload.tsx +92 -72
  103. package/src/components/order-view/order-actions/actions/add-resources/index.tsx +27 -10
  104. package/src/components/order-view/order-actions/actions/cancel-order/ReturnAction.tsx +25 -4
  105. package/src/components/order-view/order-actions/actions/cancel-order/ReturnReason.tsx +24 -4
  106. package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +9 -2
  107. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +12 -35
  108. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +1 -0
  109. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +88 -30
  110. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +5 -3
  111. package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +2 -2
  112. package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
  113. package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +635 -0
  114. package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
  115. package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
  116. package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
  117. package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
  118. package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
  119. package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
  120. package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
  121. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
  122. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
  123. package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
  124. package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
  125. package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
  126. package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
  127. package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
  128. package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
  129. package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +150 -0
  130. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
  131. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
  132. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
  133. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
  134. package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
  135. package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
  136. package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
  137. package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
  138. package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
  139. package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +2 -0
  140. package/src/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.tsx +7 -2
  141. package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +2 -0
  142. package/src/components/order-view/order-actions/index.tsx +19 -10
  143. package/src/components/order-view/order-actions/store.ts +1 -1
  144. package/src/components/order-view/order-actions/types.ts +3 -3
  145. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +102 -45
  146. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +93 -34
  147. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +88 -31
  148. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +55 -80
  149. package/src/components/order-view/order-details/expanded-content/index.tsx +37 -16
  150. package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
  151. package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx +9 -91
  152. package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +10 -182
  153. package/src/components/order-view/order-details/expanded-content/services-section/ServiceLevel.tsx +3 -4
  154. package/src/components/order-view/order-details/index.tsx +5 -2
  155. package/src/components/order-view/order-resources/expanded-content/index.tsx +2 -2
  156. package/src/components/order-view/products-info/expanded-content/index.tsx +33 -11
  157. package/src/components/order-view/products-info/index.tsx +10 -6
  158. package/src/components/order-view/return-client-products/ProductTable.tsx +12 -2
  159. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +73 -23
  160. package/src/components/order-view/store.ts +113 -1
  161. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +6 -2
  162. package/src/components/order-view/types.ts +60 -1
  163. package/src/components/order-view/utils.ts +49 -33
  164. package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +85 -26
  165. package/src/components/order-view/view-reminder/ViewReminder.tsx +31 -14
  166. package/src/components/store.ts +2 -2
  167. package/src/index.tsx +23 -5
  168. package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +0 -7
  169. package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +0 -7
  170. package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +0 -7
  171. package/dist/components/order-view/order-actions/actions/log-service-refusal/helper.d.ts +0 -3
  172. package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +0 -3
  173. package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +0 -50
  174. package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +0 -50
  175. package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +0 -57
  176. package/src/components/order-view/order-actions/actions/log-service-refusal/helper.ts +0 -26
  177. package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +0 -130
@@ -0,0 +1,150 @@
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 { OrdersType } 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 deliveryPointId = orderDetails?.order_services_detail?.order_delivery_point_id?.toString();
40
+ const serviceLevelId = orderDetails?.order_services_detail?.order_service_level_id?.toString();
41
+ const orderTypeId = orderDetails?.order_type_id?.toString();
42
+
43
+ // ON CHANGE HANDLERS
44
+ const onChangeDeliveryPoint = (
45
+ event: React.ChangeEvent<HTMLInputElement>
46
+ ) => {
47
+ const updatedServices = {
48
+ ...orderDetails?.order_services_detail!,
49
+ order_delivery_point_id: +event.target.value,
50
+ };
51
+ const newData = { ...orderDetails, order_services_detail: updatedServices };
52
+ setOrderDetails(newData);
53
+ };
54
+
55
+ const onChangeServiceLevel = (event: React.ChangeEvent<HTMLInputElement>) => {
56
+ const updatedServices = {
57
+ ...orderDetails?.order_services_detail!,
58
+ order_service_level_id: +event.target.value,
59
+ };
60
+ const newData = { ...orderDetails, order_services_detail: updatedServices };
61
+ setOrderDetails(newData);
62
+ };
63
+
64
+ const onChangeServiceType = (event: React.ChangeEvent<HTMLInputElement>) => {
65
+ const newData = { ...orderDetails, order_type_id: +event.target.value };
66
+ setOrderDetails(newData);
67
+ };
68
+
69
+ const onChangeServices = (id: number) => {
70
+ const selectedService = orderServicesOptions?.find(
71
+ (item: any) => item.id === id
72
+ );
73
+ const key = selectedService?.type;
74
+ const value = !orderDetails[key as keyof OrdersType];
75
+ setOrderDetails(prev => ({
76
+ ...prev,
77
+ [key]: value,
78
+ }));
79
+ };
80
+
81
+ return (
82
+ <Container>
83
+ <Group>
84
+ <RadioButtonGroup
85
+ heading="Service Type"
86
+ onChange={onChangeServiceType}
87
+ options={serviceTypeOptions || []}
88
+ selectedValue={orderTypeId || ''}
89
+ direction="vertical"
90
+ required={false}
91
+ isDisabled
92
+ />
93
+ </Group>
94
+ <Group>
95
+ <RadioButtonGroup
96
+ heading="Service Level"
97
+ onChange={onChangeServiceLevel}
98
+ options={serviceLevelOptions || []}
99
+ selectedValue={serviceLevelId || ''}
100
+ direction="vertical"
101
+ required={false}
102
+ isDisabled
103
+ />
104
+ </Group>
105
+ <Group>
106
+ <RadioButtonGroup
107
+ heading="Delivery Point"
108
+ onChange={onChangeDeliveryPoint}
109
+ options={deliveryPointOptions || []}
110
+ selectedValue={deliveryPointId || ''}
111
+ direction="vertical"
112
+ required={false}
113
+ isDisabled
114
+ />
115
+ </Group>
116
+
117
+ {orderServicesOptions?.map((service: any) => {
118
+ const selected = orderDetails[service?.type as keyof OrdersType];
119
+ return (
120
+ <Group>
121
+ <RadioButtonGroup
122
+ heading={service?.type?.replaceAll('_', ' ')}
123
+ onChange={() => onChangeServices(service?.id)}
124
+ options={radioButtonFilterOptions || []}
125
+ selectedValue={selected ? 'true' : 'false'}
126
+ direction="vertical"
127
+ required={false}
128
+ isDisabled
129
+ />
130
+ </Group>
131
+ );
132
+ })}
133
+ </Container>
134
+ );
135
+ }
136
+ const Container = styled.div`
137
+ display: flex;
138
+ flex-wrap: wrap;
139
+ gap: 16px;
140
+ padding: 8px;
141
+ width: 100%;
142
+ align-items: flex-start;
143
+ pointer-events: none;
144
+ `;
145
+
146
+ const Group = styled.div`
147
+ flex: 1;
148
+ `;
149
+
150
+ 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);