@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
|
@@ -12,6 +12,7 @@ import { atom, useAtom } from 'jotai';
|
|
|
12
12
|
import {
|
|
13
13
|
useActionTypeOptions,
|
|
14
14
|
useClearState,
|
|
15
|
+
useClientPortal,
|
|
15
16
|
useCustomerData,
|
|
16
17
|
useReturnPayload,
|
|
17
18
|
} from '../../store';
|
|
@@ -47,8 +48,8 @@ function SelectionFilter() {
|
|
|
47
48
|
const [actionTypeOptions, setActionTypeOptions] = useActionTypeOptions();
|
|
48
49
|
const [locationOptions, setLocationOptions] = useLocationOptions();
|
|
49
50
|
const [searchParams] = useSearchParams();
|
|
51
|
+
const [clientPortal] = useClientPortal();
|
|
50
52
|
const navigate = useNavigate();
|
|
51
|
-
|
|
52
53
|
//API for client data
|
|
53
54
|
const { data: fetchedCustomerData, loading: loading, fetchData } = useAxios<
|
|
54
55
|
ApiResponse
|
|
@@ -60,7 +61,9 @@ function SelectionFilter() {
|
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
+
if (!clientPortal && clientPortal !== undefined) {
|
|
65
|
+
fetchData();
|
|
66
|
+
}
|
|
64
67
|
}, []);
|
|
65
68
|
|
|
66
69
|
useEffect(() => {
|
|
@@ -57,8 +57,9 @@ function ReturnMainTable() {
|
|
|
57
57
|
pagination: { is_pagination: false },
|
|
58
58
|
showLoader: false,
|
|
59
59
|
});
|
|
60
|
+
|
|
60
61
|
useEffect(() => {
|
|
61
|
-
if (!clientPortal) {
|
|
62
|
+
if (!clientPortal && clientPortal !== undefined) {
|
|
62
63
|
fetchData();
|
|
63
64
|
}
|
|
64
65
|
}, []);
|
|
@@ -84,9 +85,8 @@ function ReturnMainTable() {
|
|
|
84
85
|
filters: filters,
|
|
85
86
|
showLoader: false,
|
|
86
87
|
});
|
|
87
|
-
|
|
88
88
|
useEffect(() => {
|
|
89
|
-
if (!clientPortal) {
|
|
89
|
+
if (!clientPortal && clientPortal !== undefined) {
|
|
90
90
|
fetchProductStats();
|
|
91
91
|
}
|
|
92
92
|
}, []);
|
|
@@ -314,35 +314,6 @@ function ConfirmOrder(props: IProps) {
|
|
|
314
314
|
setCurrentAction(undefined);
|
|
315
315
|
};
|
|
316
316
|
|
|
317
|
-
// const isDifferent = () => {
|
|
318
|
-
// const keysToRemovefromOrders = [
|
|
319
|
-
// 'order_locked',
|
|
320
|
-
// 'order_communications',
|
|
321
|
-
// 'updated_at',
|
|
322
|
-
// 'updated_by',
|
|
323
|
-
// 'order_services',
|
|
324
|
-
// ];
|
|
325
|
-
// const filteredOrderDetails = filterObject(
|
|
326
|
-
// orderDetailsConfirmOrder,
|
|
327
|
-
// keysToRemovefromOrders
|
|
328
|
-
// );
|
|
329
|
-
// const filteredPrevOrderDetails = filterObject(
|
|
330
|
-
// prevOrderDetails,
|
|
331
|
-
// keysToRemovefromOrders
|
|
332
|
-
// );
|
|
333
|
-
//
|
|
334
|
-
// const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
335
|
-
// const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
336
|
-
// const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
337
|
-
//
|
|
338
|
-
// console.log(orderDetailsSorted, 'orderDetailsSorted');
|
|
339
|
-
// console.log(prevOrderDetailsSorted, 'prevOrderDetailsSorted');
|
|
340
|
-
// console.log(isSame, 'isSameisSame');
|
|
341
|
-
//
|
|
342
|
-
// newOrderServicesSorted === prevOrderServicesSorted;
|
|
343
|
-
// return !isSame;
|
|
344
|
-
// };
|
|
345
|
-
|
|
346
317
|
const errorFound = () => {
|
|
347
318
|
const isError =
|
|
348
319
|
errorState.emailError.length > 0 ||
|
|
@@ -29,7 +29,6 @@ import BaseCharges from './charges/base-charge';
|
|
|
29
29
|
import DeliveryAddOns from './charges/delivery-add-ons';
|
|
30
30
|
import AdhocSection from './charges/adhoc';
|
|
31
31
|
import OrderInfo from './order-info';
|
|
32
|
-
import {} from '../../store';
|
|
33
32
|
import ForceDebriefSelector from './Selector';
|
|
34
33
|
import {
|
|
35
34
|
Checkbox,
|
|
@@ -41,7 +40,7 @@ import Escalation from './escalation';
|
|
|
41
40
|
import FDNotification from './notifications';
|
|
42
41
|
|
|
43
42
|
import { compareOrderDetailsStates, filterObject } from '../../../utils';
|
|
44
|
-
import { AdhocCharge, ApiResponse,
|
|
43
|
+
import { AdhocCharge, ApiResponse, OrdersType } from '../../../types';
|
|
45
44
|
import { notification } from 'antd';
|
|
46
45
|
import BaseChargeConfirmationModal from './BaseChargeConfirmationModal';
|
|
47
46
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -223,7 +222,6 @@ function ForceDebriefModal(props: IProps) {
|
|
|
223
222
|
'order_communications',
|
|
224
223
|
'updated_at',
|
|
225
224
|
'updated_by',
|
|
226
|
-
'order_services',
|
|
227
225
|
];
|
|
228
226
|
const filteredOrderDetails = filterObject(
|
|
229
227
|
orderDetails,
|
|
@@ -234,25 +232,9 @@ function ForceDebriefModal(props: IProps) {
|
|
|
234
232
|
keysToRemovefromOrders
|
|
235
233
|
);
|
|
236
234
|
|
|
237
|
-
const newOrderServices =
|
|
238
|
-
orderDetails?.order_services?.length > 0 &&
|
|
239
|
-
orderDetails?.order_services?.sort(
|
|
240
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
const prevOrderServices =
|
|
244
|
-
prevOrderDetails?.order_services?.length > 0 &&
|
|
245
|
-
prevOrderDetails?.order_services.sort(
|
|
246
|
-
(a: OrderServiceType, b: OrderServiceType) => a.id! - b.id!
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
const newOrderServicesSorted = JSON.stringify(newOrderServices);
|
|
250
|
-
const prevOrderServicesSorted = JSON.stringify(prevOrderServices);
|
|
251
235
|
const orderDetailsSorted = JSON.stringify(filteredOrderDetails);
|
|
252
236
|
const prevOrderDetailsSorted = JSON.stringify(filteredPrevOrderDetails);
|
|
253
|
-
const isSame =
|
|
254
|
-
orderDetailsSorted === prevOrderDetailsSorted &&
|
|
255
|
-
newOrderServicesSorted === prevOrderServicesSorted;
|
|
237
|
+
const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
256
238
|
return !isSame;
|
|
257
239
|
};
|
|
258
240
|
|
|
@@ -285,6 +267,39 @@ function ForceDebriefModal(props: IProps) {
|
|
|
285
267
|
orderDetails
|
|
286
268
|
);
|
|
287
269
|
|
|
270
|
+
const serviceKeys = [
|
|
271
|
+
'assemble',
|
|
272
|
+
'disassemble',
|
|
273
|
+
'unpack_items',
|
|
274
|
+
'collect_disposal',
|
|
275
|
+
'take_packaging_away',
|
|
276
|
+
'assembly_type',
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
let orderServicesPayload: Record<string, any> = {};
|
|
280
|
+
|
|
281
|
+
const includesKey = serviceKeys.some(key => key in ordersApiPayload);
|
|
282
|
+
|
|
283
|
+
if (includesKey) {
|
|
284
|
+
for (const key of serviceKeys) {
|
|
285
|
+
orderServicesPayload[key as keyof typeof ordersApiPayload] =
|
|
286
|
+
key in ordersApiPayload
|
|
287
|
+
? ordersApiPayload[key as keyof typeof ordersApiPayload]
|
|
288
|
+
: orderDetails[key as keyof OrdersType];
|
|
289
|
+
delete ordersApiPayload[key as keyof typeof ordersApiPayload];
|
|
290
|
+
if (
|
|
291
|
+
orderServicesPayload?.assemble === false &&
|
|
292
|
+
orderServicesPayload?.disassemble === false
|
|
293
|
+
) {
|
|
294
|
+
orderServicesPayload.assembly_type = null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (Object.keys(orderServicesPayload).length > 0) {
|
|
300
|
+
ordersApiPayload.order_services = [orderServicesPayload];
|
|
301
|
+
}
|
|
302
|
+
|
|
288
303
|
try {
|
|
289
304
|
let response = (await callUpdateOrderAPI({
|
|
290
305
|
payload: [ordersApiPayload],
|
package/src/components/order-view/order-actions/actions/force-debrief/order-info/RadioButtons.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { RadioButtonGroup } from '@bjsdistribution/dms-component-library';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { useOrderDetails, useOrderStaticData } from '../../../../store';
|
|
5
|
-
import {
|
|
5
|
+
import { OrdersType } from '../../../../types';
|
|
6
6
|
import { capitalize } from '../../../../utils';
|
|
7
7
|
|
|
8
8
|
export const radioButtonFilterOptions = [
|
|
@@ -36,7 +36,6 @@ function RadioButtonGroups() {
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const orderServicesOptions = orderStaticData?.order_service_list;
|
|
39
|
-
const orderServices = orderDetails?.order_services;
|
|
40
39
|
const deliveryPointId = orderDetails?.order_services_detail?.order_delivery_point_id?.toString();
|
|
41
40
|
const serviceLevelId = orderDetails?.order_services_detail?.order_service_level_id?.toString();
|
|
42
41
|
const orderTypeId = orderDetails?.order_type_id?.toString();
|
|
@@ -68,61 +67,15 @@ function RadioButtonGroups() {
|
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
const onChangeServices = (id: number) => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
// Check if the service already exists in the order
|
|
74
|
-
const selectedService = clone.find(
|
|
75
|
-
(s: OrderServiceType) => s.order_service_list_id === id
|
|
70
|
+
const selectedService = orderServicesOptions?.find(
|
|
71
|
+
(item: any) => item.id === id
|
|
76
72
|
);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
const newData = {
|
|
85
|
-
...orderDetails,
|
|
86
|
-
order_services: updatedOrderServices,
|
|
87
|
-
};
|
|
88
|
-
setOrderDetails(newData);
|
|
89
|
-
} else {
|
|
90
|
-
// It's an existing (persisted) service, toggle its `is_deleted` flag
|
|
91
|
-
const updatedSelectedService = {
|
|
92
|
-
...selectedService,
|
|
93
|
-
is_deleted: !selectedService.is_deleted,
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const updatedOrderServices = clone
|
|
97
|
-
.filter(
|
|
98
|
-
(service: OrderServiceType) => service.id !== selectedService.id
|
|
99
|
-
)
|
|
100
|
-
.concat(updatedSelectedService);
|
|
101
|
-
|
|
102
|
-
const newData = {
|
|
103
|
-
...orderDetails,
|
|
104
|
-
order_services: updatedOrderServices,
|
|
105
|
-
};
|
|
106
|
-
setOrderDetails(newData);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
// Case 2: Service doesn't exist — add it as a new one
|
|
110
|
-
const newService: OrderServiceType = {
|
|
111
|
-
is_deleted: false,
|
|
112
|
-
order_service_list_id: id,
|
|
113
|
-
new_id: id,
|
|
114
|
-
id: id,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
clone.push(newService);
|
|
118
|
-
|
|
119
|
-
const newData = {
|
|
120
|
-
...orderDetails,
|
|
121
|
-
order_services: clone,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
setOrderDetails(newData);
|
|
125
|
-
}
|
|
73
|
+
const key = selectedService?.type;
|
|
74
|
+
const value = !orderDetails[key as keyof OrdersType];
|
|
75
|
+
setOrderDetails(prev => ({
|
|
76
|
+
...prev,
|
|
77
|
+
[key]: value,
|
|
78
|
+
}));
|
|
126
79
|
};
|
|
127
80
|
|
|
128
81
|
return (
|
|
@@ -162,18 +115,14 @@ function RadioButtonGroups() {
|
|
|
162
115
|
</Group>
|
|
163
116
|
|
|
164
117
|
{orderServicesOptions?.map((service: any) => {
|
|
165
|
-
const selected =
|
|
166
|
-
(s: OrderServiceType) =>
|
|
167
|
-
s?.order_service_list_id === service?.id && s.is_deleted === false
|
|
168
|
-
);
|
|
169
|
-
|
|
118
|
+
const selected = orderDetails[service?.type as keyof OrdersType];
|
|
170
119
|
return (
|
|
171
120
|
<Group>
|
|
172
121
|
<RadioButtonGroup
|
|
173
122
|
heading={service?.type?.replaceAll('_', ' ')}
|
|
174
123
|
onChange={() => onChangeServices(service?.id)}
|
|
175
124
|
options={radioButtonFilterOptions || []}
|
|
176
|
-
selectedValue={selected
|
|
125
|
+
selectedValue={selected ? 'true' : 'false'}
|
|
177
126
|
direction="vertical"
|
|
178
127
|
required={false}
|
|
179
128
|
isDisabled
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
useStatusDetails,
|
|
13
13
|
} from '../store';
|
|
14
14
|
import SplitOrder from './actions/split-order';
|
|
15
|
-
import LogServiceRefusal from './actions/log-service-refusal';
|
|
16
15
|
import CancelOrder from './actions/cancel-order';
|
|
17
16
|
import ConfirmOrder from './actions/confirm-order';
|
|
18
17
|
import SendSmsModal from './actions/send-sms/SendSmsModal';
|
|
@@ -213,10 +212,7 @@ function OrderActions() {
|
|
|
213
212
|
return <SplitOrder />;
|
|
214
213
|
case 'release-order':
|
|
215
214
|
return <ReleaseOrder />;
|
|
216
|
-
|
|
217
|
-
// return <UnreleaseOrder />;
|
|
218
|
-
case 'log-service-refusal':
|
|
219
|
-
return <LogServiceRefusal callOrdersApi={callOrdersApi} />;
|
|
215
|
+
|
|
220
216
|
case 'cancel-order':
|
|
221
217
|
return (
|
|
222
218
|
<CancelOrder
|
|
@@ -1,25 +1,48 @@
|
|
|
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 { useClientPortal } from '../../../../../store';
|
|
6
12
|
|
|
7
|
-
//
|
|
13
|
+
//import { VALIDATE_UK_IRISH_NUMBER_REGEX } from '../../../helper';
|
|
14
|
+
import CallCustomer from './CallCustomer';
|
|
8
15
|
|
|
9
16
|
function ContactHome() {
|
|
10
17
|
const [errors, setErrors] = useAtom(errorAtom);
|
|
11
|
-
|
|
12
|
-
// Show call icons only if number is valid
|
|
13
|
-
// show copy icon if there is input value
|
|
18
|
+
const [isClientPortal] = useClientPortal();
|
|
14
19
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
20
|
+
const [prevOrderDetails] = usePrevOrderDetails();
|
|
21
|
+
const apiContactHome = prevOrderDetails?.order_recipient?.contact_home;
|
|
15
22
|
const orderRecipient = orderDetails?.order_recipient;
|
|
16
23
|
|
|
17
24
|
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
18
|
-
|
|
25
|
+
let val = e.target.value.replace(/\s+/g, '');
|
|
26
|
+
console.log(val, 'valuee');
|
|
27
|
+
|
|
28
|
+
if (!/^\+?\d*$/.test(val)) return;
|
|
29
|
+
|
|
30
|
+
const validPrefixes = ['+44', '44', '0', '+353', '353'];
|
|
31
|
+
|
|
32
|
+
let matchedPrefix = validPrefixes.find(prefix => val.startsWith(prefix));
|
|
33
|
+
let prefix = matchedPrefix || '';
|
|
34
|
+
let numberPart = val.slice(prefix.length);
|
|
35
|
+
|
|
36
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
37
|
+
|
|
38
|
+
if (numberPart.length > digitLimit) return;
|
|
39
|
+
|
|
40
|
+
const contactValue = val;
|
|
41
|
+
|
|
19
42
|
const updatedOrderRecipient = {
|
|
20
43
|
...(orderRecipient === null
|
|
21
|
-
? { contact_home:
|
|
22
|
-
: { ...orderRecipient, contact_home:
|
|
44
|
+
? { contact_home: contactValue }
|
|
45
|
+
: { ...orderRecipient, contact_home: contactValue }),
|
|
23
46
|
};
|
|
24
47
|
|
|
25
48
|
setOrderDetails(prev => ({
|
|
@@ -27,58 +50,100 @@ function ContactHome() {
|
|
|
27
50
|
order_recipient: updatedOrderRecipient,
|
|
28
51
|
}));
|
|
29
52
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
} else if (val.length > 11) {
|
|
37
|
-
setErrors(prevErrors => ({
|
|
38
|
-
...prevErrors,
|
|
39
|
-
homeContactError: 'Phone number must not exceed 11 digits.',
|
|
40
|
-
}));
|
|
41
|
-
} else {
|
|
42
|
-
setErrors(prevErrors => ({
|
|
43
|
-
...prevErrors,
|
|
44
|
-
homeContactError: '',
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
setErrors(prevErrors => ({
|
|
49
|
-
...prevErrors,
|
|
50
|
-
homeContactError: '',
|
|
53
|
+
if (!numberPart) {
|
|
54
|
+
setErrors(prev => ({ ...prev, homeContactError: '' }));
|
|
55
|
+
} else if (numberPart.length !== digitLimit) {
|
|
56
|
+
setErrors(prev => ({
|
|
57
|
+
...prev,
|
|
58
|
+
homeContactError: `Number must have exactly ${digitLimit} digits after the prefix.`,
|
|
51
59
|
}));
|
|
60
|
+
} else {
|
|
61
|
+
setErrors(prev => ({ ...prev, homeContactError: '' }));
|
|
52
62
|
}
|
|
53
63
|
};
|
|
54
64
|
|
|
55
65
|
return (
|
|
56
|
-
<
|
|
66
|
+
<Container>
|
|
57
67
|
<Wrapper>
|
|
58
68
|
<Label label="Contact Home" htmlFor="contact-home" />
|
|
59
|
-
{/* {showCopyIcon && <CopyText text={orderRecipient?.contact_home!} />} */}
|
|
60
69
|
</Wrapper>
|
|
61
70
|
<InputContainer>
|
|
62
71
|
<CustomInput
|
|
63
72
|
name="contact-home"
|
|
73
|
+
// maxLength={12}
|
|
64
74
|
type="text"
|
|
65
75
|
placeholder="Home Number"
|
|
66
76
|
onKeyDown={handleKeyDown}
|
|
67
|
-
minLength={10}
|
|
68
|
-
maxLength={10}
|
|
69
77
|
value={orderRecipient?.contact_home || ''}
|
|
70
78
|
onChange={onChange}
|
|
79
|
+
disabled={isClientPortal}
|
|
71
80
|
/>
|
|
81
|
+
{/*
|
|
82
|
+
<CallCustomer /> */}
|
|
83
|
+
{apiContactHome &&
|
|
84
|
+
(() => {
|
|
85
|
+
const rawNumber = apiContactHome.replace(/\s+/g, '');
|
|
86
|
+
|
|
87
|
+
let formattedNumber = rawNumber.replace(/\D/g, ''); // digits only
|
|
88
|
+
let prefix = '';
|
|
89
|
+
let numberPart = '';
|
|
90
|
+
|
|
91
|
+
if (rawNumber.startsWith('+44')) {
|
|
92
|
+
prefix = '+44';
|
|
93
|
+
numberPart = formattedNumber.slice(2);
|
|
94
|
+
} else if (rawNumber.startsWith('44')) {
|
|
95
|
+
prefix = '44';
|
|
96
|
+
numberPart = formattedNumber.slice(2);
|
|
97
|
+
} else if (rawNumber.startsWith('0')) {
|
|
98
|
+
prefix = '0';
|
|
99
|
+
numberPart = formattedNumber.slice(1);
|
|
100
|
+
} else if (rawNumber.startsWith('+353')) {
|
|
101
|
+
prefix = '+353';
|
|
102
|
+
numberPart = formattedNumber.slice(3);
|
|
103
|
+
} else if (rawNumber.startsWith('353')) {
|
|
104
|
+
prefix = '353';
|
|
105
|
+
numberPart = formattedNumber.slice(3);
|
|
106
|
+
} else {
|
|
107
|
+
numberPart = formattedNumber;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Set digit limit based on prefix
|
|
111
|
+
const digitLimit = prefix === '+353' || prefix === '353' ? 9 : 10;
|
|
112
|
+
|
|
113
|
+
if (numberPart.length !== digitLimit) return null;
|
|
114
|
+
|
|
115
|
+
let hrefPrefix = '';
|
|
72
116
|
|
|
73
|
-
|
|
117
|
+
if (prefix === '0' || prefix === '44' || prefix === '+44') {
|
|
118
|
+
hrefPrefix = '+44';
|
|
119
|
+
} else if (prefix === '353' || prefix === '+353') {
|
|
120
|
+
hrefPrefix = '+353';
|
|
121
|
+
} else {
|
|
122
|
+
hrefPrefix = '+44';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const finalHref = `tel:${hrefPrefix}${numberPart}`;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<a href={finalHref} style={{ cursor: 'pointer' }}>
|
|
129
|
+
<CallCustomer />
|
|
130
|
+
</a>
|
|
131
|
+
);
|
|
132
|
+
})()}
|
|
74
133
|
</InputContainer>
|
|
75
134
|
{errors.homeContactError && (
|
|
76
135
|
<ErrorText>{errors.homeContactError}</ErrorText>
|
|
77
136
|
)}
|
|
78
|
-
</
|
|
137
|
+
</Container>
|
|
79
138
|
);
|
|
80
139
|
}
|
|
81
140
|
|
|
141
|
+
const InputContainer = styled.div`
|
|
142
|
+
display: flex;
|
|
143
|
+
gap: 7px;
|
|
144
|
+
align-items: center;
|
|
145
|
+
`;
|
|
146
|
+
|
|
82
147
|
const Wrapper = styled.div`
|
|
83
148
|
display: flex;
|
|
84
149
|
align-items: center;
|
|
@@ -87,9 +152,6 @@ const Wrapper = styled.div`
|
|
|
87
152
|
|
|
88
153
|
const CustomInput = styled(Input)`
|
|
89
154
|
width: 80%;
|
|
90
|
-
// @media (max-width: 1024px) {
|
|
91
|
-
// width: 80%;
|
|
92
|
-
// }
|
|
93
155
|
|
|
94
156
|
&::-webkit-outer-spin-button,
|
|
95
157
|
&::-webkit-inner-spin-button {
|
|
@@ -101,13 +163,7 @@ const CustomInput = styled(Input)`
|
|
|
101
163
|
}
|
|
102
164
|
`;
|
|
103
165
|
|
|
104
|
-
const
|
|
105
|
-
display: flex;
|
|
106
|
-
gap: 7px;
|
|
107
|
-
align-items: center;
|
|
108
|
-
`;
|
|
109
|
-
|
|
110
|
-
const MainContainer = styled.div`
|
|
166
|
+
const Container = styled.div`
|
|
111
167
|
display: flex;
|
|
112
168
|
flex-direction: column;
|
|
113
169
|
gap: 6px;
|
|
@@ -119,4 +175,5 @@ const ErrorText = styled.span`
|
|
|
119
175
|
font-size: 0.85rem;
|
|
120
176
|
margin-top: 4px;
|
|
121
177
|
`;
|
|
178
|
+
|
|
122
179
|
export default ContactHome;
|