@bjsdistribution/dms-client-return 0.0.18 → 0.0.20
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/DustbinIcon.d.ts +3 -0
- package/dist/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/order-daily-overview/header-filters/overViewFilter.d.ts +16 -0
- package/dist/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.d.ts +1 -1
- package/dist/components/order-daily-overview/store/store.d.ts +2 -0
- package/dist/components/order-daily-overview/table-view/ReturnPagination.d.ts +3 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- package/dist/components/order-view/fakedata.d.ts +1 -1
- package/dist/components/order-view/order-actions/Dropdown.d.ts +6 -2
- package/dist/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.d.ts +9 -0
- package/dist/components/order-view/order-actions/store.d.ts +34 -1
- package/dist/components/order-view/order-actions/types.d.ts +5 -0
- package/dist/components/order-view/store.d.ts +1 -0
- package/dist/components/order-view/types.d.ts +5 -2
- package/dist/dms-client-return.cjs.development.js +2395 -1670
- 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 +2398 -1673
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/icons/DustbinIcon.tsx +20 -0
- package/src/common/modals/order-action-modal/OrderActionModal.tsx +4 -2
- package/src/components/order-daily-overview/header-filters/filterStore.ts +19 -18
- package/src/components/order-daily-overview/header-filters/overViewFilter.ts +80 -0
- package/src/components/order-daily-overview/index.tsx +27 -33
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +47 -5
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +9 -5
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +1 -1
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +2 -2
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +25 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +29 -11
- package/src/components/order-daily-overview/store/store.ts +11 -1
- package/src/components/order-daily-overview/table-view/Pagination.tsx +2 -1
- package/src/components/order-daily-overview/table-view/ReturnPagination.tsx +136 -0
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +26 -12
- package/src/components/order-view/details-filters/right-side-filters/Details.tsx +8 -1
- package/src/components/order-view/fakedata.ts +5 -9
- package/src/components/order-view/general-information/dropdowns/BjsMenu.tsx +15 -4
- package/src/components/order-view/general-information/dropdowns/Print.tsx +79 -39
- package/src/components/order-view/general-information/dropdowns/index.tsx +0 -13
- package/src/components/order-view/general-information/index.tsx +3 -19
- package/src/components/order-view/generic-table/AuditLogs.tsx +7 -5
- package/src/components/order-view/index.tsx +1 -2
- package/src/components/order-view/modalsPopup/ModalManager.tsx +69 -196
- package/src/components/order-view/notes/AddNote.tsx +4 -14
- package/src/components/order-view/notes/index.tsx +8 -13
- package/src/components/order-view/order-actions/Dropdown.tsx +8 -3
- package/src/components/order-view/order-actions/actions/cancel-order/index.tsx +146 -12
- package/src/components/order-view/order-actions/actions/charge-log/index.tsx +126 -79
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ActionDropdown.tsx +21 -9
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactMobile.tsx +64 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactPhone.tsx +67 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactTypeDropdown.tsx +19 -7
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWith.tsx +28 -0
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/ContactWork.tsx +65 -1
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/DeliveryDate.tsx +40 -3
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx +47 -2
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/TimedServiceDropdown.tsx +38 -9
- package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx +4 -1
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +196 -6
- package/src/components/order-view/order-actions/actions/confirm-order/slot-and-instructions/index.tsx +5 -1
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +121 -20
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx +54 -32
- package/src/components/order-view/order-actions/actions/confirm-order/tables/ReminderStyles.tsx +289 -0
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +41 -8
- package/src/components/order-view/order-actions/actions/create-task-reminder/index.tsx +11 -83
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +61 -14
- package/src/components/order-view/order-actions/actions/release-order/ReleaseOrder.tsx +93 -25
- package/src/components/order-view/order-actions/actions/split-order/SplitOrderTable.tsx +102 -247
- package/src/components/order-view/order-actions/actions/split-order/index.tsx +57 -9
- package/src/components/order-view/order-actions/index.tsx +7 -2
- package/src/components/order-view/order-actions/store.ts +45 -0
- package/src/components/order-view/order-actions/types.ts +5 -0
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +15 -12
- package/src/components/order-view/store.ts +7 -0
- package/src/components/order-view/types.ts +5 -2
package/src/components/order-view/order-actions/actions/confirm-order/customer-info/EmailAddress.tsx
CHANGED
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { Input } from 'antd';
|
|
4
|
+
import {
|
|
5
|
+
useErrorConfirmOrder,
|
|
6
|
+
useOrderDetailsConfirmOrder,
|
|
7
|
+
} from '../../../store';
|
|
4
8
|
|
|
5
9
|
function EmailAddress() {
|
|
10
|
+
const emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
11
|
+
|
|
12
|
+
const [orderDetails, setOrderDetails] = useOrderDetailsConfirmOrder();
|
|
13
|
+
|
|
14
|
+
const orderRecipient = orderDetails?.order_recipient;
|
|
15
|
+
const [errors, setErrors] = useErrorConfirmOrder();
|
|
16
|
+
|
|
17
|
+
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
18
|
+
const val = e.target.value;
|
|
19
|
+
validateInput(val);
|
|
20
|
+
const updatedOrderRecipient = {
|
|
21
|
+
...(orderRecipient === null
|
|
22
|
+
? { contact_email: val }
|
|
23
|
+
: { ...orderRecipient, contact_email: val }),
|
|
24
|
+
};
|
|
25
|
+
setOrderDetails(prev => {
|
|
26
|
+
return {
|
|
27
|
+
...prev,
|
|
28
|
+
order_recipient: updatedOrderRecipient,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const validateInput = (value: string) => {
|
|
34
|
+
const isValid = emailRegex.test(value);
|
|
35
|
+
setErrors(prev => ({
|
|
36
|
+
...prev,
|
|
37
|
+
emailError: isValid ? '' : 'Please enter a valid Email Address',
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
|
|
6
41
|
return (
|
|
7
42
|
<Container>
|
|
8
43
|
<Label>Email Address</Label>
|
|
9
|
-
<Input
|
|
44
|
+
<Input
|
|
45
|
+
style={{ borderRadius: '15px' }}
|
|
46
|
+
type="text"
|
|
47
|
+
value={orderRecipient?.contact_email || ''}
|
|
48
|
+
onChange={onChange}
|
|
49
|
+
/>
|
|
50
|
+
{errors.emailError && <ErrorText>{errors.emailError}</ErrorText>}
|
|
10
51
|
</Container>
|
|
11
52
|
);
|
|
12
53
|
}
|
|
@@ -24,5 +65,9 @@ const Container = styled.div`
|
|
|
24
65
|
flex-direction: column;
|
|
25
66
|
gap: 6px;
|
|
26
67
|
`;
|
|
27
|
-
|
|
68
|
+
const ErrorText = styled.span`
|
|
69
|
+
color: red;
|
|
70
|
+
font-size: 0.85rem;
|
|
71
|
+
margin-top: 4px;
|
|
72
|
+
`;
|
|
28
73
|
export default EmailAddress;
|
|
@@ -1,23 +1,52 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import OrderActionsDropdown from '../../../Dropdown';
|
|
3
|
+
import { useOrderStaticData } from '../../../../store';
|
|
4
|
+
import { capitalize } from '../../../../utils';
|
|
5
|
+
import { useOrderDetailsConfirmOrder } from '../../../store';
|
|
6
|
+
|
|
7
|
+
function convertTo12HourFormat(time24: any) {
|
|
8
|
+
const [hours, minutes] = time24?.split(':')?.map(Number);
|
|
9
|
+
const period = hours >= 12 ? 'PM' : 'AM';
|
|
10
|
+
const hours12 = hours % 12 || 12; // Convert to 12-hour format
|
|
11
|
+
return `${hours12}:${minutes?.toString()?.padStart(2, '0')} ${period}`;
|
|
12
|
+
}
|
|
3
13
|
|
|
4
14
|
function TimedServiceDropdown() {
|
|
5
|
-
const
|
|
6
|
-
const
|
|
15
|
+
const [orderStaticData] = useOrderStaticData();
|
|
16
|
+
const [orderData, setOrderData] = useOrderDetailsConfirmOrder();
|
|
17
|
+
const timesServiceId = orderData?.order_services_detail?.timed_service_id;
|
|
7
18
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
const timedServicesOptions = orderStaticData?.order_timed_services?.map(
|
|
20
|
+
(option: any) => {
|
|
21
|
+
const startTime = convertTo12HourFormat(option?.start_time);
|
|
22
|
+
const endTime = convertTo12HourFormat(option?.end_time);
|
|
23
|
+
const label = `${capitalize(
|
|
24
|
+
option?.type?.replaceAll('_', ' ')
|
|
25
|
+
)} (${startTime} - ${endTime})`;
|
|
26
|
+
return {
|
|
27
|
+
label: label,
|
|
28
|
+
value: option?.id,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
);
|
|
13
32
|
|
|
33
|
+
const onSelect = (event: any) => {
|
|
34
|
+
const updatedServices = {
|
|
35
|
+
...orderData?.order_services_detail!,
|
|
36
|
+
timed_service_id: +event,
|
|
37
|
+
};
|
|
38
|
+
const newData = { ...orderData, order_services_detail: updatedServices };
|
|
39
|
+
setOrderData(newData);
|
|
40
|
+
};
|
|
14
41
|
return (
|
|
15
42
|
<OrderActionsDropdown
|
|
16
43
|
label="Timed Service"
|
|
17
44
|
placeholder="Select Timed Service"
|
|
18
|
-
options={
|
|
45
|
+
options={timedServicesOptions || []}
|
|
46
|
+
value={timedServicesOptions?.filter(
|
|
47
|
+
(f: any) => f.value === timesServiceId
|
|
48
|
+
)}
|
|
19
49
|
onSelect={onSelect}
|
|
20
|
-
onSearch={onSearch}
|
|
21
50
|
/>
|
|
22
51
|
);
|
|
23
52
|
}
|
package/src/components/order-view/order-actions/actions/confirm-order/customer-info/index.tsx
CHANGED
|
@@ -8,12 +8,15 @@ import ContactTypeDropdown from './ContactTypeDropdown';
|
|
|
8
8
|
import ActionDropdown from './ActionDropdown';
|
|
9
9
|
import DeliveryDate from './DeliveryDate';
|
|
10
10
|
import TimedServiceDropdown from './TimedServiceDropdown';
|
|
11
|
+
import { useOrderDetailsConfirmOrder } from '../../../store';
|
|
11
12
|
|
|
12
13
|
function CustomerInformation() {
|
|
14
|
+
const [orderDetails] = useOrderDetailsConfirmOrder();
|
|
15
|
+
|
|
13
16
|
return (
|
|
14
17
|
<Container>
|
|
15
18
|
<Title>Address</Title>
|
|
16
|
-
<AddressField>
|
|
19
|
+
<AddressField>{orderDetails?.order_recipient?.address}</AddressField>
|
|
17
20
|
<Wrapper>
|
|
18
21
|
<EmailAddress />
|
|
19
22
|
<ContactPhone />
|
|
@@ -1,28 +1,216 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import OrderActionModal from '../../../../../common/modals/order-action-modal/OrderActionModal';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import CustomerInformation from './customer-info';
|
|
5
5
|
import ProductTable from './tables/ProductTable';
|
|
6
6
|
import NotesTable from './tables/NotesTable';
|
|
7
7
|
import SlotAndInstructions from './slot-and-instructions';
|
|
8
|
-
import { Alert } from '@bjsdistribution/dms-component-library';
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import { Alert, useApiHook } from '@bjsdistribution/dms-component-library';
|
|
9
|
+
import {
|
|
10
|
+
useCurrentAction,
|
|
11
|
+
useCustomerInfo,
|
|
12
|
+
useLiveRecalling,
|
|
13
|
+
useOrderDetails,
|
|
14
|
+
useOrderId,
|
|
15
|
+
usePrevOrderDetails,
|
|
16
|
+
} from '../../../store';
|
|
17
|
+
import {
|
|
18
|
+
useConfirmOrderDate,
|
|
19
|
+
useErrorConfirmOrder,
|
|
20
|
+
useOrderDetailsConfirmOrder,
|
|
21
|
+
} from '../../store';
|
|
22
|
+
import { ApiResponse, OrdersType } from '../../../types';
|
|
23
|
+
import { useLoading } from '../../../../order-daily-overview/store/store';
|
|
24
|
+
import { notification } from 'antd';
|
|
25
|
+
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
26
|
+
import useUpdateOrder from '../../../hooks/useUpdateOrder';
|
|
27
|
+
// import { filterObject } from '../../../utils';
|
|
11
28
|
|
|
12
29
|
function ConfirmOrder() {
|
|
13
30
|
const [, setCurrentAction] = useCurrentAction();
|
|
31
|
+
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
32
|
+
const [prevOrderDetails, setPrevOrderDetails] = usePrevOrderDetails();
|
|
33
|
+
const [
|
|
34
|
+
orderDetailsConfirmOrder,
|
|
35
|
+
setOrderDetailsConfirmOrder,
|
|
36
|
+
] = useOrderDetailsConfirmOrder();
|
|
37
|
+
const [, setLoading] = useLoading();
|
|
38
|
+
const [customerInfo] = useCustomerInfo();
|
|
39
|
+
const infoText = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
|
|
40
|
+
const [deliveryDate] = useConfirmOrderDate();
|
|
41
|
+
const [liveRecalling, setRecalling] = useLiveRecalling();
|
|
42
|
+
const [orderId] = useOrderId();
|
|
43
|
+
const [errorState] = useErrorConfirmOrder();
|
|
44
|
+
const updateOrder = useUpdateOrder();
|
|
14
45
|
|
|
15
46
|
const onClose = () => {
|
|
16
47
|
setCurrentAction(undefined);
|
|
17
48
|
};
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const clone = JSON.parse(JSON.stringify(orderDetails));
|
|
52
|
+
setOrderDetailsConfirmOrder(clone);
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
setOrderDetailsConfirmOrder(clone);
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
loading: loadingForConfirm,
|
|
61
|
+
data: response,
|
|
62
|
+
setShouldPerformAction: setPerformAction,
|
|
63
|
+
} = useApiHook<{
|
|
64
|
+
data: ApiResponse[];
|
|
65
|
+
}>({
|
|
66
|
+
endpoint: `orders/${orderId}/confirm-date/?date=${deliveryDate}`,
|
|
67
|
+
method: 'POST',
|
|
68
|
+
performAction: false,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const { data: fetchedData, loading, setShouldPerformAction } = useApiHook<{
|
|
72
|
+
data: OrdersType[];
|
|
73
|
+
}>({
|
|
74
|
+
endpoint: `orders/${orderId}`,
|
|
75
|
+
method: 'GET',
|
|
76
|
+
performAction: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setLoading(loading);
|
|
81
|
+
if (fetchedData && fetchedData.data) {
|
|
82
|
+
const requiredData = fetchedData?.data;
|
|
83
|
+
setOrderDetails(requiredData[0]);
|
|
84
|
+
setPrevOrderDetails(requiredData[0]);
|
|
85
|
+
setCurrentAction(undefined);
|
|
86
|
+
}
|
|
87
|
+
if (
|
|
88
|
+
(fetchedData && fetchedData?.data === null) ||
|
|
89
|
+
fetchedData?.data?.length === 0
|
|
90
|
+
) {
|
|
91
|
+
setCurrentAction(undefined);
|
|
92
|
+
}
|
|
93
|
+
}, [loading, liveRecalling]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (response) {
|
|
97
|
+
//@ts-ignore
|
|
98
|
+
if (response?.data && response?.code === 200) {
|
|
99
|
+
notification.success({
|
|
100
|
+
message: 'Success',
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
description: response?.message || 'Order confirmed successfully',
|
|
103
|
+
});
|
|
104
|
+
setShouldPerformAction(true);
|
|
105
|
+
setRecalling(true);
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
setRecalling(false);
|
|
108
|
+
}, 2000);
|
|
109
|
+
} else {
|
|
110
|
+
setShouldPerformAction(false);
|
|
111
|
+
|
|
112
|
+
notification.error({
|
|
113
|
+
message: 'Error',
|
|
114
|
+
description:
|
|
115
|
+
//@ts-ignore
|
|
116
|
+
response?.error_traceback ||
|
|
117
|
+
'An error has occurred. Please try again later.',
|
|
118
|
+
});
|
|
119
|
+
setCurrentAction(undefined);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, [loadingForConfirm]);
|
|
123
|
+
|
|
124
|
+
function hasOnlyIdKey(obj: any) {
|
|
125
|
+
return Object.keys(obj).length === 1 && obj.hasOwnProperty('id');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const ConfirmOrder = async () => {
|
|
129
|
+
setRecalling(false);
|
|
130
|
+
|
|
131
|
+
const keysToRemovefromOrders = [
|
|
132
|
+
'order_locked',
|
|
133
|
+
'order_communications',
|
|
134
|
+
'updated_at',
|
|
135
|
+
'updated_by',
|
|
136
|
+
'stock_alias',
|
|
137
|
+
'order_delivery_declined_dates',
|
|
138
|
+
'order_eta_updates',
|
|
139
|
+
];
|
|
140
|
+
const filteredOrderDetails = filterObject(
|
|
141
|
+
orderDetailsConfirmOrder,
|
|
142
|
+
keysToRemovefromOrders
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const filteredPrevOrderDetails = filterObject(
|
|
146
|
+
prevOrderDetails,
|
|
147
|
+
keysToRemovefromOrders
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
const payload = compareOrderDetailsStates(
|
|
151
|
+
filteredPrevOrderDetails,
|
|
152
|
+
filteredOrderDetails
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const notUpdateOrder = hasOnlyIdKey(payload);
|
|
156
|
+
if (!notUpdateOrder) {
|
|
157
|
+
const response = await updateOrder([payload]);
|
|
158
|
+
if (response && response?.data?.length > 0) {
|
|
159
|
+
setOrderDetails(response?.data[0]);
|
|
160
|
+
setPrevOrderDetails(response?.data[0]);
|
|
161
|
+
} else {
|
|
162
|
+
setOrderDetails(prevOrderDetails);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (orderId && deliveryDate) {
|
|
166
|
+
//call order update api then call confirm order if required
|
|
167
|
+
setPerformAction(true);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// const isDifferent = () => {
|
|
172
|
+
// const keysToRemovefromOrders = [
|
|
173
|
+
// 'order_locked',
|
|
174
|
+
// 'order_communications',
|
|
175
|
+
// 'updated_at',
|
|
176
|
+
// 'updated_by',
|
|
177
|
+
// 'order_services',
|
|
178
|
+
// ];
|
|
179
|
+
// const filteredOrderDetails = filterObject(
|
|
180
|
+
// orderDetailsConfirmOrder,
|
|
181
|
+
// keysToRemovefromOrders
|
|
182
|
+
// );
|
|
183
|
+
// const filteredPrevOrderDetails = filterObject(
|
|
184
|
+
// prevOrderDetails,
|
|
185
|
+
// keysToRemovefromOrders
|
|
186
|
+
// );
|
|
187
|
+
|
|
188
|
+
// const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
189
|
+
// const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
190
|
+
// const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
191
|
+
// // newOrderServicesSorted === prevOrderServicesSorted;
|
|
192
|
+
// return !isSame;
|
|
193
|
+
// };
|
|
194
|
+
|
|
195
|
+
const errorFound = () => {
|
|
196
|
+
const isError =
|
|
197
|
+
errorState.emailError.length > 0 ||
|
|
198
|
+
errorState.homeContactError.length > 0 ||
|
|
199
|
+
errorState.workContactError.length > 0 ||
|
|
200
|
+
errorState.mobileError.length > 0;
|
|
201
|
+
|
|
202
|
+
return isError;
|
|
203
|
+
};
|
|
204
|
+
|
|
18
205
|
return (
|
|
19
206
|
<OrderActionModal
|
|
20
207
|
headerTitle="Confirm Order"
|
|
21
208
|
showAdditionalInfo
|
|
22
|
-
infoText=
|
|
209
|
+
infoText={infoText}
|
|
23
210
|
onCloseHeader={onClose}
|
|
24
|
-
onSubmit={
|
|
211
|
+
onSubmit={ConfirmOrder}
|
|
25
212
|
submitBtnTitle="Save Details"
|
|
213
|
+
isSubmitDisabled={errorFound()}
|
|
26
214
|
>
|
|
27
215
|
<ContentContainer>
|
|
28
216
|
<Alert
|
|
@@ -31,6 +219,7 @@ function ConfirmOrder() {
|
|
|
31
219
|
type="info"
|
|
32
220
|
title="There is Orders with identical postcodes that are yet to be delivered.View Orders"
|
|
33
221
|
showOkButton={false}
|
|
222
|
+
showCloseIcon={false}
|
|
34
223
|
/>
|
|
35
224
|
<Wrapper>
|
|
36
225
|
<CustomerInformation />
|
|
@@ -61,6 +250,7 @@ const ContentContainer = styled.div`
|
|
|
61
250
|
min-height: 500px;
|
|
62
251
|
overflow-x: hidden;
|
|
63
252
|
max-height: 500px;
|
|
253
|
+
scrollbar-width: thin;
|
|
64
254
|
`;
|
|
65
255
|
|
|
66
256
|
export default ConfirmOrder;
|
|
@@ -2,14 +2,18 @@ import styled from 'styled-components';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ConfirmationNotes from './ConfirmationNotes';
|
|
4
4
|
import DeliveryInstructions from './DeliveryInstructions';
|
|
5
|
+
import ContactWith from '../customer-info/ContactWith';
|
|
6
|
+
import { useOrderDetailsConfirmOrder } from '../../../store';
|
|
5
7
|
|
|
6
8
|
function SlotAndInstructions() {
|
|
9
|
+
const [orderDetails] = useOrderDetailsConfirmOrder();
|
|
7
10
|
return (
|
|
8
11
|
<Container>
|
|
9
12
|
<Slot>
|
|
10
13
|
<Title>Slot</Title>
|
|
11
|
-
<Value>
|
|
14
|
+
<Value>{orderDetails?.order_routes?.slot}</Value>
|
|
12
15
|
</Slot>
|
|
16
|
+
<ContactWith />
|
|
13
17
|
<DeliveryInstructions />
|
|
14
18
|
<ConfirmationNotes />
|
|
15
19
|
</Container>
|
|
@@ -1,29 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import { useApiHook } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { useOrderId } from '../../../../store';
|
|
5
|
+
|
|
6
|
+
import { Empty, Skeleton } from 'antd';
|
|
7
|
+
import { format } from 'date-fns';
|
|
8
|
+
import {
|
|
9
|
+
EmptyDataContainer,
|
|
10
|
+
StyledTable,
|
|
11
|
+
StyledTableWrapper,
|
|
12
|
+
} from './ReminderStyles';
|
|
4
13
|
|
|
5
14
|
function NotesTable() {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const [moduleIds, setModuleIds] = useState<{
|
|
16
|
+
id?: string;
|
|
17
|
+
child_id?: string;
|
|
18
|
+
} | null>(null);
|
|
19
|
+
const [orderId] = useOrderId();
|
|
20
|
+
const [notes, setNotes] = useState<any>();
|
|
21
|
+
const [loading, setNoteLoadingStore] = useState(false);
|
|
22
|
+
|
|
23
|
+
// Fetch module IDs
|
|
24
|
+
const { data: fetchedData, loading: apiLoading } = useApiHook<{ data: any }>({
|
|
25
|
+
endpoint: 'audit_logs/modules/',
|
|
26
|
+
method: 'GET',
|
|
27
|
+
pagination: { page: 1, per_page: 100 },
|
|
28
|
+
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!apiLoading && fetchedData?.data) {
|
|
31
|
+
const modules = fetchedData?.data
|
|
32
|
+
.filter((item: any) => item?.name === 'ORDER')
|
|
33
|
+
.map((item: any) => {
|
|
34
|
+
const orderProductId = item?.static_child_mappings.find(
|
|
35
|
+
(i: any) => i?.child_module?.name === 'ORDER-PRODUCT'
|
|
36
|
+
)?.child_module?.id;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
id: item?.id,
|
|
40
|
+
child_id: orderProductId || null,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
setModuleIds(modules[0] || null);
|
|
44
|
+
}
|
|
45
|
+
}, [apiLoading, fetchedData]);
|
|
46
|
+
|
|
47
|
+
// Fetch Notes Data
|
|
48
|
+
const {
|
|
49
|
+
data: NotesData,
|
|
50
|
+
loading: NotesLoading,
|
|
51
|
+
setShouldPerformAction,
|
|
52
|
+
} = useApiHook<{ data: any }>({
|
|
53
|
+
endpoint: `audit_logs/?module_id=${moduleIds?.id}&module_object_id=${orderId}`,
|
|
54
|
+
method: 'GET',
|
|
55
|
+
performAction: false,
|
|
56
|
+
});
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setNoteLoadingStore(true);
|
|
59
|
+
if (moduleIds) {
|
|
60
|
+
setShouldPerformAction(true);
|
|
61
|
+
}
|
|
62
|
+
if (!NotesLoading && NotesData?.data) {
|
|
63
|
+
const OrdersData = NotesData?.data[0]?.ORDER || [];
|
|
64
|
+
const OrderNotesData = NotesData?.data[1]?.['ORDER-PRODUCT'] || [];
|
|
65
|
+
const allNotes = [...OrdersData, ...OrderNotesData];
|
|
66
|
+
setNotes(allNotes);
|
|
67
|
+
setNoteLoadingStore(NotesLoading);
|
|
68
|
+
}
|
|
69
|
+
}, [moduleIds, NotesLoading]);
|
|
70
|
+
|
|
71
|
+
if (notes?.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
22
74
|
|
|
23
75
|
return (
|
|
24
76
|
<Container>
|
|
25
|
-
<Title>Notes (
|
|
26
|
-
<
|
|
77
|
+
<Title>Notes ({notes?.length})</Title>
|
|
78
|
+
<StyledTableWrapper>
|
|
79
|
+
<StyledTable className="scrollClass">
|
|
80
|
+
<thead>
|
|
81
|
+
<tr>
|
|
82
|
+
<th>Created</th>
|
|
83
|
+
<th>Notes</th>
|
|
84
|
+
</tr>
|
|
85
|
+
</thead>
|
|
86
|
+
<tbody>
|
|
87
|
+
{loading ? (
|
|
88
|
+
<tr>
|
|
89
|
+
<td colSpan={6}>
|
|
90
|
+
<Skeleton active />
|
|
91
|
+
</td>
|
|
92
|
+
<td colSpan={6}></td>
|
|
93
|
+
</tr>
|
|
94
|
+
) : notes?.length === 0 ? (
|
|
95
|
+
<tr>
|
|
96
|
+
<td className="emptyTd" colSpan={7}>
|
|
97
|
+
<EmptyDataContainer>
|
|
98
|
+
<Empty />
|
|
99
|
+
</EmptyDataContainer>
|
|
100
|
+
</td>
|
|
101
|
+
</tr>
|
|
102
|
+
) : (
|
|
103
|
+
notes?.map((order: any) => (
|
|
104
|
+
<tr key={order.id}>
|
|
105
|
+
<td>
|
|
106
|
+
<div
|
|
107
|
+
style={{
|
|
108
|
+
fontWeight: 'bold',
|
|
109
|
+
textTransform: 'capitalize',
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{order?.created_by}
|
|
113
|
+
</div>
|
|
114
|
+
<div>
|
|
115
|
+
{format(
|
|
116
|
+
new Date(order?.created_at),
|
|
117
|
+
"dd/MM/yyyy '@' HH:mm"
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
</td>
|
|
121
|
+
<td>{order?.description}</td>
|
|
122
|
+
</tr>
|
|
123
|
+
))
|
|
124
|
+
)}
|
|
125
|
+
</tbody>
|
|
126
|
+
</StyledTable>
|
|
127
|
+
</StyledTableWrapper>
|
|
27
128
|
</Container>
|
|
28
129
|
);
|
|
29
130
|
}
|
package/src/components/order-view/order-actions/actions/confirm-order/tables/ProductTable.tsx
CHANGED
|
@@ -1,43 +1,65 @@
|
|
|
1
|
-
import { AntTable } from '@bjsdistribution/dms-component-library';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import styled from 'styled-components';
|
|
3
|
+
import { useProductDetails } from '../../../../store';
|
|
4
|
+
|
|
5
|
+
import { Empty, Skeleton } from 'antd';
|
|
6
|
+
import { useLoading } from '../../../../../order-daily-overview/store/store';
|
|
7
|
+
import {
|
|
8
|
+
EmptyDataContainer,
|
|
9
|
+
StyledTable,
|
|
10
|
+
StyledTableWrapper,
|
|
11
|
+
} from './ReminderStyles';
|
|
4
12
|
|
|
5
13
|
function ProductTable() {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
action: 'option1',
|
|
9
|
-
code: 'FFLMW-B1',
|
|
10
|
-
description:
|
|
11
|
-
'Flair Furnishings Loop Midsleeper White /DOUBLE COXMOOR NEST OF 3 TABLES - OAK',
|
|
12
|
-
parts: '1',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
action: 'option2',
|
|
16
|
-
code: 'FFLMW-B1',
|
|
17
|
-
description:
|
|
18
|
-
'Flair Furnishings Loop Midsleeper White /DOUBLE COXMOOR NEST OF 3 TABLES - OAK',
|
|
19
|
-
parts: '1',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
action: 'option3',
|
|
23
|
-
code: 'FFLMW-B1',
|
|
24
|
-
description:
|
|
25
|
-
'Flair Furnishings Loop Midsleeper White /DOUBLE COXMOOR NEST OF 3 TABLES - OAK',
|
|
26
|
-
parts: '2',
|
|
27
|
-
},
|
|
28
|
-
];
|
|
14
|
+
const [orderProductDetails] = useProductDetails();
|
|
15
|
+
const [loading] = useLoading();
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{ key: 'description', title: 'Description', isSelect: false },
|
|
34
|
-
{ key: 'parts', title: 'Parts', isSelect: false },
|
|
35
|
-
];
|
|
17
|
+
if (!orderProductDetails) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
36
20
|
|
|
37
21
|
return (
|
|
38
22
|
<Container>
|
|
39
|
-
<Title>Products(
|
|
40
|
-
<
|
|
23
|
+
<Title>Products ({orderProductDetails?.length})</Title>
|
|
24
|
+
<StyledTableWrapper>
|
|
25
|
+
<StyledTable className="scrollClass">
|
|
26
|
+
<thead>
|
|
27
|
+
<tr>
|
|
28
|
+
<th>Action</th>
|
|
29
|
+
<th>Code</th>
|
|
30
|
+
<th>Description</th>
|
|
31
|
+
<th>Parts</th>
|
|
32
|
+
</tr>
|
|
33
|
+
</thead>
|
|
34
|
+
<tbody>
|
|
35
|
+
{loading ? (
|
|
36
|
+
<tr>
|
|
37
|
+
<td colSpan={6}>
|
|
38
|
+
<Skeleton active />
|
|
39
|
+
</td>
|
|
40
|
+
<td colSpan={6}></td>
|
|
41
|
+
</tr>
|
|
42
|
+
) : orderProductDetails?.length === 0 ? (
|
|
43
|
+
<tr>
|
|
44
|
+
<td className="emptyTd" colSpan={7}>
|
|
45
|
+
<EmptyDataContainer>
|
|
46
|
+
<Empty />
|
|
47
|
+
</EmptyDataContainer>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
) : (
|
|
51
|
+
orderProductDetails?.map((order: any) => (
|
|
52
|
+
<tr key={order.id}>
|
|
53
|
+
<td>{order?.order_product_type?.type}</td>
|
|
54
|
+
<td>{order?.code}</td>
|
|
55
|
+
<td>{order?.description}</td>
|
|
56
|
+
<td>{order?.sku}</td>
|
|
57
|
+
</tr>
|
|
58
|
+
))
|
|
59
|
+
)}
|
|
60
|
+
</tbody>
|
|
61
|
+
</StyledTable>
|
|
62
|
+
</StyledTableWrapper>
|
|
41
63
|
</Container>
|
|
42
64
|
);
|
|
43
65
|
}
|