@bjsdistribution/dms-client-return 0.1.21-dev → 0.1.21-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/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/client-portal/ReturnRTFilters.d.ts +3 -0
- package/dist/components/order-daily-overview/header/route-header/ClientRouterHeader.d.ts +11 -0
- package/dist/components/order-daily-overview/table-view/TableStyle.d.ts +4 -4
- package/dist/components/order-view/types.d.ts +6 -0
- package/dist/components/order-view/utils.d.ts +8 -2
- package/dist/components/order-view/view-reminder/ViewReminder.d.ts +0 -2
- package/dist/components/store.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +2962 -3216
- 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 +2999 -3253
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/client-portal/DateFilterStore.ts +45 -0
- package/src/components/client-portal/OutstandingTable.tsx +3 -2
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +2 -1
- package/src/components/client-portal/ReturnOverview.tsx +11 -2
- package/src/components/client-portal/ReturnRTFilters.tsx +140 -41
- package/src/components/client-portal/ReturnSearchBar.tsx +3 -3
- package/src/components/client-portal/ReturnStatus.tsx +4 -2
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +1 -1
- package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +166 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +1 -78
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +5 -2
- package/src/components/order-daily-overview/index.tsx +3 -3
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +0 -29
- package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +35 -20
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +11 -62
- package/src/components/order-view/order-actions/index.tsx +1 -5
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactHome.tsx +102 -45
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactMobile.tsx +93 -34
- package/src/components/order-view/order-details/expanded-content/customer-section/contact-info/ContactWork.tsx +88 -31
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +52 -83
- package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx +9 -91
- package/src/components/order-view/order-details/expanded-content/services-section/OrderServices.tsx +10 -182
- package/src/components/order-view/store.ts +6 -0
- package/src/components/order-view/types.ts +6 -0
- package/src/components/order-view/utils.ts +12 -33
- package/src/components/order-view/view-reminder/ViewReminder.tsx +0 -2
- package/src/components/store.ts +1 -1
- package/src/index.tsx +17 -2
- package/dist/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/Notes.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/OrderServices.d.ts +0 -7
- package/dist/components/order-view/order-actions/actions/log-service-refusal/helper.d.ts +0 -3
- package/dist/components/order-view/order-actions/actions/log-service-refusal/index.d.ts +0 -3
- package/src/components/order-view/order-actions/actions/log-service-refusal/DeliveryPoint.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/Notes.tsx +0 -50
- package/src/components/order-view/order-actions/actions/log-service-refusal/OrderServices.tsx +0 -57
- package/src/components/order-view/order-actions/actions/log-service-refusal/helper.ts +0 -26
- package/src/components/order-view/order-actions/actions/log-service-refusal/index.tsx +0 -130
|
@@ -3,16 +3,21 @@ import React from 'react';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import CopyText from '../../../../../../common/copy/CopyText';
|
|
5
5
|
import CallCustomer from './CallCustomer';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
errorAtom,
|
|
8
|
+
useAtom,
|
|
9
|
+
useOrderDetails,
|
|
10
|
+
usePrevOrderDetails,
|
|
11
|
+
} from '../../../../store';
|
|
7
12
|
import { handleKeyDown } from '../../../../utils';
|
|
8
|
-
|
|
13
|
+
import { useClientPortal } from '../../../../../store';
|
|
9
14
|
|
|
10
15
|
function ContactMobile() {
|
|
11
16
|
const [errors, setErrors] = useAtom(errorAtom);
|
|
12
|
-
|
|
13
|
-
// Show call icons only if number is valid
|
|
14
|
-
// show copy icon if there is input value
|
|
17
|
+
const [isClientPortal] = useClientPortal();
|
|
15
18
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
19
|
+
const [prevOrderDetails] = usePrevOrderDetails();
|
|
20
|
+
const apiContactMobile = prevOrderDetails?.order_recipient?.contact_mobile;
|
|
16
21
|
const orderRecipient = orderDetails?.order_recipient;
|
|
17
22
|
|
|
18
23
|
const showCopyIcon =
|
|
@@ -21,11 +26,26 @@ function ContactMobile() {
|
|
|
21
26
|
orderRecipient?.contact_mobile?.length > 0;
|
|
22
27
|
|
|
23
28
|
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
24
|
-
|
|
29
|
+
let val = e.target.value.replace(/\s+/g, '');
|
|
30
|
+
|
|
31
|
+
if (!/^\+?\d*$/.test(val)) return;
|
|
32
|
+
|
|
33
|
+
const validPrefixes = ['+44', '44', '0', '+353', '353'];
|
|
34
|
+
|
|
35
|
+
let matchedPrefix = validPrefixes.find(prefix => val.startsWith(prefix));
|
|
36
|
+
let prefix = matchedPrefix || '';
|
|
37
|
+
let numberPart = val.slice(prefix.length);
|
|
38
|
+
|
|
39
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
40
|
+
|
|
41
|
+
if (numberPart.length > digitLimit) return;
|
|
42
|
+
|
|
43
|
+
const contactValue = val;
|
|
44
|
+
|
|
25
45
|
const updatedOrderRecipient = {
|
|
26
46
|
...(orderRecipient === null
|
|
27
|
-
? { contact_mobile:
|
|
28
|
-
: { ...orderRecipient, contact_mobile:
|
|
47
|
+
? { contact_mobile: contactValue }
|
|
48
|
+
: { ...orderRecipient, contact_mobile: contactValue }),
|
|
29
49
|
};
|
|
30
50
|
|
|
31
51
|
setOrderDetails(prev => ({
|
|
@@ -33,50 +53,89 @@ function ContactMobile() {
|
|
|
33
53
|
order_recipient: updatedOrderRecipient,
|
|
34
54
|
}));
|
|
35
55
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setErrors(prevErrors => ({
|
|
44
|
-
...prevErrors,
|
|
45
|
-
mobileError: 'Phone number must not exceed 11 digits.',
|
|
46
|
-
}));
|
|
47
|
-
} else {
|
|
48
|
-
setErrors(prevErrors => ({
|
|
49
|
-
...prevErrors,
|
|
50
|
-
mobileError: '',
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
setErrors(prevErrors => ({
|
|
55
|
-
...prevErrors,
|
|
56
|
-
mobileError: '',
|
|
56
|
+
// Validation errors
|
|
57
|
+
if (!numberPart) {
|
|
58
|
+
setErrors(prev => ({ ...prev, mobileError: '' }));
|
|
59
|
+
} else if (numberPart.length !== digitLimit) {
|
|
60
|
+
setErrors(prev => ({
|
|
61
|
+
...prev,
|
|
62
|
+
mobileError: `Number must have exactly ${digitLimit} digits after the prefix.`,
|
|
57
63
|
}));
|
|
64
|
+
} else {
|
|
65
|
+
setErrors(prev => ({ ...prev, mobileError: '' }));
|
|
58
66
|
}
|
|
59
67
|
};
|
|
60
68
|
|
|
61
69
|
return (
|
|
62
70
|
<Container>
|
|
63
71
|
<Wrapper>
|
|
64
|
-
<Label label="Contact Mobile" htmlFor="contact-
|
|
72
|
+
<Label label="Contact Mobile" htmlFor="contact-mobile" />
|
|
65
73
|
{showCopyIcon && <CopyText text={orderRecipient?.contact_mobile!} />}
|
|
66
74
|
</Wrapper>
|
|
67
75
|
<InputContainer>
|
|
68
76
|
<CustomInput
|
|
69
|
-
name="contact-
|
|
70
|
-
|
|
71
|
-
maxLength={10}
|
|
77
|
+
name="contact-mobile"
|
|
78
|
+
// maxLength={12}
|
|
72
79
|
type="text"
|
|
73
80
|
placeholder="Mobile Number"
|
|
74
81
|
onKeyDown={handleKeyDown}
|
|
75
82
|
value={orderRecipient?.contact_mobile || ''}
|
|
76
83
|
onChange={onChange}
|
|
84
|
+
disabled={isClientPortal}
|
|
77
85
|
/>
|
|
78
|
-
|
|
86
|
+
|
|
87
|
+
{apiContactMobile &&
|
|
88
|
+
(() => {
|
|
89
|
+
const rawNumber = apiContactMobile.replace(/\s+/g, '');
|
|
90
|
+
|
|
91
|
+
let formattedNumber = rawNumber.replace(/\D/g, '');
|
|
92
|
+
let prefix = '';
|
|
93
|
+
let numberPart = '';
|
|
94
|
+
|
|
95
|
+
if (rawNumber.startsWith('+44')) {
|
|
96
|
+
prefix = '+44';
|
|
97
|
+
numberPart = formattedNumber.slice(2);
|
|
98
|
+
} else if (rawNumber.startsWith('44')) {
|
|
99
|
+
prefix = '44';
|
|
100
|
+
numberPart = formattedNumber.slice(2);
|
|
101
|
+
} else if (rawNumber.startsWith('0')) {
|
|
102
|
+
prefix = '0';
|
|
103
|
+
numberPart = formattedNumber.slice(1);
|
|
104
|
+
} else if (rawNumber.startsWith('+353')) {
|
|
105
|
+
prefix = '+353';
|
|
106
|
+
numberPart = formattedNumber.slice(3);
|
|
107
|
+
} else if (rawNumber.startsWith('353')) {
|
|
108
|
+
prefix = '353';
|
|
109
|
+
numberPart = formattedNumber.slice(3);
|
|
110
|
+
} else {
|
|
111
|
+
numberPart = formattedNumber;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Set digit limit based on prefix
|
|
115
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
116
|
+
|
|
117
|
+
if (numberPart.length !== digitLimit) return null;
|
|
118
|
+
|
|
119
|
+
let hrefPrefix = '';
|
|
120
|
+
|
|
121
|
+
if (prefix === '0' || prefix === '44' || prefix === '+44') {
|
|
122
|
+
hrefPrefix = '+44';
|
|
123
|
+
} else if (prefix === '353' || prefix === '+353') {
|
|
124
|
+
hrefPrefix = '+353';
|
|
125
|
+
} else {
|
|
126
|
+
hrefPrefix = '+44';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const finalHref = `tel:${hrefPrefix}${numberPart}`;
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<a href={finalHref} style={{ cursor: 'pointer' }}>
|
|
133
|
+
<CallCustomer />
|
|
134
|
+
</a>
|
|
135
|
+
);
|
|
136
|
+
})()}
|
|
79
137
|
</InputContainer>
|
|
138
|
+
|
|
80
139
|
{errors.mobileError && <ErrorText>{errors.mobileError}</ErrorText>}
|
|
81
140
|
</Container>
|
|
82
141
|
);
|
|
@@ -1,52 +1,59 @@
|
|
|
1
1
|
import { Input, Label } from '@bjsdistribution/dms-component-library';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
errorAtom,
|
|
6
|
+
useAtom,
|
|
7
|
+
useOrderDetails,
|
|
8
|
+
usePrevOrderDetails,
|
|
9
|
+
} from '../../../../store';
|
|
5
10
|
import { handleKeyDown } from '../../../../utils';
|
|
11
|
+
import CallCustomer from './CallCustomer';
|
|
6
12
|
|
|
7
13
|
function ContactWork() {
|
|
8
14
|
const [errors, setErrors] = useAtom(errorAtom);
|
|
9
15
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
10
16
|
const orderRecipient = orderDetails?.order_recipient;
|
|
11
|
-
|
|
17
|
+
const [prevOrderDetails] = usePrevOrderDetails();
|
|
18
|
+
const apiContactWork = prevOrderDetails?.order_recipient?.contact_work;
|
|
12
19
|
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
13
|
-
|
|
20
|
+
let val = e.target.value.replace(/\s+/g, '');
|
|
21
|
+
|
|
22
|
+
if (!/^\+?\d*$/.test(val)) return;
|
|
23
|
+
|
|
24
|
+
const validPrefixes = ['+44', '44', '0', '+353', '353'];
|
|
25
|
+
|
|
26
|
+
let matchedPrefix = validPrefixes.find(prefix => val.startsWith(prefix));
|
|
27
|
+
let prefix = matchedPrefix || '';
|
|
28
|
+
let numberPart = val.slice(prefix.length);
|
|
29
|
+
|
|
30
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
31
|
+
|
|
32
|
+
if (numberPart.length > digitLimit) return;
|
|
33
|
+
|
|
34
|
+
const contactValue = val;
|
|
35
|
+
|
|
14
36
|
const updatedOrderRecipient = {
|
|
15
37
|
...(orderRecipient === null
|
|
16
|
-
? { contact_work:
|
|
17
|
-
: { ...orderRecipient, contact_work:
|
|
38
|
+
? { contact_work: contactValue }
|
|
39
|
+
: { ...orderRecipient, contact_work: contactValue }),
|
|
18
40
|
};
|
|
41
|
+
|
|
19
42
|
setOrderDetails(prev => ({
|
|
20
43
|
...prev,
|
|
21
44
|
order_recipient: updatedOrderRecipient,
|
|
22
45
|
}));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
workCOntanctError: 'Phone number must be at least 10 digits.',
|
|
30
|
-
}));
|
|
31
|
-
} else if (val.length > 10) {
|
|
32
|
-
setErrors(prevErrors => ({
|
|
33
|
-
...prevErrors,
|
|
34
|
-
workCOntanctError: 'Phone number must not exceed 10 digits.',
|
|
35
|
-
}));
|
|
36
|
-
} else {
|
|
37
|
-
setErrors(prevErrors => ({
|
|
38
|
-
...prevErrors,
|
|
39
|
-
workCOntanctError: '',
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
setErrors(prevErrors => ({
|
|
44
|
-
...prevErrors,
|
|
45
|
-
workCOntanctError: '',
|
|
46
|
+
if (!numberPart) {
|
|
47
|
+
setErrors(prev => ({ ...prev, workCOntanctError: '' }));
|
|
48
|
+
} else if (numberPart.length !== digitLimit) {
|
|
49
|
+
setErrors(prev => ({
|
|
50
|
+
...prev,
|
|
51
|
+
workCOntanctError: `Number must have exactly ${digitLimit} digits after the prefix.`,
|
|
46
52
|
}));
|
|
53
|
+
} else {
|
|
54
|
+
setErrors(prev => ({ ...prev, workCOntanctError: '' }));
|
|
47
55
|
}
|
|
48
56
|
};
|
|
49
|
-
|
|
50
57
|
return (
|
|
51
58
|
<Container>
|
|
52
59
|
<Wrapper>
|
|
@@ -60,9 +67,59 @@ function ContactWork() {
|
|
|
60
67
|
onKeyDown={handleKeyDown}
|
|
61
68
|
value={orderRecipient?.contact_work || ''}
|
|
62
69
|
onChange={onChange}
|
|
63
|
-
minLength={10}
|
|
64
|
-
maxLength={10}
|
|
70
|
+
// minLength={10}
|
|
71
|
+
// maxLength={10}
|
|
65
72
|
/>
|
|
73
|
+
{apiContactWork &&
|
|
74
|
+
(() => {
|
|
75
|
+
const rawNumber = apiContactWork.replace(/\s+/g, '');
|
|
76
|
+
|
|
77
|
+
let formattedNumber = rawNumber.replace(/\D/g, '');
|
|
78
|
+
let prefix = '';
|
|
79
|
+
let numberPart = '';
|
|
80
|
+
|
|
81
|
+
if (rawNumber.startsWith('+44')) {
|
|
82
|
+
prefix = '+44';
|
|
83
|
+
numberPart = formattedNumber.slice(2);
|
|
84
|
+
} else if (rawNumber.startsWith('44')) {
|
|
85
|
+
prefix = '44';
|
|
86
|
+
numberPart = formattedNumber.slice(2);
|
|
87
|
+
} else if (rawNumber.startsWith('0')) {
|
|
88
|
+
prefix = '0';
|
|
89
|
+
numberPart = formattedNumber.slice(1);
|
|
90
|
+
} else if (rawNumber.startsWith('+353')) {
|
|
91
|
+
prefix = '+353';
|
|
92
|
+
numberPart = formattedNumber.slice(3);
|
|
93
|
+
} else if (rawNumber.startsWith('353')) {
|
|
94
|
+
prefix = '353';
|
|
95
|
+
numberPart = formattedNumber.slice(3);
|
|
96
|
+
} else {
|
|
97
|
+
numberPart = formattedNumber;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Set digit limit based on prefix
|
|
101
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
102
|
+
|
|
103
|
+
if (numberPart.length !== digitLimit) return null;
|
|
104
|
+
|
|
105
|
+
let hrefPrefix = '';
|
|
106
|
+
|
|
107
|
+
if (prefix === '0' || prefix === '44' || prefix === '+44') {
|
|
108
|
+
hrefPrefix = '+44';
|
|
109
|
+
} else if (prefix === '353' || prefix === '+353') {
|
|
110
|
+
hrefPrefix = '+353';
|
|
111
|
+
} else {
|
|
112
|
+
hrefPrefix = '+44';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const finalHref = `tel:${hrefPrefix}${numberPart}`;
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<a href={finalHref} style={{ cursor: 'pointer' }}>
|
|
119
|
+
<CallCustomer />
|
|
120
|
+
</a>
|
|
121
|
+
);
|
|
122
|
+
})()}
|
|
66
123
|
</InputContainer>
|
|
67
124
|
{errors.workCOntanctError && (
|
|
68
125
|
<ErrorText>{errors.workCOntanctError}</ErrorText>
|
|
@@ -9,13 +9,12 @@ import {
|
|
|
9
9
|
errorAtom,
|
|
10
10
|
useCustomerInfo,
|
|
11
11
|
useGlobalStateHitAuditLog,
|
|
12
|
-
useOrderStaticData,
|
|
13
12
|
useGlobalStateHitOrder,
|
|
14
13
|
useLiveRecalling,
|
|
15
14
|
} from '../../../store';
|
|
16
15
|
// import useUpdateOrder from '../../../hooks/useUpdateOrder';
|
|
17
16
|
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
18
|
-
import { ApiResponse,
|
|
17
|
+
import { ApiResponse, OrdersType } from '../../../types';
|
|
19
18
|
import { notification } from 'antd';
|
|
20
19
|
import { useClientPortal } from '../../../../store';
|
|
21
20
|
|
|
@@ -26,7 +25,6 @@ function OrderDetailsFooter() {
|
|
|
26
25
|
// const updateOrder = useUpdateOrder();
|
|
27
26
|
const [errorState] = useAtom(errorAtom);
|
|
28
27
|
const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
|
|
29
|
-
const [orderStaticData] = useOrderStaticData();
|
|
30
28
|
const [, setRecallOrders] = useGlobalStateHitOrder();
|
|
31
29
|
const [isClientPortal] = useClientPortal();
|
|
32
30
|
const [, setRecalling] = useLiveRecalling();
|
|
@@ -56,7 +54,6 @@ function OrderDetailsFooter() {
|
|
|
56
54
|
'order_communications',
|
|
57
55
|
'updated_at',
|
|
58
56
|
'updated_by',
|
|
59
|
-
'order_services',
|
|
60
57
|
];
|
|
61
58
|
const filteredOrderDetails = filterObject(
|
|
62
59
|
orderDetails,
|
|
@@ -67,25 +64,9 @@ function OrderDetailsFooter() {
|
|
|
67
64
|
keysToRemovefromOrders
|
|
68
65
|
);
|
|
69
66
|
|
|
70
|
-
const newOrderServices =
|
|
71
|
-
orderDetails?.order_services?.length > 0 &&
|
|
72
|
-
orderDetails?.order_services?.sort(
|
|
73
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const prevOrderServices =
|
|
77
|
-
prevOrderDetails?.order_services?.length > 0 &&
|
|
78
|
-
prevOrderDetails?.order_services.sort(
|
|
79
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const newOrderServicesSorted = JSON.stringify(newOrderServices);
|
|
83
|
-
const prevOrderServicesSorted = JSON.stringify(prevOrderServices);
|
|
84
67
|
const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
85
68
|
const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
86
|
-
const isSame =
|
|
87
|
-
orderDetailsSorted === prevOrderDetailsSorted &&
|
|
88
|
-
newOrderServicesSorted === prevOrderServicesSorted;
|
|
69
|
+
const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
89
70
|
return !isSame;
|
|
90
71
|
};
|
|
91
72
|
|
|
@@ -94,75 +75,63 @@ function OrderDetailsFooter() {
|
|
|
94
75
|
setRecallOrders(false);
|
|
95
76
|
setRecalling(false);
|
|
96
77
|
const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
|
|
97
|
-
const clone = [...orderDetails?.order_services];
|
|
98
78
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
const serviceKeys = [
|
|
80
|
+
'assemble',
|
|
81
|
+
'disassemble',
|
|
82
|
+
'unpack_items',
|
|
83
|
+
'collect_disposal',
|
|
84
|
+
'take_packaging_away',
|
|
85
|
+
'assembly_type',
|
|
86
|
+
];
|
|
106
87
|
|
|
107
|
-
|
|
108
|
-
(x: any) => x?.order_service_list_id === assembleOrderService?.id
|
|
109
|
-
);
|
|
88
|
+
let orderServicesPayload: Record<string, any> = {};
|
|
110
89
|
|
|
111
|
-
const
|
|
112
|
-
(x: any) => x?.order_service_list_id === disassembleOrderService?.id
|
|
113
|
-
);
|
|
90
|
+
const includesKey = serviceKeys.some(key => key in payload);
|
|
114
91
|
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
92
|
+
if (includesKey) {
|
|
93
|
+
for (const key of serviceKeys) {
|
|
94
|
+
orderServicesPayload[key as keyof typeof payload] =
|
|
95
|
+
key in payload
|
|
96
|
+
? payload[key as keyof typeof payload]
|
|
97
|
+
: orderDetails[key as keyof OrdersType];
|
|
98
|
+
delete payload[key as keyof typeof payload];
|
|
99
|
+
if (
|
|
100
|
+
orderServicesPayload?.assemble === false &&
|
|
101
|
+
orderServicesPayload?.disassemble === false
|
|
102
|
+
) {
|
|
103
|
+
orderServicesPayload.assembly_type = null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (Object.keys(orderServicesPayload).length > 0) {
|
|
109
|
+
payload.order_services = [orderServicesPayload];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let response = (await callUpdateOrderAPI({
|
|
113
|
+
payload: [payload],
|
|
114
|
+
})) as {
|
|
115
|
+
code: number | null;
|
|
116
|
+
error?: string | null | undefined;
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
};
|
|
119
|
+
// const response = await updateOrder([payload]);
|
|
120
|
+
setRecallOrders(true);
|
|
121
|
+
if (response.code == 200 && response?.data?.length > 0) {
|
|
122
|
+
notification.success({
|
|
123
|
+
message: 'Success',
|
|
124
|
+
description: `${response?.message}`,
|
|
124
125
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
disassemblyTypeService?.service_category_id === null)
|
|
131
|
-
) {
|
|
132
|
-
notification.info({
|
|
133
|
-
message: 'Info',
|
|
134
|
-
description: 'Assembly Type is required',
|
|
126
|
+
setOrderDetails(response?.data[0]);
|
|
127
|
+
setPrevOrderDetails(response?.data[0]);
|
|
128
|
+
setCustomerInfo({
|
|
129
|
+
recipient_name: response?.data[0]?.order_recipient?.recipient_name,
|
|
130
|
+
postcode: response?.data[0]?.order_recipient?.postcode,
|
|
135
131
|
});
|
|
136
|
-
|
|
132
|
+
setRecallAuditLog(true);
|
|
137
133
|
} else {
|
|
138
|
-
|
|
139
|
-
payload: [payload],
|
|
140
|
-
})) as {
|
|
141
|
-
code: number | null;
|
|
142
|
-
error?: string | null | undefined;
|
|
143
|
-
[key: string]: any;
|
|
144
|
-
};
|
|
145
|
-
// const response = await updateOrder([payload]);
|
|
146
|
-
setRecalling(true);
|
|
147
|
-
setTimeout(() => {
|
|
148
|
-
setRecalling(false);
|
|
149
|
-
}, 2000);
|
|
150
|
-
setRecallOrders(true);
|
|
151
|
-
if (response.code == 200 && response?.data?.length > 0) {
|
|
152
|
-
notification.success({
|
|
153
|
-
message: 'Success',
|
|
154
|
-
description: `${response?.message}`,
|
|
155
|
-
});
|
|
156
|
-
setOrderDetails(response?.data[0]);
|
|
157
|
-
setPrevOrderDetails(response?.data[0]);
|
|
158
|
-
setCustomerInfo({
|
|
159
|
-
recipient_name: response?.data[0]?.order_recipient?.recipient_name,
|
|
160
|
-
postcode: response?.data[0]?.order_recipient?.postcode,
|
|
161
|
-
});
|
|
162
|
-
setRecallAuditLog(true);
|
|
163
|
-
} else {
|
|
164
|
-
setOrderDetails(prevOrderDetails);
|
|
165
|
-
}
|
|
134
|
+
setOrderDetails(prevOrderDetails);
|
|
166
135
|
}
|
|
167
136
|
};
|
|
168
137
|
|
package/src/components/order-view/order-details/expanded-content/services-section/AssemblyType.tsx
CHANGED
|
@@ -3,111 +3,29 @@ import React from 'react';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useOrderDetails, useOrderStaticData } from '../../../store';
|
|
5
5
|
import { capitalize } from '../../../utils';
|
|
6
|
+
import { OrdersType } from '../../../types';
|
|
6
7
|
|
|
7
8
|
function AssemblyType() {
|
|
8
9
|
const [orderData, setOrderData] = useOrderDetails();
|
|
9
10
|
const [orderStaticData] = useOrderStaticData();
|
|
10
|
-
|
|
11
|
-
const cloneServices = [...orderServices];
|
|
12
|
-
const assembleOrderService = orderStaticData?.order_service_list?.find(
|
|
13
|
-
(x: any) => x?.type?.toLowerCase() === 'assemble'
|
|
14
|
-
);
|
|
15
|
-
const disassembleOrderService = orderStaticData?.order_service_list?.find(
|
|
16
|
-
(x: any) => x?.type?.toLowerCase() === 'disassemble'
|
|
17
|
-
);
|
|
18
|
-
const assemblyTypeService = cloneServices?.find(
|
|
19
|
-
(x: any) => x?.order_service_list_id === assembleOrderService?.id
|
|
20
|
-
);
|
|
21
|
-
const disassemblyTypeService = cloneServices?.find(
|
|
22
|
-
(x: any) => x?.order_service_list_id === disassembleOrderService?.id
|
|
23
|
-
);
|
|
24
|
-
const assemblyTypeId =
|
|
25
|
-
assemblyTypeService?.service_category_id ||
|
|
26
|
-
disassemblyTypeService?.service_category_id;
|
|
11
|
+
|
|
27
12
|
const assemblyTypeOptions = orderStaticData?.order_service_list_category?.map(
|
|
28
13
|
(option: any) => ({
|
|
29
14
|
label: capitalize(option.type.replaceAll('_', ' ')),
|
|
30
|
-
value: option.
|
|
15
|
+
value: option.type,
|
|
31
16
|
})
|
|
32
17
|
);
|
|
33
18
|
|
|
34
19
|
const radioGroupHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let updatedOrderServices: any = [];
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
(assemblyTypeService?.is_deleted === false &&
|
|
43
|
-
disassemblyTypeService?.is_deleted === true &&
|
|
44
|
-
disassemblyTypeService !== undefined &&
|
|
45
|
-
disassemblyTypeService !== null) ||
|
|
46
|
-
(disassemblyTypeService?.is_deleted === false &&
|
|
47
|
-
assemblyTypeService?.is_deleted === true &&
|
|
48
|
-
assemblyTypeService !== undefined &&
|
|
49
|
-
assemblyTypeService !== null) ||
|
|
50
|
-
(assemblyTypeService?.is_deleted === false &&
|
|
51
|
-
disassemblyTypeService?.is_deleted === false)
|
|
52
|
-
) {
|
|
53
|
-
updatedAssemblyTypeService = {
|
|
54
|
-
...assemblyTypeService!,
|
|
55
|
-
service_category_id: +event.target.value,
|
|
56
|
-
};
|
|
57
|
-
updatedDisassemblyTypeService = {
|
|
58
|
-
...disassemblyTypeService!,
|
|
59
|
-
service_category_id: +event.target.value,
|
|
60
|
-
};
|
|
61
|
-
updatedOrderServices = cloneServices?.filter(
|
|
62
|
-
s =>
|
|
63
|
-
s?.order_service_list_id !== assembleOrderService?.id &&
|
|
64
|
-
s?.order_service_list_id !== disassembleOrderService?.id
|
|
65
|
-
);
|
|
66
|
-
updatedOrderServices.push(updatedAssemblyTypeService);
|
|
67
|
-
updatedOrderServices.push(updatedDisassemblyTypeService);
|
|
68
|
-
} else if (
|
|
69
|
-
assemblyTypeService?.is_deleted === false &&
|
|
70
|
-
(disassemblyTypeService?.is_deleted === true ||
|
|
71
|
-
disassemblyTypeService === undefined ||
|
|
72
|
-
disassemblyTypeService === null)
|
|
73
|
-
) {
|
|
74
|
-
updatedAssemblyTypeService = {
|
|
75
|
-
...assemblyTypeService!,
|
|
76
|
-
service_category_id: +event.target.value,
|
|
77
|
-
};
|
|
78
|
-
updatedOrderServices = cloneServices?.filter(
|
|
79
|
-
s => s?.order_service_list_id !== assembleOrderService?.id
|
|
80
|
-
);
|
|
81
|
-
updatedOrderServices.push(updatedAssemblyTypeService);
|
|
82
|
-
} else {
|
|
83
|
-
updatedDisassemblyTypeService = {
|
|
84
|
-
...disassemblyTypeService!,
|
|
85
|
-
service_category_id: +event.target.value,
|
|
86
|
-
};
|
|
87
|
-
updatedOrderServices = cloneServices?.filter(
|
|
88
|
-
s => s?.order_service_list_id !== disassembleOrderService?.id
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
updatedOrderServices.push(updatedDisassemblyTypeService);
|
|
92
|
-
}
|
|
93
|
-
const newData = { ...orderData, order_services: updatedOrderServices };
|
|
20
|
+
const newData: OrdersType = {
|
|
21
|
+
...orderData,
|
|
22
|
+
assembly_type: event.target.value,
|
|
23
|
+
};
|
|
94
24
|
setOrderData(newData);
|
|
95
25
|
};
|
|
96
26
|
|
|
97
27
|
const isServiceDisable = () => {
|
|
98
|
-
if (
|
|
99
|
-
(assemblyTypeService?.is_deleted === true &&
|
|
100
|
-
(disassemblyTypeService?.is_deleted === true ||
|
|
101
|
-
disassemblyTypeService === undefined ||
|
|
102
|
-
disassemblyTypeService === null)) ||
|
|
103
|
-
(disassemblyTypeService?.is_deleted === true &&
|
|
104
|
-
(assemblyTypeService?.is_deleted === true ||
|
|
105
|
-
assemblyTypeService === undefined ||
|
|
106
|
-
assemblyTypeService === null)) ||
|
|
107
|
-
(assemblyTypeService === undefined &&
|
|
108
|
-
disassemblyTypeService === undefined) ||
|
|
109
|
-
(assemblyTypeService === null && disassemblyTypeService === null)
|
|
110
|
-
) {
|
|
28
|
+
if (orderData?.assemble === false && orderData?.disassemble === false) {
|
|
111
29
|
return true;
|
|
112
30
|
} else {
|
|
113
31
|
return false;
|
|
@@ -117,7 +35,7 @@ function AssemblyType() {
|
|
|
117
35
|
return (
|
|
118
36
|
<Container $isDisable={isServiceDisable()}>
|
|
119
37
|
<RadioButtonGroup
|
|
120
|
-
selectedValue={
|
|
38
|
+
selectedValue={orderData?.assembly_type || ''}
|
|
121
39
|
heading="Assembly Type"
|
|
122
40
|
options={assemblyTypeOptions || []}
|
|
123
41
|
onChange={radioGroupHandler}
|