@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.
- package/dist/assets/icons/ArrowDownIcon.d.ts +6 -0
- package/dist/assets/icons/DeliverProductIcon.d.ts +3 -0
- package/dist/assets/icons/ReturnProductIcon.d.ts +3 -0
- package/dist/common/checkbox/index.d.ts +2 -0
- package/dist/common/modals/order-action-modal/OrderActionModal.d.ts +3 -1
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.d.ts +1 -0
- package/dist/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.d.ts +2 -2
- package/dist/components/order-view/flags-action-modal/Actions.d.ts +6 -2
- package/dist/components/order-view/flags-action-modal/Dropdowns.d.ts +1 -0
- package/dist/components/order-view/flags-action-modal/Header.d.ts +1 -1
- package/dist/components/order-view/notification/FlagTemplate.d.ts +1 -1
- package/dist/components/order-view/notification/OrderTemplate.d.ts +1 -1
- package/dist/components/order-view/notification/Tabs.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.d.ts +5 -0
- package/dist/components/order-view/order-actions/actions/cancel-order/index.d.ts +7 -1
- package/dist/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/charge-log/index.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.d.ts +1 -13
- package/dist/components/order-view/order-actions/actions/create-task-reminder/TaskModal.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/create-task-reminder/index.d.ts +6 -2
- package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +6 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +5 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +5 -1
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.d.ts +7 -1
- package/dist/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.d.ts +5 -0
- package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +6 -1
- package/dist/components/order-view/order-actions/store.d.ts +10 -8
- package/dist/components/order-view/order-actions/types.d.ts +38 -60
- package/dist/components/order-view/order-actions/utils.d.ts +2 -1
- package/dist/components/order-view/store.d.ts +48 -3
- package/dist/components/order-view/types.d.ts +11 -0
- package/dist/components/order-view/utils.d.ts +1 -0
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +5 -1
- package/dist/components/order-view/view-reminder/reminder-styles.d.ts +3 -1
- package/dist/components/store.d.ts +2 -1
- package/dist/dms-client-return.cjs.development.js +4812 -3095
- package/dist/dms-client-return.cjs.development.js.map +1 -1
- package/dist/dms-client-return.cjs.production.min.js +1 -1
- package/dist/dms-client-return.cjs.production.min.js.map +1 -1
- package/dist/dms-client-return.esm.js +4815 -3098
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/ArrowDownIcon.tsx +28 -0
- package/src/assets/icons/DeliverProductIcon.tsx +42 -0
- package/src/assets/icons/ReturnProductIcon.tsx +23 -0
- package/src/common/checkbox/index.tsx +60 -17
- package/src/common/modals/order-action-modal/OrderActionModal.tsx +13 -7
- package/src/common/radio-group/RadioButtonGroup.tsx +3 -4
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +29 -26
- package/src/components/order-daily-overview/header-filters/filterStore.ts +6 -8
- package/src/components/order-daily-overview/index.tsx +20 -7
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +2 -2
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +19 -19
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +11 -9
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +19 -4
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +41 -59
- package/src/components/order-daily-overview/table/ReturnTable.tsx +1 -30
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +52 -2
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/MenuDropDown.tsx +37 -43
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +75 -44
- package/src/components/order-view/fakedata.ts +7 -6
- package/src/components/order-view/flags-action-modal/Actions.tsx +51 -25
- package/src/components/order-view/flags-action-modal/DetailSection.tsx +5 -5
- package/src/components/order-view/flags-action-modal/Dropdowns.tsx +75 -89
- package/src/components/order-view/flags-action-modal/Header.tsx +32 -23
- package/src/components/order-view/flags-action-modal/TextSection.tsx +9 -6
- package/src/components/order-view/flags-action-modal/index.tsx +54 -67
- package/src/components/order-view/general-information/dropdowns/Print.tsx +136 -70
- package/src/components/order-view/generic-table/AuditLogs.tsx +5 -4
- package/src/components/order-view/index.tsx +9 -42
- package/src/components/order-view/modalsPopup/CreateReturnModal.tsx +20 -18
- package/src/components/order-view/modalsPopup/ModalManager.tsx +4 -10
- package/src/components/order-view/notes/logs/index.tsx +1 -1
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +5 -7
- package/src/components/order-view/notification/FlagTemplate.tsx +8 -8
- package/src/components/order-view/notification/OrderTemplate.tsx +169 -175
- package/src/components/order-view/notification/ReminderTemplate.tsx +23 -14
- package/src/components/order-view/notification/Tabs.tsx +15 -14
- package/src/components/order-view/notification/index.tsx +164 -92
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +19 -29
- package/src/components/order-view/order-actions/actions/cancel-order/CancelOrderTable.tsx +345 -0
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -71
- package/src/components/order-view/order-actions/actions/change-customer-account/ChangeCustomerAccModal.tsx +95 -32
- package/src/components/order-view/order-actions/actions/charge-log/index.tsx +395 -0
- package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +34 -17
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +2 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +39 -25
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +4 -2
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +254 -66
- package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +1 -1
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +13 -9
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +1 -1
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +213 -117
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +97 -152
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +30 -87
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +77 -83
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +57 -65
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +10 -16
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +21 -4
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +39 -11
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +79 -8
- package/src/components/order-view/order-actions/actions/send-email/SendEmailModal.tsx +114 -17
- package/src/components/order-view/order-actions/actions/send-sms/SendSmsModal.tsx +115 -7
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +14 -4
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrder.tsx +176 -87
- package/src/components/order-view/order-actions/actions/uncancel-order/UncancelOrderTable.tsx +352 -0
- package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +35 -59
- package/src/components/order-view/order-actions/index.tsx +237 -22
- package/src/components/order-view/order-actions/store.ts +50 -48
- package/src/components/order-view/order-actions/types.ts +40 -65
- package/src/components/order-view/order-actions/utils.ts +15 -8
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactEmail.tsx +2 -1
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +80 -39
- package/src/components/order-view/order-details/expanded-content/orders-section/Carrier.tsx +10 -14
- package/src/components/order-view/order-details/expanded-content/orders-section/DeliveryDate.tsx +10 -1
- package/src/components/order-view/order-details/expanded-content/orders-section/ScheduleAfter.tsx +2 -1
- package/src/components/order-view/products-info/expanded-content/index.tsx +3 -2
- package/src/components/order-view/products-info/index.tsx +14 -11
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +26 -24
- package/src/components/order-view/store.ts +59 -2
- package/src/components/order-view/system-event-logs/columns/Date.tsx +4 -2
- package/src/components/order-view/system-event-logs/columns/Event.tsx +9 -9
- package/src/components/order-view/system-event-logs/columns/Note.tsx +1 -1
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +25 -25
- package/src/components/order-view/types.ts +13 -0
- package/src/components/order-view/utils.ts +4 -0
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +183 -12
- package/src/components/order-view/view-reminder/ViewReminder.tsx +234 -143
- package/src/components/order-view/view-reminder/reminder-styles.tsx +14 -8
- package/src/components/store.ts +6 -0
- 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
|
-
|
|
8
|
-
useCategoryData,
|
|
7
|
+
useStaticData,
|
|
9
8
|
useCreateReminderPayload,
|
|
10
|
-
|
|
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
|
|
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
|
-
|
|
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 [
|
|
35
|
-
const [,
|
|
36
|
-
const [,
|
|
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: `/
|
|
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: `/
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
|
147
|
+
export default ReminderModal;
|
|
@@ -2,16 +2,13 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
AntSelect,
|
|
4
4
|
Label,
|
|
5
|
-
|
|
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
|
|
26
|
-
import {
|
|
22
|
+
import { ApiResponse } from '../../../types';
|
|
23
|
+
import { useClientPortal } from '../../../../store';
|
|
27
24
|
|
|
28
|
-
|
|
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 [
|
|
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
|
-
|
|
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>
|
package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx
CHANGED
|
@@ -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: '
|
|
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
|
-
|
|
28
|
-
|
|
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={
|
|
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
|
-
|
|
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
|
-
|
|
12
|
+
props?.setRefusedReason(event.target.value);
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
return (
|
|
11
16
|
<Container>
|
|
12
|
-
<
|
|
13
|
-
|
|
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;
|
package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 {
|
|
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=
|
|
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
|
-
|
|
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
|
|
98
|
+
<Notes
|
|
99
|
+
refusedReason={refusedReason}
|
|
100
|
+
setRefusedReason={setRefusedReason}
|
|
101
|
+
/>
|
|
31
102
|
</Right>
|
|
32
103
|
</ContentContainer>
|
|
33
104
|
</OrderActionModal>
|