@bjsdistribution/dms-client-return 0.1.49-prod → 0.1.50-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/components/order-view/northern-southern-info/CustomInput.d.ts +17 -0
- package/dist/components/order-view/northern-southern-info/index.d.ts +3 -0
- package/dist/components/order-view/return-client-products/product-table/ReturnProductTable.d.ts +1 -0
- package/dist/components/order-view/types.d.ts +37 -0
- package/dist/components/order-view/utils.d.ts +24 -0
- package/dist/components/store.d.ts +1 -0
- package/dist/dms-client-return.cjs.development.js +1089 -616
- 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 +1090 -617
- package/dist/dms-client-return.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts +30 -0
- package/src/components/order-view/index.tsx +67 -3
- package/src/components/order-view/northern-southern-info/CustomInput.tsx +80 -0
- package/src/components/order-view/northern-southern-info/index.tsx +94 -0
- package/src/components/order-view/order-details/expanded-content/customer-section/location-info/Postcode.tsx +170 -8
- package/src/components/order-view/order-details/expanded-content/footer/index.tsx +53 -2
- package/src/components/order-view/order-details/expanded-content/index.tsx +13 -1
- package/src/components/order-view/products-info/collapsed-content/index.tsx +29 -0
- package/src/components/order-view/return-client-products/product-table/ReturnProductTable.tsx +166 -43
- package/src/components/order-view/store.ts +20 -0
- package/src/components/order-view/types.ts +39 -0
- package/src/components/order-view/utils.ts +29 -0
- package/src/components/store.ts +4 -1
package/package.json
CHANGED
package/src/components/order-daily-overview/return-order-table/return-orders-filters/returnstyles.ts
CHANGED
|
@@ -481,6 +481,35 @@ export const StyledTable = styled.table`
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
tbody {
|
|
484
|
+
tr.product-row td {
|
|
485
|
+
border-bottom: none;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
tr.ni-row td {
|
|
489
|
+
border-top: none;
|
|
490
|
+
padding-top: 0;
|
|
491
|
+
background: #fff;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
tr.product-row td:first-child {
|
|
495
|
+
border-bottom-left-radius: 0;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
tr.product-row td:last-child {
|
|
499
|
+
border-bottom-right-radius: 0;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
tr.ni-row td:first-child {
|
|
503
|
+
border-top-left-radius: 0;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
tr.ni-row td:last-child {
|
|
507
|
+
border-top-right-radius: 0;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
tr.ni-row:nth-child(even) td {
|
|
511
|
+
background: #fff;
|
|
512
|
+
}
|
|
484
513
|
tr {
|
|
485
514
|
td {
|
|
486
515
|
padding: 14px 20px;
|
|
@@ -504,6 +533,7 @@ export const StyledTable = styled.table`
|
|
|
504
533
|
}
|
|
505
534
|
}
|
|
506
535
|
}
|
|
536
|
+
|
|
507
537
|
.actions {
|
|
508
538
|
display: flex;
|
|
509
539
|
align-items: center;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import OrderDetails from './order-details';
|
|
4
4
|
import Notes from './notes';
|
|
@@ -35,13 +35,14 @@ import {
|
|
|
35
35
|
} from './store';
|
|
36
36
|
import { OrdersType } from './types';
|
|
37
37
|
import { useLocation } from 'react-router-dom';
|
|
38
|
-
import { notification } from 'antd';
|
|
38
|
+
import { message, notification } from 'antd';
|
|
39
39
|
import DetailsFilters from './details-filters/DetailsFilters';
|
|
40
|
-
import { useSubContracterData } from '../store';
|
|
40
|
+
import { useIsShowNorthSouth, useSubContracterData } from '../store';
|
|
41
41
|
import Notification from './notification';
|
|
42
42
|
import Order from './order-resources/expanded-content';
|
|
43
43
|
import { setResourcesCall, useAllOrderStatus } from './order-actions/store';
|
|
44
44
|
import { ClientType } from '../order-daily-overview/common/interface';
|
|
45
|
+
import { getEnvironment } from './utils';
|
|
45
46
|
|
|
46
47
|
interface ApiResponse {
|
|
47
48
|
message: string;
|
|
@@ -79,6 +80,7 @@ function OrderView({ locationloading }: any) {
|
|
|
79
80
|
const [getResources] = useAtom(setResourcesCall);
|
|
80
81
|
const [, setClientData] = usegetClientData();
|
|
81
82
|
const [, setGlobalEscData] = useGlobalEscData();
|
|
83
|
+
const [, setIsNorthSouth] = useIsShowNorthSouth();
|
|
82
84
|
|
|
83
85
|
useEffect(() => {
|
|
84
86
|
setStatusVal(orderDetails?.status_value);
|
|
@@ -455,7 +457,69 @@ function OrderView({ locationloading }: any) {
|
|
|
455
457
|
}, [escalationDataLoading]);
|
|
456
458
|
|
|
457
459
|
const docTitle = `${customerInfo?.recipient_name}, ${customerInfo?.postcode}`;
|
|
460
|
+
const environment = getEnvironment();
|
|
461
|
+
const { fetchData: callCheckPostcode } = useAxios<{
|
|
462
|
+
data: ApiResponse[];
|
|
463
|
+
}>({
|
|
464
|
+
endpoint: `v1/orders/customs/postcode/check/`,
|
|
465
|
+
method: 'GET',
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
//northern southern
|
|
469
|
+
const callCheckPostcodeAPI = async () => {
|
|
470
|
+
try {
|
|
471
|
+
const response = await callCheckPostcode({
|
|
472
|
+
endPointQuery: `?postcode=${orderDetails?.order_recipient?.postcode}`,
|
|
473
|
+
});
|
|
474
|
+
//@ts-ignore
|
|
475
|
+
if (response?.code === 200) {
|
|
476
|
+
//@ts-ignore
|
|
477
|
+
const isNorthSouth = response?.data?.order_customs_postcodes;
|
|
478
|
+
setIsNorthSouth(isNorthSouth);
|
|
479
|
+
} else {
|
|
480
|
+
message.open({
|
|
481
|
+
type: 'error',
|
|
482
|
+
//@ts-ignore
|
|
483
|
+
content: response?.error || 'Something went wrong',
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
} catch (err) {
|
|
487
|
+
message.open({
|
|
488
|
+
type: 'error',
|
|
489
|
+
content: 'Failed to check postcode. Please try again.',
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
const POSTCODE_REGEX = {
|
|
494
|
+
UK: /\b(?:[A-Za-z][A-HJ-Ya-hj-y]?[0-9][0-9A-Za-z]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})\b/,
|
|
495
|
+
IRISH: /^(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}$/,
|
|
496
|
+
US: /^\d{5}(-\d{4})?$/,
|
|
497
|
+
};
|
|
498
|
+
const isDevelopmentOrStagingOrReleaseUK =
|
|
499
|
+
environment === 'development' ||
|
|
500
|
+
environment === 'staging' ||
|
|
501
|
+
environment === 'release_uk';
|
|
502
|
+
const isValidPostcode = (val: any) => {
|
|
503
|
+
if (isDevelopmentOrStagingOrReleaseUK) {
|
|
504
|
+
return POSTCODE_REGEX.UK.test(val) || POSTCODE_REGEX.IRISH.test(val);
|
|
505
|
+
} else {
|
|
506
|
+
return POSTCODE_REGEX.US.test(val);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
const hasCalledInitialAPI = useRef(false);
|
|
458
510
|
|
|
511
|
+
useEffect(() => {
|
|
512
|
+
const currentPostcode = orderDetails?.order_recipient?.postcode?.trim();
|
|
513
|
+
|
|
514
|
+
if (
|
|
515
|
+
currentPostcode &&
|
|
516
|
+
isValidPostcode(currentPostcode) &&
|
|
517
|
+
!hasCalledInitialAPI.current
|
|
518
|
+
) {
|
|
519
|
+
hasCalledInitialAPI.current = true;
|
|
520
|
+
callCheckPostcodeAPI();
|
|
521
|
+
}
|
|
522
|
+
}, [orderDetails?.order_recipient?.postcode]);
|
|
459
523
|
return (
|
|
460
524
|
<MainContainer>
|
|
461
525
|
<DocumentTitle title={docTitle} />
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Label } from '@bjsdistribution/dms-component-library';
|
|
4
|
+
|
|
5
|
+
type CustomInputProps = {
|
|
6
|
+
label: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
value?: string | number;
|
|
11
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
13
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
14
|
+
minLength?: number;
|
|
15
|
+
maxLength?: number;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
direction?: 'row' | 'column';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const CustomInput: React.FC<CustomInputProps> = ({
|
|
21
|
+
label,
|
|
22
|
+
name,
|
|
23
|
+
type = 'text',
|
|
24
|
+
placeholder,
|
|
25
|
+
value,
|
|
26
|
+
onChange,
|
|
27
|
+
onBlur,
|
|
28
|
+
onKeyDown,
|
|
29
|
+
minLength,
|
|
30
|
+
direction = 'column',
|
|
31
|
+
maxLength,
|
|
32
|
+
disabled,
|
|
33
|
+
}) => {
|
|
34
|
+
return (
|
|
35
|
+
<Container direction={direction}>
|
|
36
|
+
{label && <Label label={label} htmlFor={name} />}
|
|
37
|
+
<StyledInput
|
|
38
|
+
id={name}
|
|
39
|
+
name={name}
|
|
40
|
+
type={type}
|
|
41
|
+
placeholder={placeholder}
|
|
42
|
+
value={value}
|
|
43
|
+
onChange={onChange}
|
|
44
|
+
onBlur={onBlur}
|
|
45
|
+
onKeyDown={onKeyDown}
|
|
46
|
+
minLength={minLength}
|
|
47
|
+
maxLength={maxLength}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
/>
|
|
50
|
+
</Container>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default CustomInput;
|
|
55
|
+
|
|
56
|
+
// ---------------- styled ----------------
|
|
57
|
+
|
|
58
|
+
const StyledInput = styled.input`
|
|
59
|
+
padding: 12px 12px;
|
|
60
|
+
border: 1px solid #ccc;
|
|
61
|
+
border-radius: 8px;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
outline: none;
|
|
64
|
+
width: 100%;
|
|
65
|
+
|
|
66
|
+
&::-webkit-outer-spin-button,
|
|
67
|
+
&::-webkit-inner-spin-button {
|
|
68
|
+
-webkit-appearance: none;
|
|
69
|
+
margin: 0;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const Container = styled.div<{ direction: 'row' | 'column' }>`
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: ${({ direction }: any) => direction};
|
|
76
|
+
align-items: ${({ direction }: any) =>
|
|
77
|
+
direction === 'row' ? 'center' : 'flex-start'};
|
|
78
|
+
gap: 6px;
|
|
79
|
+
flex: 1;
|
|
80
|
+
`;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { FormSection } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { useOrderDetails } from '../store';
|
|
6
|
+
import Header from '../order-details/common/Header';
|
|
7
|
+
import CustomInput from './CustomInput';
|
|
8
|
+
|
|
9
|
+
const NorthernSouthernInfoView = () => {
|
|
10
|
+
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
11
|
+
const handleChange = (key: any, value: string) => {
|
|
12
|
+
setOrderDetails((prev: any) => ({
|
|
13
|
+
...prev,
|
|
14
|
+
order_customs_details: {
|
|
15
|
+
...prev.order_customs_details,
|
|
16
|
+
[key]: value,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<CustomFormSection>
|
|
23
|
+
<Header label="Northern/Southern Ireland" />
|
|
24
|
+
<FormInputs>
|
|
25
|
+
<GroupedInputs>
|
|
26
|
+
<CustomInput
|
|
27
|
+
label="Consignee Country"
|
|
28
|
+
type="text"
|
|
29
|
+
placeholder="Enter Consignee Country"
|
|
30
|
+
value={orderDetails?.order_customs_details?.consignee_country}
|
|
31
|
+
onChange={(e: any) =>
|
|
32
|
+
handleChange('consignee_country', e.target.value)
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
</GroupedInputs>
|
|
36
|
+
<GroupedInputs>
|
|
37
|
+
<CustomInput
|
|
38
|
+
label="Procedure Code"
|
|
39
|
+
type="text"
|
|
40
|
+
placeholder="Enter Procedure Code"
|
|
41
|
+
value={orderDetails?.order_customs_details?.procedure_code}
|
|
42
|
+
onChange={(e: any) =>
|
|
43
|
+
handleChange('procedure_code', e.target.value)
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
46
|
+
</GroupedInputs>
|
|
47
|
+
<GroupedInputs>
|
|
48
|
+
<CustomInput
|
|
49
|
+
label="Additional Procedure Code"
|
|
50
|
+
type="text"
|
|
51
|
+
placeholder="Enter Add. Procedure Code"
|
|
52
|
+
value={
|
|
53
|
+
orderDetails?.order_customs_details?.additional_procedure_code
|
|
54
|
+
}
|
|
55
|
+
onChange={(e: any) =>
|
|
56
|
+
handleChange('additional_procedure_code', e.target.value)
|
|
57
|
+
}
|
|
58
|
+
/>
|
|
59
|
+
</GroupedInputs>
|
|
60
|
+
<CustomInput
|
|
61
|
+
label="Additional Procedures"
|
|
62
|
+
name="additional-procedures"
|
|
63
|
+
type="text"
|
|
64
|
+
placeholder="Enter Additional Procedures"
|
|
65
|
+
value={orderDetails?.order_customs_details?.additional_procedures}
|
|
66
|
+
onChange={(e: any) =>
|
|
67
|
+
handleChange('additional_procedures', e.target.value)
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
</FormInputs>
|
|
71
|
+
</CustomFormSection>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
const FormInputs = styled.div`
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
gap: 25px;
|
|
78
|
+
flex: 1;
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
const CustomFormSection = styled(FormSection)`
|
|
82
|
+
flex: 1;
|
|
83
|
+
border-radius: 8px;
|
|
84
|
+
background: #f8fafc;
|
|
85
|
+
box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1);
|
|
86
|
+
padding: 15px;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const GroupedInputs = styled.div`
|
|
90
|
+
display: flex;
|
|
91
|
+
gap: 15px;
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
`;
|
|
94
|
+
export default NorthernSouthernInfoView;
|
|
@@ -1,52 +1,209 @@
|
|
|
1
|
-
import { Input, Label } from '@bjsdistribution/dms-component-library';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
1
|
+
import { Input, Label, useAxios } from '@bjsdistribution/dms-component-library';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
4
|
import CopyText from '../../../../../../common/copy/CopyText';
|
|
5
|
-
import { useOrderDetails } from '../../../../store';
|
|
6
|
-
|
|
5
|
+
import { errorAtom, useOrderDetails } from '../../../../store';
|
|
6
|
+
import {
|
|
7
|
+
useAtom,
|
|
8
|
+
useClientPortal,
|
|
9
|
+
useIsShowNorthSouth,
|
|
10
|
+
} from '../../../../../store';
|
|
11
|
+
import { ApiResponse } from '../../../../types';
|
|
12
|
+
import { message } from 'antd';
|
|
13
|
+
|
|
14
|
+
const POSTCODE_REGEX = {
|
|
15
|
+
UK: /\b(?:[A-Za-z][A-HJ-Ya-hj-y]?[0-9][0-9A-Za-z]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})\b/,
|
|
16
|
+
IRISH: /^(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}$/,
|
|
17
|
+
US: /^\d{5}(-\d{4})?$/,
|
|
18
|
+
};
|
|
7
19
|
|
|
8
20
|
function Postcode() {
|
|
9
|
-
|
|
21
|
+
const getEnvironment = ():
|
|
22
|
+
| 'development'
|
|
23
|
+
| 'release_us'
|
|
24
|
+
| 'release_uk'
|
|
25
|
+
| 'staging' => {
|
|
26
|
+
const projectEnv = process.env.REACT_APP_PROJECT_ENV;
|
|
27
|
+
const apiPath = process.env.REACT_APP_API_PATH;
|
|
28
|
+
|
|
29
|
+
if (apiPath === 'https://us.dms.api.bjshomedelivery.com') {
|
|
30
|
+
return 'release_us';
|
|
31
|
+
}
|
|
32
|
+
if (apiPath === 'https://development.dms.api.bjshomedelivery.com') {
|
|
33
|
+
return 'development';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (projectEnv === 'release_uk') {
|
|
37
|
+
return 'release_uk';
|
|
38
|
+
}
|
|
39
|
+
if (projectEnv === 'release_us') {
|
|
40
|
+
return 'release_us';
|
|
41
|
+
}
|
|
42
|
+
if (projectEnv === 'staging') {
|
|
43
|
+
return 'staging';
|
|
44
|
+
}
|
|
45
|
+
return 'development';
|
|
46
|
+
};
|
|
47
|
+
|
|
10
48
|
const [orderDetails, setOrderDetails] = useOrderDetails();
|
|
49
|
+
const [isClientPortal] = useClientPortal();
|
|
50
|
+
const environment = getEnvironment();
|
|
51
|
+
const [errors, setErrors] = useAtom(errorAtom);
|
|
11
52
|
const orderRecipient = orderDetails?.order_recipient;
|
|
53
|
+
const isInvalidOrder = orderDetails?.invalid_order;
|
|
54
|
+
const [, setIsNorthSouth] = useIsShowNorthSouth();
|
|
55
|
+
const prevPostcodeRef = useRef<string | undefined>(undefined);
|
|
56
|
+
|
|
12
57
|
const showCopyIcon =
|
|
13
58
|
orderRecipient?.postcode !== undefined &&
|
|
14
59
|
orderRecipient?.postcode !== null &&
|
|
15
60
|
orderRecipient?.postcode?.length > 0;
|
|
16
61
|
|
|
62
|
+
const isDevelopmentOrStagingOrReleaseUK =
|
|
63
|
+
environment === 'development' ||
|
|
64
|
+
environment === 'staging' ||
|
|
65
|
+
environment === 'release_uk';
|
|
66
|
+
|
|
67
|
+
const isValidPostcode = (val: any) => {
|
|
68
|
+
if (isDevelopmentOrStagingOrReleaseUK) {
|
|
69
|
+
return POSTCODE_REGEX.UK.test(val) || POSTCODE_REGEX.IRISH.test(val);
|
|
70
|
+
} else {
|
|
71
|
+
return POSTCODE_REGEX.US.test(val);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const showErr = () => {
|
|
76
|
+
setErrors(prevErrors => ({
|
|
77
|
+
...prevErrors,
|
|
78
|
+
postCodeError: 'Invalid postcode format',
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const clearErr = () => {
|
|
83
|
+
setErrors(prevErrors => ({
|
|
84
|
+
...prevErrors,
|
|
85
|
+
postCodeError: '',
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const validatePostcode = (val: any) => {
|
|
90
|
+
if (isValidPostcode(val)) {
|
|
91
|
+
clearErr();
|
|
92
|
+
} else {
|
|
93
|
+
showErr();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
17
97
|
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
18
98
|
const val = e.target.value;
|
|
99
|
+
|
|
19
100
|
const updatedOrderRecipient = {
|
|
20
101
|
...(orderRecipient === null
|
|
21
102
|
? { postcode: val }
|
|
22
103
|
: { ...orderRecipient, postcode: val }),
|
|
23
104
|
};
|
|
105
|
+
|
|
24
106
|
setOrderDetails(prev => {
|
|
25
107
|
return {
|
|
26
108
|
...prev,
|
|
27
109
|
order_recipient: updatedOrderRecipient,
|
|
28
110
|
};
|
|
29
111
|
});
|
|
112
|
+
|
|
113
|
+
validatePostcode(val);
|
|
30
114
|
};
|
|
115
|
+
|
|
116
|
+
const hasError = !!isInvalidOrder;
|
|
117
|
+
|
|
118
|
+
const { fetchData: callCheckPostcode } = useAxios<{
|
|
119
|
+
data: ApiResponse[];
|
|
120
|
+
}>({
|
|
121
|
+
endpoint: `v1/orders/customs/postcode/check/`,
|
|
122
|
+
method: 'GET',
|
|
123
|
+
});
|
|
124
|
+
const callCheckPostcodeAPI = async () => {
|
|
125
|
+
try {
|
|
126
|
+
const response = await callCheckPostcode({
|
|
127
|
+
endPointQuery: `?postcode=${orderRecipient?.postcode}`,
|
|
128
|
+
});
|
|
129
|
+
//@ts-ignore
|
|
130
|
+
if (response?.code === 200) {
|
|
131
|
+
//@ts-ignore
|
|
132
|
+
const isNorthSouth = response?.data?.order_customs_postcodes;
|
|
133
|
+
setIsNorthSouth(isNorthSouth);
|
|
134
|
+
|
|
135
|
+
message.open({
|
|
136
|
+
type: 'success',
|
|
137
|
+
//@ts-ignore
|
|
138
|
+
content: isNorthSouth
|
|
139
|
+
? //@ts-ignore
|
|
140
|
+
`${response?.message} - Northern/Southern Ireland postcode found`
|
|
141
|
+
: //@ts-ignore
|
|
142
|
+
response?.message || 'Success',
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
message.open({
|
|
146
|
+
type: 'error',
|
|
147
|
+
//@ts-ignore
|
|
148
|
+
content: response?.error || 'Something went wrong',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
message.open({
|
|
153
|
+
type: 'error',
|
|
154
|
+
content: 'Failed to check postcode. Please try again.',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
31
159
|
return (
|
|
32
160
|
<Container>
|
|
33
161
|
<Wrapper>
|
|
34
162
|
<Label label="Postcode" htmlFor="postcode" />
|
|
35
163
|
{showCopyIcon && <CopyText text={orderRecipient?.postcode!} />}
|
|
36
164
|
</Wrapper>
|
|
37
|
-
<
|
|
165
|
+
<InputContainer
|
|
38
166
|
name="postcode"
|
|
39
167
|
type="text"
|
|
40
168
|
placeholder="Enter Postcode"
|
|
41
169
|
value={orderRecipient?.postcode || ''}
|
|
42
170
|
onChange={onChange}
|
|
43
171
|
autoComplete="off"
|
|
44
|
-
style={{
|
|
172
|
+
style={{ width: '100%' }}
|
|
173
|
+
disabled={isClientPortal}
|
|
174
|
+
hasError={hasError}
|
|
175
|
+
onBlur={async () => {
|
|
176
|
+
const currentPostcode = orderRecipient?.postcode?.trim();
|
|
177
|
+
if (
|
|
178
|
+
currentPostcode &&
|
|
179
|
+
isValidPostcode(currentPostcode) &&
|
|
180
|
+
currentPostcode !== prevPostcodeRef.current
|
|
181
|
+
) {
|
|
182
|
+
await callCheckPostcodeAPI();
|
|
183
|
+
}
|
|
184
|
+
prevPostcodeRef.current = currentPostcode;
|
|
185
|
+
}}
|
|
45
186
|
/>
|
|
187
|
+
{errors.postCodeError && <ErrorText>{errors.postCodeError}</ErrorText>}
|
|
46
188
|
</Container>
|
|
47
189
|
);
|
|
48
190
|
}
|
|
49
191
|
|
|
192
|
+
const InputContainer = styled(Input)<{ hasError?: boolean }>`
|
|
193
|
+
${({ hasError }) =>
|
|
194
|
+
hasError &&
|
|
195
|
+
css`
|
|
196
|
+
border: 1px solid rgb(253, 154, 154);
|
|
197
|
+
background-color: #fff5f5;
|
|
198
|
+
`}
|
|
199
|
+
`;
|
|
200
|
+
|
|
201
|
+
const ErrorText = styled.span`
|
|
202
|
+
color: red;
|
|
203
|
+
font-size: 0.85rem;
|
|
204
|
+
margin-top: 4px;
|
|
205
|
+
`;
|
|
206
|
+
|
|
50
207
|
const Wrapper = styled.div`
|
|
51
208
|
display: flex;
|
|
52
209
|
align-items: center;
|
|
@@ -59,5 +216,10 @@ const Container = styled.div`
|
|
|
59
216
|
gap: 6px;
|
|
60
217
|
flex: 1;
|
|
61
218
|
`;
|
|
219
|
+
// const ErrorText = styled.span`
|
|
220
|
+
// color: red;
|
|
221
|
+
// font-size: 0.85rem;
|
|
222
|
+
// margin-top: 4px;
|
|
223
|
+
// `;
|
|
62
224
|
|
|
63
225
|
export default Postcode;
|
|
@@ -89,8 +89,57 @@ function OrderDetailsFooter() {
|
|
|
89
89
|
const isSame = orderDetailsSorted === prevOrderDetailsSorted;
|
|
90
90
|
return !isSame;
|
|
91
91
|
};
|
|
92
|
-
|
|
92
|
+
//Northern/Southern Ireland PATCH API
|
|
93
|
+
const { fetchData: callCustomDetailsAPI } = useAxios<{
|
|
94
|
+
data: ApiResponse[];
|
|
95
|
+
}>({
|
|
96
|
+
endpoint: `v1/orders/update/customs_details?order_id=${orderDetails?.id}`,
|
|
97
|
+
method: 'PATCH',
|
|
98
|
+
});
|
|
93
99
|
const onSave = async () => {
|
|
100
|
+
if (orderDetails?.id) {
|
|
101
|
+
console.log('yooooooo11111');
|
|
102
|
+
|
|
103
|
+
const {
|
|
104
|
+
consignor_eori,
|
|
105
|
+
packaging_type,
|
|
106
|
+
consignee_country,
|
|
107
|
+
commodity_code,
|
|
108
|
+
country_of_origin,
|
|
109
|
+
item_invoice_amount,
|
|
110
|
+
procedure_code,
|
|
111
|
+
ni_additional_information_codes,
|
|
112
|
+
additional_procedure_code,
|
|
113
|
+
additional_procedures,
|
|
114
|
+
} = orderDetails?.order_customs_details ?? {};
|
|
115
|
+
|
|
116
|
+
let customDetailsPayload: Record<string, any> = {
|
|
117
|
+
order_id: orderDetails?.id,
|
|
118
|
+
consignor_eori,
|
|
119
|
+
packaging_type,
|
|
120
|
+
consignee_country,
|
|
121
|
+
commodity_code,
|
|
122
|
+
country_of_origin,
|
|
123
|
+
item_invoice_amount,
|
|
124
|
+
procedure_code,
|
|
125
|
+
ni_additional_information_codes,
|
|
126
|
+
additional_procedure_code,
|
|
127
|
+
additional_procedures,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// remove null/undefined values
|
|
131
|
+
customDetailsPayload = Object.fromEntries(
|
|
132
|
+
Object.entries(customDetailsPayload).filter(
|
|
133
|
+
([_, value]) => value !== null && value !== undefined
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// northern/southern details API
|
|
138
|
+
callCustomDetailsAPI({
|
|
139
|
+
payload: customDetailsPayload,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
console.log('yoooooooooo');
|
|
94
143
|
setRecallAuditLog(false);
|
|
95
144
|
setRecallOrders(false);
|
|
96
145
|
setRecalling(false);
|
|
@@ -127,14 +176,16 @@ function OrderDetailsFooter() {
|
|
|
127
176
|
payload.assembly_type = null;
|
|
128
177
|
}
|
|
129
178
|
|
|
179
|
+
console.log('final payload for update--->', [payload]);
|
|
130
180
|
let response = (await callUpdateOrderAPI({
|
|
131
|
-
payload: [payload],
|
|
181
|
+
payload: [{ ...payload, id: orderDetails?.id }],
|
|
132
182
|
})) as {
|
|
133
183
|
code: number | null;
|
|
134
184
|
error?: string | null | undefined;
|
|
135
185
|
[key: string]: any;
|
|
136
186
|
};
|
|
137
187
|
// const response = await updateOrder([payload]);
|
|
188
|
+
|
|
138
189
|
setRecallOrders(true);
|
|
139
190
|
if (response.code == 200 && response?.data?.length > 0) {
|
|
140
191
|
notification.success({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import CustomerSection from './customer-section';
|
|
4
4
|
import OrdersSection from './orders-section';
|
|
@@ -7,8 +7,17 @@ import ServicesSection from './services-section';
|
|
|
7
7
|
import OrderDetailsFooter from './footer';
|
|
8
8
|
import { Skeleton } from 'antd';
|
|
9
9
|
import { FormSection } from '@bjsdistribution/dms-component-library';
|
|
10
|
+
import { useIsShowNorthSouth } from '../../../store';
|
|
11
|
+
import { useOrderDetails } from '../../store';
|
|
12
|
+
import NorthernSouthernInfoView from '../../northern-southern-info';
|
|
10
13
|
|
|
11
14
|
function ExpandedContent({ orderLoading, depotDataLoading }: any) {
|
|
15
|
+
const [isNorthSouth] = useIsShowNorthSouth();
|
|
16
|
+
const [orderDetails] = useOrderDetails();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
console.log('north sourthsalhdjas', isNorthSouth);
|
|
20
|
+
}, [isNorthSouth]);
|
|
12
21
|
return (
|
|
13
22
|
<>
|
|
14
23
|
<MainContainer>
|
|
@@ -29,6 +38,9 @@ function ExpandedContent({ orderLoading, depotDataLoading }: any) {
|
|
|
29
38
|
<OrdersSection />
|
|
30
39
|
</HalfWidth>
|
|
31
40
|
<InstructionSection />
|
|
41
|
+
{(isNorthSouth === true ||
|
|
42
|
+
(orderDetails?.show_customs_details &&
|
|
43
|
+
isNorthSouth !== false)) && <NorthernSouthernInfoView />}
|
|
32
44
|
</Container>
|
|
33
45
|
|
|
34
46
|
<ServicesSection />
|