@bjsdistribution/dms-client-return 0.0.94-prod → 0.0.95-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 (138) hide show
  1. package/dist/assets/icons/ArrowDownIcon.d.ts +6 -0
  2. package/dist/assets/icons/DeliverProductIcon.d.ts +3 -0
  3. package/dist/assets/icons/ReturnProductIcon.d.ts +3 -0
  4. package/dist/common/checkbox/index.d.ts +2 -0
  5. package/dist/common/modals/order-action-modal/OrderActionModal.d.ts +3 -1
  6. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.d.ts +1 -0
  7. package/dist/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.d.ts +2 -2
  8. package/dist/components/order-view/flags-action-modal/Actions.d.ts +6 -2
  9. package/dist/components/order-view/flags-action-modal/Dropdowns.d.ts +1 -0
  10. package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
  11. package/dist/components/order-view/notification/FlagTemplate.d.ts +1 -1
  12. package/dist/components/order-view/notification/OrderTemplate.d.ts +1 -1
  13. package/dist/components/order-view/notification/Tabs.d.ts +1 -1
  14. package/dist/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.d.ts +5 -0
  15. package/dist/components/order-view/order-actions/actions/cancel-order/index.d.ts +7 -1
  16. package/dist/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.d.ts +4 -1
  17. package/dist/components/order-view/order-actions/actions/charge-log/index.d.ts +11 -0
  18. package/dist/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.d.ts +1 -13
  19. package/dist/components/order-view/order-actions/actions/create-task-reminder/TaskModal.d.ts +5 -1
  20. package/dist/components/order-view/order-actions/actions/create-task-reminder/index.d.ts +6 -2
  21. package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +6 -1
  22. package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +5 -1
  23. package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +5 -3
  24. package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +5 -1
  25. package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +1 -1
  26. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +7 -1
  27. package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.d.ts +5 -0
  28. package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +6 -1
  29. package/dist/components/order-view/order-actions/store.d.ts +10 -8
  30. package/dist/components/order-view/order-actions/types.d.ts +38 -60
  31. package/dist/components/order-view/order-actions/utils.d.ts +2 -1
  32. package/dist/components/order-view/store.d.ts +48 -3
  33. package/dist/components/order-view/types.d.ts +11 -0
  34. package/dist/components/order-view/utils.d.ts +1 -0
  35. package/dist/components/order-view/view-reminder/ViewReminder.d.ts +5 -1
  36. package/dist/components/order-view/view-reminder/reminder-styles.d.ts +3 -1
  37. package/dist/components/store.d.ts +2 -1
  38. package/dist/dms-client-return.cjs.development.js +4812 -3095
  39. package/dist/dms-client-return.cjs.development.js.map +1 -1
  40. package/dist/dms-client-return.cjs.production.min.js +1 -1
  41. package/dist/dms-client-return.cjs.production.min.js.map +1 -1
  42. package/dist/dms-client-return.esm.js +4815 -3098
  43. package/dist/dms-client-return.esm.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/assets/icons/ArrowDownIcon.tsx +28 -0
  46. package/src/assets/icons/DeliverProductIcon.tsx +42 -0
  47. package/src/assets/icons/ReturnProductIcon.tsx +23 -0
  48. package/src/common/checkbox/index.tsx +60 -17
  49. package/src/common/modals/order-action-modal/OrderActionModal.tsx +13 -7
  50. package/src/common/radio-group/RadioButtonGroup.tsx +3 -4
  51. package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +29 -26
  52. package/src/components/order-daily-overview/header-filters/filterStore.ts +6 -8
  53. package/src/components/order-daily-overview/index.tsx +20 -7
  54. package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +2 -2
  55. package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +19 -19
  56. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +11 -9
  57. package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +19 -4
  58. package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +41 -59
  59. package/src/components/order-daily-overview/table/ReturnTable.tsx +1 -30
  60. package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +52 -2
  61. package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +37 -43
  62. package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +75 -44
  63. package/src/components/order-view/fakedata.ts +7 -6
  64. package/src/components/order-view/flags-action-modal/Actions.tsx +51 -25
  65. package/src/components/order-view/flags-action-modal/DetailSection.tsx +5 -5
  66. package/src/components/order-view/flags-action-modal/Dropdowns.tsx +75 -89
  67. package/src/components/order-view/flags-action-modal/Header.tsx +32 -23
  68. package/src/components/order-view/flags-action-modal/TextSection.tsx +9 -6
  69. package/src/components/order-view/flags-action-modal/index.tsx +54 -67
  70. package/src/components/order-view/general-information/dropdowns/Print.tsx +136 -70
  71. package/src/components/order-view/generic-table/AuditLogs.tsx +5 -4
  72. package/src/components/order-view/index.tsx +9 -42
  73. package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +20 -18
  74. package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -10
  75. package/src/components/order-view/notes/logs/index.tsx +1 -1
  76. package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +5 -7
  77. package/src/components/order-view/notification/FlagTemplate.tsx +8 -8
  78. package/src/components/order-view/notification/OrderTemplate.tsx +169 -175
  79. package/src/components/order-view/notification/ReminderTemplate.tsx +23 -14
  80. package/src/components/order-view/notification/Tabs.tsx +15 -14
  81. package/src/components/order-view/notification/index.tsx +164 -92
  82. package/src/components/order-view/order-actions/actions/add-resources/index.tsx +19 -29
  83. package/src/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.tsx +345 -0
  84. package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -71
  85. package/src/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.tsx +95 -32
  86. package/src/components/order-view/order-actions/actions/charge-log/index.tsx +395 -0
  87. package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +1 -1
  88. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +34 -17
  89. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +2 -3
  90. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +2 -3
  91. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +2 -3
  92. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +39 -25
  93. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +1 -1
  94. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +4 -2
  95. package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +1 -1
  96. package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +254 -66
  97. package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +1 -1
  98. package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +13 -9
  99. package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +1 -1
  100. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +213 -117
  101. package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +97 -152
  102. package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +30 -87
  103. package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +77 -83
  104. package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +57 -65
  105. package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +10 -16
  106. package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +21 -4
  107. package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +39 -11
  108. package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +79 -8
  109. package/src/components/order-view/order-actions/actions/send-email/SendEmailModal.tsx +114 -17
  110. package/src/components/order-view/order-actions/actions/send-sms/SendSmsModal.tsx +115 -7
  111. package/src/components/order-view/order-actions/actions/split-order/index.tsx +14 -4
  112. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +176 -87
  113. package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.tsx +352 -0
  114. package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +35 -59
  115. package/src/components/order-view/order-actions/index.tsx +237 -22
  116. package/src/components/order-view/order-actions/store.ts +50 -48
  117. package/src/components/order-view/order-actions/types.ts +40 -65
  118. package/src/components/order-view/order-actions/utils.ts +15 -8
  119. package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +2 -1
  120. package/src/components/order-view/order-details/expanded-content/footer/index.tsx +80 -39
  121. package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +10 -14
  122. package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +10 -1
  123. package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +2 -1
  124. package/src/components/order-view/products-info/expanded-content/index.tsx +3 -2
  125. package/src/components/order-view/products-info/index.tsx +14 -11
  126. package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +26 -24
  127. package/src/components/order-view/store.ts +59 -2
  128. package/src/components/order-view/system-event-logs/columns/Date.tsx +4 -2
  129. package/src/components/order-view/system-event-logs/columns/Event.tsx +9 -9
  130. package/src/components/order-view/system-event-logs/columns/Note.tsx +1 -1
  131. package/src/components/order-view/system-event-logs/expanded-content/index.tsx +25 -25
  132. package/src/components/order-view/types.ts +13 -0
  133. package/src/components/order-view/utils.ts +4 -0
  134. package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +183 -12
  135. package/src/components/order-view/view-reminder/ViewReminder.tsx +234 -143
  136. package/src/components/order-view/view-reminder/reminder-styles.tsx +14 -8
  137. package/src/components/store.ts +6 -0
  138. package/src/index.tsx +28 -18
@@ -1,21 +1,16 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { useApiHook, useAxios } from '@bjsdistribution/dms-component-library';
3
3
  import 'react-datepicker/dist/react-datepicker.css';
4
4
  import CreateReminder from './CreateReminderModal';
5
5
  import {
6
6
  initialValue,
7
- useAllStaticData,
8
- useCategoryData,
7
+ useStaticData,
9
8
  useCreateReminderPayload,
10
- useDepartmentData,
11
- useReminderNotiData,
12
- useTaskPriority,
13
- useTaskTypeData,
14
- useTaskTypeExtended,
9
+ useNotiifcationLabel,
15
10
  } from '../../store';
16
11
  import { allTypes } from '../../types';
17
12
  import { ContentContainer } from './SharedComponents';
18
- import { useCurrentAction, useOrderDetails } from '../../../store';
13
+ import { useCurrentAction } from '../../../store';
19
14
  import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
20
15
  import styled from 'styled-components';
21
16
  import { notification } from 'antd';
@@ -27,44 +22,27 @@ interface ApiResponse {
27
22
  error_traceback: string | null;
28
23
  data: allTypes[];
29
24
  }
30
-
31
- function TaskReminderModal() {
25
+ interface IProps {
26
+ callReminderApi: any;
27
+ callUnresolvedTaskApi: any;
28
+ }
29
+ function ReminderModal(props: IProps) {
32
30
  const [, setCurrentAction] = useCurrentAction();
33
31
  const [createReminder, setReminderPayload] = useCreateReminderPayload();
34
- const [staticData, setStaticData] = useAllStaticData();
35
- const [, setPriority] = useTaskPriority();
36
- const [, setTaskCategory] = useCategoryData();
37
- const [, setTaskTypes] = useTaskTypeData();
38
- const [, setTaskTypeExtended] = useTaskTypeExtended();
39
- const [, setDepartmentData] = useDepartmentData();
40
- const [, setReminderData] = useReminderNotiData();
41
- const [OrderData] = useOrderDetails();
32
+ const [label] = useNotiifcationLabel();
33
+ const [, setStaticData] = useStaticData();
34
+ const [, setExtracted] = useState('');
42
35
 
43
- //create reminder API
44
36
  const { fetchData: createReminderAPI } = useAxios<{
45
37
  data: ApiResponse[];
46
38
  }>({
47
- endpoint: `/tasks/reminders/create/`,
39
+ endpoint: `/v1/task/reminders/create/`,
48
40
  method: 'POST',
49
41
  });
50
42
 
51
- //reminder get
52
- const {
53
- fetchData: callReminderApi,
54
- data: fetchedReminderData,
55
- loading: reminderLoading,
56
- } = useAxios<{
57
- data: ApiResponse[];
58
- }>({
59
- endpoint: `/tasks/reminder/get/`,
60
- method: 'GET',
61
- pagination: { is_pagination: false },
62
- filters: [{ field: 'order_id', op: '=', value: OrderData.id }],
63
- });
64
-
65
43
  // API Call
66
44
  const { data: fetchedStaticData } = useApiHook<ApiResponse>({
67
- endpoint: `/tasks/getStaticData/all/`,
45
+ endpoint: `/v1/task/getStaticData/all/`,
68
46
  method: 'GET',
69
47
  });
70
48
 
@@ -74,71 +52,87 @@ function TaskReminderModal() {
74
52
  }
75
53
  }, [fetchedStaticData]);
76
54
 
77
- //extracted types from whole static data
78
- useEffect(() => {
79
- if (staticData) {
80
- setPriority(staticData?.map(data => data.tasks_priority).flat());
81
- setTaskTypes(staticData?.map(data => data.tasks_types).flat());
82
- setTaskCategory(staticData?.map(data => data.task_categories).flat());
83
- setTaskTypeExtended(
84
- staticData?.map(data => data.task_sub_categories).flat()
85
- );
86
- setDepartmentData(staticData?.map(data => data.department).flat());
87
- }
88
- }, [staticData]);
89
-
90
55
  const closeModal = () => {
91
56
  setCurrentAction(undefined);
92
-
93
57
  setReminderPayload(initialValue);
94
58
  };
95
-
59
+ console.log(createReminder, 'createReminder');
96
60
  const handleReminderSubmit = async () => {
97
- let response = (await createReminderAPI({
98
- payload: { reminder: createReminder },
99
- })) as {
100
- code: number | null;
101
- error?: string | null | undefined;
102
- [key: string]: any;
103
- };
104
- if (response.code == 200 && response.data) {
105
- notification.success({
106
- message: 'Success',
107
- description: `${response.message}`,
108
- });
109
- callReminderApi();
110
- closeModal();
111
- }
112
- if (response?.code == null && response.error) {
113
- return notification.error({
114
- message: 'Failure',
115
- description: `${response.error}`,
61
+ try {
62
+ const response = (await createReminderAPI({
63
+ payload: [createReminder],
64
+ })) as {
65
+ code: number | null;
66
+ message?: string;
67
+ error?: string | null;
68
+ error_traceback?: string;
69
+ data?: any;
70
+ };
71
+
72
+ if (response?.code === 200 && response?.data) {
73
+ notification.success({
74
+ message: 'Success',
75
+ description: response?.message || 'Reminder created successfully',
76
+ });
77
+ closeModal();
78
+ await props?.callReminderApi();
79
+ } else {
80
+ notification.error({
81
+ message: 'Error',
82
+ description:
83
+ response?.error ||
84
+ 'Something went wrong while creating the reminder.',
85
+ });
86
+ }
87
+ } catch (error) {
88
+ const err = error as any;
89
+
90
+ const errMsg =
91
+ err?.response?.data?.error ||
92
+ err?.response?.data?.message ||
93
+ err?.message ||
94
+ 'An unexpected error occurred.';
95
+
96
+ notification.error({
97
+ message: 'Request Failed',
98
+ description: errMsg,
116
99
  });
117
100
  }
118
101
  };
119
-
120
- //reminder data set
121
- useEffect(() => {
122
- if (fetchedReminderData && fetchedReminderData?.data) {
123
- setReminderData(fetchedReminderData?.data);
124
- }
125
- }, [reminderLoading]);
126
-
127
102
  const isSubmitDisabled = () => {
128
- const { details, due } = createReminder;
129
- return !details || !due;
130
-
131
- return true;
103
+ const {
104
+ department,
105
+ assigned_to,
106
+ priority,
107
+ due_datetime,
108
+ description,
109
+ } = createReminder;
110
+ return (
111
+ !department ||
112
+ !description ||
113
+ !due_datetime ||
114
+ !priority ||
115
+ assigned_to?.length === 0 ||
116
+ !assigned_to
117
+ );
132
118
  };
133
119
 
120
+ useEffect(() => {
121
+ const match = label.match(/\(([^)]+)\)/);
122
+ const extractedText = match ? match[1] : '';
123
+ setExtracted(extractedText);
124
+ }, [label]);
125
+
134
126
  return (
135
127
  <>
128
+ {/* {loading && <Loader />} */}
136
129
  <OrderModal
137
130
  headerTitle={'CREATE REMINDER'}
138
131
  onCloseHeader={closeModal}
139
132
  onSubmit={handleReminderSubmit}
140
133
  submitBtnTitle={'Save Reminder'}
141
134
  isSubmitDisabled={isSubmitDisabled()}
135
+ footerActions={''}
142
136
  >
143
137
  <ContentContainer>{<CreateReminder />}</ContentContainer>
144
138
  </OrderModal>
@@ -150,4 +144,4 @@ const OrderModal = styled(OrderActionModal)`
150
144
  width: 70%;
151
145
  `;
152
146
 
153
- export default TaskReminderModal;
147
+ export default ReminderModal;
@@ -2,16 +2,13 @@ import React, { useEffect, useState } from 'react';
2
2
  import {
3
3
  AntSelect,
4
4
  Label,
5
- useApiHook,
5
+ useAxios,
6
6
  } from '@bjsdistribution/dms-component-library';
7
7
  import {
8
8
  useCurrentAction,
9
9
  useCustomerInfo,
10
- useLiveRecalling,
11
- useOrderDetails,
12
10
  useOrderId,
13
11
  useOrderStaticData,
14
- usePrevOrderDetails,
15
12
  } from '../../../store';
16
13
  import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
17
14
  import {
@@ -22,21 +19,23 @@ import {
22
19
  } from '../modalstyle';
23
20
  import { DatePicker, DatePickerProps, notification } from 'antd';
24
21
  import dayjs from 'dayjs';
25
- import { ApiResponse, OrdersType } from '../../../types';
26
- import { useLoading } from '../../../../order-daily-overview/store/store';
22
+ import { ApiResponse } from '../../../types';
23
+ import { useClientPortal } from '../../../../store';
27
24
 
28
- function HoldOrderModal() {
25
+ interface IProps {
26
+ callOrderAlertsApi: any;
27
+ callOrdersApi?: any;
28
+ callUnresolvedTaskApi?: any;
29
+ }
30
+
31
+ function HoldOrderModal(props: IProps) {
29
32
  const [orderId] = useOrderId();
30
33
  const [, setCurrentAction] = useCurrentAction();
31
- const [, setLoading] = useLoading();
32
34
  const [orderStaticData] = useOrderStaticData();
33
35
  const [selectedDate, setDate] = useState<Date | string | null>(null);
34
36
  const [holdReason, setHoldReason] = useState<string | undefined>(undefined);
35
- const [, setOrderDetails] = useOrderDetails();
36
- const [, setPrevOrderDetails] = usePrevOrderDetails();
37
37
  const [customerInfo] = useCustomerInfo();
38
- const [, setRecalling] = useLiveRecalling();
39
-
38
+ const [isClientPortal] = useClientPortal();
40
39
  const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
41
40
 
42
41
  const onHoldReasonOptions = orderStaticData?.onhold_reasons?.map(
@@ -53,63 +52,13 @@ function HoldOrderModal() {
53
52
  : `orders/${orderId}/hold/?hold_reason=${holdReason}
54
53
  `;
55
54
 
56
- const {
57
- data: response,
58
- setShouldPerformAction: setPerformAction,
59
- } = useApiHook<{
55
+ const { fetchData: callOnHoldApi, error } = useAxios<{
60
56
  data: ApiResponse[];
61
57
  }>({
62
58
  endpoint: dynamicUrl,
63
59
  method: 'POST',
64
- performAction: false,
65
- });
66
-
67
- const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
68
- data: OrdersType[];
69
- }>({
70
- endpoint: `orders/${orderId}`,
71
- method: 'GET',
72
- performAction: false,
73
60
  });
74
61
 
75
- useEffect(() => {
76
- setLoading(loading);
77
- if (fetchedData && fetchedData.data) {
78
- const requiredData = fetchedData?.data;
79
- setOrderDetails(requiredData[0]);
80
- setPrevOrderDetails(requiredData[0]);
81
- setCurrentAction(undefined);
82
- }
83
- if (
84
- (fetchedData && fetchedData?.data === null) ||
85
- fetchedData?.data?.length === 0
86
- ) {
87
- setCurrentAction(undefined);
88
- }
89
- }, [loading]);
90
-
91
- useEffect(() => {
92
- if (response) {
93
- //@ts-ignore
94
- if (response?.data && response?.code === 200) {
95
- setShouldPerformAction(true);
96
- setRecalling(true);
97
- setTimeout(() => {
98
- setRecalling(false);
99
- }, 1000);
100
- } else {
101
- notification.error({
102
- message: 'Error',
103
- description:
104
- //@ts-ignore
105
- response?.error_traceback ||
106
- 'An error has occurred. Please try again later.',
107
- });
108
- setCurrentAction(undefined);
109
- }
110
- }
111
- }, [response]);
112
-
113
62
  const onClose = () => {
114
63
  setCurrentAction(undefined);
115
64
  };
@@ -127,16 +76,56 @@ function HoldOrderModal() {
127
76
  }
128
77
  };
129
78
 
130
- const onSubmitHold = () => {
79
+ const onSubmitHold = async () => {
131
80
  if (orderId) {
132
- setPerformAction(true);
81
+ const response = (await callOnHoldApi()) as {
82
+ code: number | null;
83
+ error?: string | null | undefined;
84
+ [key: string]: any;
85
+ };
86
+ if (response?.code === 200) {
87
+ notification.success({
88
+ message: 'Success',
89
+ description: `${response.message}`,
90
+ });
91
+ // call orders api to update status
92
+ if (isClientPortal) {
93
+ await props?.callUnresolvedTaskApi();
94
+ }
95
+ await props?.callOrderAlertsApi();
96
+ await props?.callOrdersApi();
97
+ }
98
+ if (response?.code !== 200) {
99
+ notification.error({
100
+ message: 'Error',
101
+ description: `${response.error}`,
102
+ });
103
+ setCurrentAction(undefined);
104
+ }
133
105
  }
134
106
  };
135
107
 
108
+ useEffect(() => {
109
+ //@ts-ignore
110
+ if (error !== null && error?.code !== 200) {
111
+ console.log('entered');
112
+ notification.error({
113
+ //@ts-ignore
114
+ message: `${error?.error}`,
115
+ description: (
116
+ //@ts-ignore
117
+ <span dangerouslySetInnerHTML={{ __html: error?.message }} />
118
+ ),
119
+ });
120
+ setCurrentAction(undefined);
121
+ }
122
+ }, [error]);
123
+
136
124
  const showSubmitBtn = holdReason !== undefined;
137
125
 
138
126
  return (
139
127
  <OrderActionModal
128
+ minWidth="24vw"
140
129
  headerTitle="Hold order"
141
130
  onCloseHeader={onClose}
142
131
  onSubmit={onSubmitHold}
@@ -157,6 +146,9 @@ function HoldOrderModal() {
157
146
  value={
158
147
  selectedDate === null ? selectedDate : dayjs(selectedDate)
159
148
  }
149
+ disabledDate={current => {
150
+ return current && current < dayjs().startOf('day');
151
+ }}
160
152
  />
161
153
  </HoldDatePickerWrap>
162
154
  </HoldRow>
@@ -3,6 +3,11 @@ import styled from 'styled-components';
3
3
  import RadioButtonGroup from '../../../../../common/radio-group/RadioButtonGroup';
4
4
  import { StandardOptionsType } from '@bjsdistribution/dms-component-library';
5
5
 
6
+ interface IProps {
7
+ refusedDelPointService: any;
8
+ setRefusedDelPointService: React.Dispatch<React.SetStateAction<any>>;
9
+ }
10
+
6
11
  const deliveryPoints: StandardOptionsType[] = [
7
12
  {
8
13
  label: 'Hallway',
@@ -10,27 +15,16 @@ const deliveryPoints: StandardOptionsType[] = [
10
15
  },
11
16
  {
12
17
  label: 'ROC',
13
- value: 'roc',
14
- },
15
- {
16
- label: 'Front Door',
17
- value: 'frontdoor',
18
- },
19
- {
20
- label: 'Garden',
21
- value: 'garden',
18
+ value: 'room_of_choice',
22
19
  },
23
20
  ];
24
21
 
25
- function DeliveryPoint() {
22
+ function DeliveryPoint(props: IProps) {
26
23
  const radioGroupHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
27
- // console.log(typeof event.target.value, 'value...');
28
- setSelectedValue(event.target.value);
24
+ const service = event.target.value;
25
+ props?.setRefusedDelPointService(service);
29
26
  };
30
27
 
31
- const [selectedValue, setSelectedValue] = React.useState<any>(
32
- deliveryPoints[0].value
33
- );
34
28
  return (
35
29
  <Container>
36
30
  <RadioButtonGroup
@@ -38,7 +32,7 @@ function DeliveryPoint() {
38
32
  options={deliveryPoints || []}
39
33
  onChange={radioGroupHandler}
40
34
  direction="horizontal"
41
- selectedValue={selectedValue}
35
+ selectedValue={props?.refusedDelPointService}
42
36
  required={false}
43
37
  />
44
38
  </Container>
@@ -2,19 +2,36 @@ import styled from 'styled-components';
2
2
  import React from 'react';
3
3
  import { TextArea } from '@bjsdistribution/dms-component-library';
4
4
 
5
- function Notes({ onNotesChange }: { onNotesChange: (notes: string) => void }) {
5
+ interface IProps {
6
+ refusedReason: string;
7
+ setRefusedReason: React.Dispatch<React.SetStateAction<string>>;
8
+ }
9
+
10
+ function Notes(props: IProps) {
6
11
  const handleTextChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
7
- onNotesChange(event.target.value);
12
+ props?.setRefusedReason(event.target.value);
8
13
  };
9
14
 
10
15
  return (
11
16
  <Container>
12
- <Label>Notes</Label>
13
- <TextArea rows={15} onChange={handleTextChange} />
17
+ <div style={{ display: 'flex', flexDirection: 'row' }}>
18
+ <Label>Notes</Label> <RequiredAsterisk>*</RequiredAsterisk>
19
+ </div>
20
+ <TextArea
21
+ rows={15}
22
+ onChange={handleTextChange}
23
+ placeholder="Why did the customer refuse the selected service(s)? Add notes..."
24
+ value={props?.refusedReason}
25
+ />
14
26
  </Container>
15
27
  );
16
28
  }
17
29
 
30
+ const RequiredAsterisk = styled.span`
31
+ color: red;
32
+ margin-left: 2px;
33
+ font-size: x-small;
34
+ `;
18
35
  const Label = styled.span`
19
36
  color: #6a7378;
20
37
  font-family: 'Lato', sans-serif;
@@ -2,20 +2,48 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import Checkbox from '../../../../../common/checkbox';
4
4
  import { getIcon } from './helper';
5
+ import { useOrderDetails, useOrderStaticData } from '../../../store';
6
+ import { OrderServiceType } from '../../../types';
7
+ interface IProps {
8
+ refusedServices: string[];
9
+ setRefusedServices: React.Dispatch<React.SetStateAction<string[]>>;
10
+ }
11
+
12
+ function OrderServices(props: IProps) {
13
+ const [orderStaticData] = useOrderStaticData();
14
+ const [orderDetails] = useOrderDetails();
15
+ const orderServices = orderDetails?.order_services;
16
+ const orderServicesOptions = orderStaticData?.order_service_list;
17
+
18
+ const onClick = (service: string) => {
19
+ if (props?.refusedServices?.includes(service)) {
20
+ const filteredServices = props?.refusedServices?.filter(
21
+ (item: string) => item !== service
22
+ );
23
+ props?.setRefusedServices(filteredServices);
24
+ } else {
25
+ props?.setRefusedServices((prev: string[]) => [...prev, service]);
26
+ }
27
+ };
5
28
 
6
- function OrderServices() {
7
- // TO DO -> get services from static data
8
29
  return (
9
30
  <Container>
10
- <Checkbox checked={false} label="Assemble" imageSrc={getIcon(1)} />
11
- <Checkbox checked={false} label="Disassemble" imageSrc={getIcon(2)} />
12
- <Checkbox checked label="Unpack Items" imageSrc={getIcon(3)} />
13
- <Checkbox checked label="Collect Disposal" imageSrc={getIcon(5)} />
14
- <Checkbox
15
- checked={false}
16
- label="Take Package Away"
17
- imageSrc={getIcon(4)}
18
- />
31
+ {orderServicesOptions.map((service: any) => {
32
+ const selected = !!orderServices?.find(
33
+ (s: OrderServiceType) =>
34
+ s?.order_service_list_id === service?.id && s.is_deleted === false
35
+ );
36
+ const isRefused = props?.refusedServices?.includes(service?.type);
37
+ return (
38
+ <Checkbox
39
+ checked={isRefused}
40
+ label={service?.type}
41
+ imageSrc={getIcon(service?.id)}
42
+ enabled={selected}
43
+ onClickCheckbox={onClick}
44
+ />
45
+ );
46
+ })}
19
47
  </Container>
20
48
  );
21
49
  }
@@ -1,33 +1,104 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
3
3
  import styled from 'styled-components';
4
4
  import DeliveryPoint from './DeliveryPoint';
5
5
  import OrderServices from './OrderServices';
6
6
  import Notes from './Notes';
7
- import { useCurrentAction } from '../../../store';
7
+ import {
8
+ useCurrentAction,
9
+ useCustomerInfo,
10
+ useOrderDetails,
11
+ } from '../../../store';
12
+ import { useAxios } from '@bjsdistribution/dms-component-library';
13
+ import { ApiResponse } from '../../../types';
14
+ import { notification } from 'antd';
8
15
 
9
- function LogServiceRefusal() {
16
+ function LogServiceRefusal(props: any) {
10
17
  const [, setCurrentAction] = useCurrentAction();
18
+ // Local States for handling service refusal
19
+ const [refusedReason, setRefusedReason] = useState<string>('');
20
+ const [refusedServices, setRefusedServices] = useState<string[]>([]);
21
+ const [refusedDelPointService, setRefusedDelPointService] = useState<any>('');
22
+ const [customerInfo] = useCustomerInfo();
23
+ const [orderDetails] = useOrderDetails();
24
+ const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
25
+
26
+ const { fetchData: callLogRefusalApi } = useAxios<{
27
+ data: ApiResponse[];
28
+ }>({
29
+ endpoint: `/v1/orders/log-refusal/`,
30
+ method: 'POST',
31
+ });
11
32
 
12
33
  const onClose = () => {
13
34
  setCurrentAction(undefined);
14
35
  };
36
+
37
+ const onSubmit = async () => {
38
+ const allServices =
39
+ refusedDelPointService?.length > 0
40
+ ? [...refusedServices, refusedDelPointService]
41
+ : refusedServices;
42
+ const finalPayload = {
43
+ order_id: orderDetails?.id,
44
+ route_id: orderDetails?.order_routes?.route_id,
45
+ refused_reason: refusedReason,
46
+ service_name: allServices,
47
+ };
48
+ try {
49
+ let response = (await callLogRefusalApi({
50
+ payload: finalPayload,
51
+ })) as {
52
+ code: number | null;
53
+ error?: string | null | undefined;
54
+ [key: string]: any;
55
+ };
56
+ if (response.code == 200) {
57
+ notification.success({
58
+ message: 'Success',
59
+ description: `${response?.message}`,
60
+ });
61
+ props?.callOrdersApi();
62
+ } else {
63
+ notification.error({
64
+ message: 'Error',
65
+ description: `${response?.error}`,
66
+ });
67
+ onClose();
68
+ }
69
+ } catch (error) {}
70
+ };
71
+
72
+ const disableSubmitBtn =
73
+ refusedReason?.length === 0 ||
74
+ (refusedServices?.length === 0 && refusedDelPointService?.length === 0);
75
+
15
76
  return (
16
77
  <OrderActionModal
17
78
  headerTitle="Service Refusal"
18
79
  showAdditionalInfo
19
- infoText="CURTIS RADCLIFFE, PR5 5TD"
80
+ infoText={infoText}
20
81
  submitBtnTitle="Log Refusal"
21
82
  onCloseHeader={onClose}
22
- onSubmit={() => {}}
83
+ onSubmit={onSubmit}
84
+ isSubmitDisabled={disableSubmitBtn}
23
85
  >
24
86
  <ContentContainer>
25
87
  <Left>
26
- <DeliveryPoint />
27
- <OrderServices />
88
+ <DeliveryPoint
89
+ refusedDelPointService={refusedDelPointService}
90
+ setRefusedDelPointService={setRefusedDelPointService}
91
+ />
92
+ <OrderServices
93
+ refusedServices={refusedServices}
94
+ setRefusedServices={setRefusedServices}
95
+ />
28
96
  </Left>
29
97
  <Right>
30
- <Notes onNotesChange={() => console.log('object')} />
98
+ <Notes
99
+ refusedReason={refusedReason}
100
+ setRefusedReason={setRefusedReason}
101
+ />
31
102
  </Right>
32
103
  </ContentContainer>
33
104
  </OrderActionModal>