@bjsdistribution/dms-client-return 0.1.20-dev → 0.1.20-prod
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/date-picker/header/ClearDate.d.ts +1 -1
- package/dist/components/client-portal/DateFilterStore.d.ts +15 -0
- 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/DynamicTable.d.ts +2 -1
- package/dist/components/order-view/general-information/Status.d.ts +1 -1
- package/dist/components/order-view/general-information/index.d.ts +1 -1
- package/dist/components/order-view/index.d.ts +1 -1
- package/dist/components/order-view/notes/AddNote.d.ts +1 -0
- package/dist/components/order-view/notes/order-dropdown/NewReturnDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/confirm-order/index.d.ts +4 -1
- package/dist/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/Selector.d.ts +11 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.d.ts +8 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/escalation/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/notifications/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.d.ts +7 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/index.d.ts +4 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.d.ts +3 -0
- package/dist/components/order-view/order-actions/actions/force-debrief/styles.d.ts +8 -0
- package/dist/components/order-view/order-actions/actions/hold-order/HoldOrderModal.d.ts +1 -0
- package/dist/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.d.ts +1 -1
- package/dist/components/order-view/order-actions/actions/unhold-order/UnholdOrder.d.ts +1 -0
- package/dist/components/order-view/order-actions/types.d.ts +3 -3
- package/dist/components/order-view/order-details/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/order-details/index.d.ts +1 -1
- package/dist/components/order-view/order-resources/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/products-info/expanded-content/index.d.ts +6 -1
- package/dist/components/order-view/products-info/index.d.ts +1 -1
- package/dist/components/order-view/return-client-products/ProductTable.d.ts +6 -1
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +6 -1
- package/dist/components/order-view/store.d.ts +15 -3
- package/dist/components/order-view/system-event-logs/expanded-content/index.d.ts +1 -1
- package/dist/components/order-view/types.d.ts +55 -1
- package/dist/components/order-view/utils.d.ts +11 -2
- package/dist/components/store.d.ts +1 -1
- package/dist/dms-client-return.cjs.development.js +7157 -4661
- 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 +7173 -4677
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +6 -4
- package/src/assets/icons/ActionIcon.tsx +1 -1
- package/src/assets/icons/ArrowDownIcon.tsx +2 -2
- package/src/components/client-portal/DateFilterStore.ts +139 -0
- package/src/components/client-portal/OutstandingTable.tsx +16 -72
- package/src/components/client-portal/ReturnAfterSearchBar.tsx +42 -87
- package/src/components/client-portal/ReturnOverview.tsx +11 -2
- package/src/components/client-portal/ReturnRTFilters.tsx +140 -43
- package/src/components/client-portal/ReturnSearchBar.tsx +42 -153
- package/src/components/client-portal/ReturnStatus.tsx +33 -82
- package/src/components/client-portal/return-confirm/ConfirmedMain.tsx +12 -23
- package/src/components/client-portal/return-confirm/ReturnConfirmedTable.tsx +9 -86
- package/src/components/order-daily-overview/header/route-header/ClientRouterHeader.tsx +166 -0
- package/src/components/order-daily-overview/header/route-header/RouterHeader.tsx +2 -86
- package/src/components/order-daily-overview/header-filters/SelectionFilter.tsx +46 -15
- package/src/components/order-daily-overview/index.tsx +23 -4
- package/src/components/order-daily-overview/return-after-table/ReturnAfterTable.tsx +6 -1
- package/src/components/order-daily-overview/return-after-table/table/OrderTable.tsx +3 -0
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnFilterStore.ts +36 -36
- package/src/components/order-daily-overview/return-after-table/table-filters/ReturnOrderFilter.tsx +12 -2
- package/src/components/order-daily-overview/return-order-table/ReturnTable.tsx +16 -0
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/ReturnOrderTable.tsx +25 -11
- package/src/components/order-daily-overview/table/ReturnTable.tsx +8 -4
- package/src/components/order-view/DynamicTable.tsx +21 -8
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/DropDowns.tsx +1 -1
- package/src/components/order-view/details-filters/left-side-filters/dropdowns/OptionsDropDown.tsx +9 -0
- package/src/components/order-view/details-filters/right-side-filters/Details.tsx +28 -3
- package/src/components/order-view/flags-action-modal/Dropdowns.tsx +2 -0
- package/src/components/order-view/general-information/Status.tsx +92 -18
- package/src/components/order-view/general-information/index.tsx +2 -2
- package/src/components/order-view/generic-table/AuditLogs.tsx +39 -12
- package/src/components/order-view/index.tsx +50 -8
- package/src/components/order-view/modalsPopup/ModalManager.tsx +1 -1
- package/src/components/order-view/notes/AddNote.tsx +95 -65
- package/src/components/order-view/notes/order-dropdown/NewReturnDropdown.tsx +8 -10
- package/src/components/order-view/notification/FlagTemplate.tsx +21 -10
- package/src/components/order-view/notification/OrderTemplate.tsx +192 -41
- package/src/components/order-view/notification/ReminderTemplate.tsx +28 -13
- package/src/components/order-view/notification/index.tsx +100 -55
- package/src/components/order-view/order-actions/actions/add-resources/DocFileUpload.tsx +92 -72
- package/src/components/order-view/order-actions/actions/add-resources/index.tsx +27 -10
- package/src/components/order-view/order-actions/actions/cancel-order/ReturnAction.tsx +25 -4
- package/src/components/order-view/order-actions/actions/cancel-order/ReturnReason.tsx +24 -4
- package/src/components/order-view/order-actions/actions/clear-booking-status/ClearBookingStatus.tsx +9 -2
- package/src/components/order-view/order-actions/actions/confirm-order/index.tsx +12 -35
- package/src/components/order-view/order-actions/actions/confirm-order/tables/NotesTable.tsx +1 -0
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateReminderModal.tsx +88 -30
- package/src/components/order-view/order-actions/actions/create-task-reminder/CreateTaskModal.tsx +5 -3
- package/src/components/order-view/order-actions/actions/create-task-reminder/TaskModal.tsx +2 -2
- package/src/components/order-view/order-actions/actions/force-debrief/BaseChargeConfirmationModal.tsx +94 -0
- package/src/components/order-view/order-actions/actions/force-debrief/ForceDebriefModal.tsx +635 -0
- package/src/components/order-view/order-actions/actions/force-debrief/Selector.tsx +65 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/adhoc/index.tsx +94 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/base-charge/index.tsx +106 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/collection-add-ons/index.tsx +77 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/delivery-add-ons/index.tsx +78 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/disposal-charges/index.tsx +77 -0
- package/src/components/order-view/order-actions/actions/force-debrief/charges/order-charges/index.tsx +124 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationCategory.tsx +92 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationLevel.tsx +90 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/EscalationReason.tsx +122 -0
- package/src/components/order-view/order-actions/actions/force-debrief/escalation/index.tsx +16 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/FlagsTemplate.tsx +46 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/OrderTemplate.tsx +117 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/Tabs.tsx +32 -0
- package/src/components/order-view/order-actions/actions/force-debrief/notifications/index.tsx +180 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx +150 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/CancellationReasonDropdown.tsx +40 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/FailureReasonDropdown.tsx +108 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/OrderHoldReasonDropdown.tsx +37 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/StatusDropdown.tsx +48 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/dropdowns/ZoneDropdown.tsx +27 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/failure-content/index.tsx +187 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/index.tsx +55 -0
- package/src/components/order-view/order-actions/actions/force-debrief/order-info/success-content/index.tsx +221 -0
- package/src/components/order-view/order-actions/actions/force-debrief/styles.tsx +51 -0
- package/src/components/order-view/order-actions/actions/hold-order/HoldOrderModal.tsx +2 -0
- package/src/components/order-view/order-actions/actions/remove-from-route/RemoveFromRoute.tsx +7 -2
- package/src/components/order-view/order-actions/actions/unhold-order/UnholdOrder.tsx +2 -0
- package/src/components/order-view/order-actions/index.tsx +19 -10
- package/src/components/order-view/order-actions/store.ts +1 -1
- package/src/components/order-view/order-actions/types.ts +3 -3
- 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 +55 -80
- package/src/components/order-view/order-details/expanded-content/index.tsx +37 -16
- package/src/components/order-view/order-details/expanded-content/instruction-section/index.tsx +1 -1
- 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/order-details/expanded-content/services-section/ServiceLevel.tsx +3 -4
- package/src/components/order-view/order-details/index.tsx +5 -2
- package/src/components/order-view/order-resources/expanded-content/index.tsx +2 -2
- package/src/components/order-view/products-info/expanded-content/index.tsx +33 -11
- package/src/components/order-view/products-info/index.tsx +10 -6
- package/src/components/order-view/return-client-products/ProductTable.tsx +12 -2
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +73 -23
- package/src/components/order-view/store.ts +113 -1
- package/src/components/order-view/system-event-logs/expanded-content/index.tsx +6 -2
- package/src/components/order-view/types.ts +60 -1
- package/src/components/order-view/utils.ts +49 -33
- package/src/components/order-view/view-reminder/AssigneeDropdown.tsx +85 -26
- package/src/components/order-view/view-reminder/ViewReminder.tsx +31 -14
- package/src/components/store.ts +2 -2
- package/src/index.tsx +23 -5
- 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,12 +9,12 @@ import {
|
|
|
9
9
|
errorAtom,
|
|
10
10
|
useCustomerInfo,
|
|
11
11
|
useGlobalStateHitAuditLog,
|
|
12
|
-
useOrderStaticData,
|
|
13
12
|
useGlobalStateHitOrder,
|
|
13
|
+
useLiveRecalling,
|
|
14
14
|
} from '../../../store';
|
|
15
15
|
// import useUpdateOrder from '../../../hooks/useUpdateOrder';
|
|
16
16
|
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
17
|
-
import { ApiResponse,
|
|
17
|
+
import { ApiResponse, OrdersType } from '../../../types';
|
|
18
18
|
import { notification } from 'antd';
|
|
19
19
|
import { useClientPortal } from '../../../../store';
|
|
20
20
|
|
|
@@ -25,10 +25,9 @@ function OrderDetailsFooter() {
|
|
|
25
25
|
// const updateOrder = useUpdateOrder();
|
|
26
26
|
const [errorState] = useAtom(errorAtom);
|
|
27
27
|
const [, setRecallAuditLog] = useGlobalStateHitAuditLog();
|
|
28
|
-
const [orderStaticData] = useOrderStaticData();
|
|
29
28
|
const [, setRecallOrders] = useGlobalStateHitOrder();
|
|
30
29
|
const [isClientPortal] = useClientPortal();
|
|
31
|
-
|
|
30
|
+
const [, setRecalling] = useLiveRecalling();
|
|
32
31
|
//update order
|
|
33
32
|
const { fetchData: callUpdateOrderAPI } = useAxios<{
|
|
34
33
|
data: ApiResponse[];
|
|
@@ -55,7 +54,6 @@ function OrderDetailsFooter() {
|
|
|
55
54
|
'order_communications',
|
|
56
55
|
'updated_at',
|
|
57
56
|
'updated_by',
|
|
58
|
-
'order_services',
|
|
59
57
|
];
|
|
60
58
|
const filteredOrderDetails = filterObject(
|
|
61
59
|
orderDetails,
|
|
@@ -66,97 +64,74 @@ function OrderDetailsFooter() {
|
|
|
66
64
|
keysToRemovefromOrders
|
|
67
65
|
);
|
|
68
66
|
|
|
69
|
-
const newOrderServices =
|
|
70
|
-
orderDetails?.order_services?.length > 0 &&
|
|
71
|
-
orderDetails?.order_services?.sort(
|
|
72
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const prevOrderServices =
|
|
76
|
-
prevOrderDetails?.order_services?.length > 0 &&
|
|
77
|
-
prevOrderDetails?.order_services.sort(
|
|
78
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const newOrderServicesSorted = JSON.stringify(newOrderServices);
|
|
82
|
-
const prevOrderServicesSorted = JSON.stringify(prevOrderServices);
|
|
83
67
|
const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
84
68
|
const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
85
|
-
const isSame =
|
|
86
|
-
orderDetailsSorted === prevOrderDetailsSorted &&
|
|
87
|
-
newOrderServicesSorted === prevOrderServicesSorted;
|
|
69
|
+
const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
88
70
|
return !isSame;
|
|
89
71
|
};
|
|
90
72
|
|
|
91
73
|
const onSave = async () => {
|
|
92
74
|
setRecallAuditLog(false);
|
|
93
75
|
setRecallOrders(false);
|
|
76
|
+
setRecalling(false);
|
|
94
77
|
const payload = compareOrderDetailsStates(prevOrderDetails, orderDetails);
|
|
95
|
-
const clone = [...orderDetails?.order_services];
|
|
96
78
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
79
|
+
const serviceKeys = [
|
|
80
|
+
'assemble',
|
|
81
|
+
'disassemble',
|
|
82
|
+
'unpack_items',
|
|
83
|
+
'collect_disposal',
|
|
84
|
+
'take_packaging_away',
|
|
85
|
+
'assembly_type',
|
|
86
|
+
];
|
|
104
87
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
88
|
+
let orderServicesPayload: Record<string, any> = {};
|
|
89
|
+
|
|
90
|
+
const includesKey = serviceKeys.some(key => key in payload);
|
|
91
|
+
|
|
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
|
+
}
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
if (Object.keys(orderServicesPayload).length > 0) {
|
|
109
|
+
payload.order_services = [orderServicesPayload];
|
|
110
|
+
}
|
|
112
111
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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}`,
|
|
122
125
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
disassemblyTypeService?.service_category_id === null)
|
|
129
|
-
) {
|
|
130
|
-
notification.info({
|
|
131
|
-
message: 'Info',
|
|
132
|
-
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,
|
|
133
131
|
});
|
|
134
|
-
|
|
132
|
+
setRecallAuditLog(true);
|
|
135
133
|
} else {
|
|
136
|
-
|
|
137
|
-
payload: [payload],
|
|
138
|
-
})) as {
|
|
139
|
-
code: number | null;
|
|
140
|
-
error?: string | null | undefined;
|
|
141
|
-
[key: string]: any;
|
|
142
|
-
};
|
|
143
|
-
// const response = await updateOrder([payload]);
|
|
144
|
-
setRecallOrders(true);
|
|
145
|
-
if (response.code == 200 && response?.data?.length > 0) {
|
|
146
|
-
notification.success({
|
|
147
|
-
message: 'Success',
|
|
148
|
-
description: `${response?.message}`,
|
|
149
|
-
});
|
|
150
|
-
setOrderDetails(response?.data[0]);
|
|
151
|
-
setPrevOrderDetails(response?.data[0]);
|
|
152
|
-
setCustomerInfo({
|
|
153
|
-
recipient_name: response?.data[0]?.order_recipient?.recipient_name,
|
|
154
|
-
postcode: response?.data[0]?.order_recipient?.postcode,
|
|
155
|
-
});
|
|
156
|
-
setRecallAuditLog(true);
|
|
157
|
-
} else {
|
|
158
|
-
setOrderDetails(prevOrderDetails);
|
|
159
|
-
}
|
|
134
|
+
setOrderDetails(prevOrderDetails);
|
|
160
135
|
}
|
|
161
136
|
};
|
|
162
137
|
|
|
@@ -5,24 +5,38 @@ import OrdersSection from './orders-section';
|
|
|
5
5
|
import InstructionSection from './instruction-section';
|
|
6
6
|
import ServicesSection from './services-section';
|
|
7
7
|
import OrderDetailsFooter from './footer';
|
|
8
|
+
import { Skeleton } from 'antd';
|
|
9
|
+
import { FormSection } from '@bjsdistribution/dms-component-library';
|
|
8
10
|
|
|
9
|
-
function ExpandedContent() {
|
|
11
|
+
function ExpandedContent({ orderLoading, depotDataLoading }: any) {
|
|
10
12
|
return (
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
<>
|
|
14
|
+
<MainContainer>
|
|
15
|
+
{orderLoading || depotDataLoading ? (
|
|
16
|
+
<>
|
|
17
|
+
<CustomFormSection>
|
|
18
|
+
<Skeleton paragraph={{ rows: 4 }} />
|
|
19
|
+
<Skeleton paragraph={{ rows: 4 }} />
|
|
20
|
+
</CustomFormSection>
|
|
21
|
+
</>
|
|
22
|
+
) : (
|
|
23
|
+
<>
|
|
24
|
+
<Container>
|
|
25
|
+
<HalfWidth>
|
|
26
|
+
<CustomerSection />
|
|
27
|
+
</HalfWidth>
|
|
28
|
+
<HalfWidth>
|
|
29
|
+
<OrdersSection />
|
|
30
|
+
</HalfWidth>
|
|
31
|
+
<InstructionSection />
|
|
32
|
+
</Container>
|
|
33
|
+
|
|
34
|
+
<ServicesSection />
|
|
35
|
+
<OrderDetailsFooter />
|
|
36
|
+
</>
|
|
37
|
+
)}
|
|
38
|
+
</MainContainer>
|
|
39
|
+
</>
|
|
26
40
|
);
|
|
27
41
|
}
|
|
28
42
|
|
|
@@ -86,4 +100,11 @@ const MainContainer = styled.div`
|
|
|
86
100
|
}
|
|
87
101
|
`;
|
|
88
102
|
|
|
103
|
+
const CustomFormSection = styled(FormSection)`
|
|
104
|
+
flex: 1;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
background: #f8fafc;
|
|
107
|
+
box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1);
|
|
108
|
+
`;
|
|
109
|
+
|
|
89
110
|
export default ExpandedContent;
|