@akinon/pz-masterpass 1.19.2 → 1.19.3
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useLocalization } from '@akinon/next/hooks';
|
|
4
4
|
import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
|
|
5
5
|
import Script from 'next/script';
|
|
6
|
-
import { useEffect } from 'react';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
7
|
import { checkMasterpass } from './utils/check-masterpass';
|
|
8
8
|
import { init } from './utils/init';
|
|
9
9
|
import {
|
|
@@ -46,6 +46,11 @@ export const MasterpassProvider = (props: MasterpassProviderProps) => {
|
|
|
46
46
|
const { locale } = useLocalization();
|
|
47
47
|
const dispatch = useAppDispatch();
|
|
48
48
|
|
|
49
|
+
const [scriptLoadState, setScriptLoadState] = useState({
|
|
50
|
+
zepto: false,
|
|
51
|
+
mfs: false
|
|
52
|
+
});
|
|
53
|
+
|
|
49
54
|
const prepareState = async () => {
|
|
50
55
|
dispatch(setLanguage(getLanguage(locale)));
|
|
51
56
|
|
|
@@ -86,12 +91,16 @@ export const MasterpassProvider = (props: MasterpassProviderProps) => {
|
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
useEffect(() => {
|
|
89
|
-
if (
|
|
94
|
+
if (
|
|
95
|
+
preOrder?.payment_option?.payment_type !== 'masterpass' ||
|
|
96
|
+
!scriptLoadState.zepto ||
|
|
97
|
+
!scriptLoadState.mfs
|
|
98
|
+
) {
|
|
90
99
|
return;
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
prepareState();
|
|
94
|
-
}, [preOrder?.payment_option?.payment_type]);
|
|
103
|
+
}, [scriptLoadState, preOrder?.payment_option?.payment_type]);
|
|
95
104
|
|
|
96
105
|
useEffect(() => {
|
|
97
106
|
if (!otp.response) {
|
|
@@ -116,8 +125,26 @@ export const MasterpassProvider = (props: MasterpassProviderProps) => {
|
|
|
116
125
|
|
|
117
126
|
return (
|
|
118
127
|
<>
|
|
119
|
-
<Script
|
|
120
|
-
|
|
128
|
+
<Script
|
|
129
|
+
src="/mfs-client.min.js"
|
|
130
|
+
strategy="afterInteractive"
|
|
131
|
+
onLoad={() => {
|
|
132
|
+
setScriptLoadState((prevState) => ({
|
|
133
|
+
...prevState,
|
|
134
|
+
mfs: true
|
|
135
|
+
}));
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
<Script
|
|
139
|
+
src="/zepto.min.js"
|
|
140
|
+
strategy="afterInteractive"
|
|
141
|
+
onLoad={() => {
|
|
142
|
+
setScriptLoadState((prevState) => ({
|
|
143
|
+
...prevState,
|
|
144
|
+
zepto: true
|
|
145
|
+
}));
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
121
148
|
|
|
122
149
|
<Modal
|
|
123
150
|
portalId="masterpass-error-modal"
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button, LoaderSpinner } from 'components';
|
|
3
|
-
import { useTranslation } from '@akinon/next/hooks';
|
|
4
3
|
import { useCountdown } from '../../hooks/use-countdown';
|
|
5
4
|
|
|
6
|
-
const SendSms = ({ resendSms, resendSmsFetching }) => {
|
|
7
|
-
const { t } = useTranslation('checkout');
|
|
8
|
-
|
|
5
|
+
const SendSms = ({ resendSms, resendSmsFetching, resendSmsTranslation }) => {
|
|
9
6
|
return (
|
|
10
7
|
<Button
|
|
11
8
|
onClick={() => resendSms()}
|
|
12
9
|
className="mt-2 w-full text-primary bg-[#cccccc] border-0 hover:border"
|
|
13
10
|
>
|
|
14
|
-
{!resendSmsFetching ?
|
|
15
|
-
t('payment.masterpass.add.send_sms_again')
|
|
16
|
-
) : (
|
|
17
|
-
<LoaderSpinner />
|
|
18
|
-
)}
|
|
11
|
+
{!resendSmsFetching ? resendSmsTranslation : <LoaderSpinner />}
|
|
19
12
|
</Button>
|
|
20
13
|
);
|
|
21
14
|
};
|
|
@@ -28,12 +21,21 @@ const ShowCounter = ({ minutes, seconds }) => {
|
|
|
28
21
|
);
|
|
29
22
|
};
|
|
30
23
|
|
|
31
|
-
const CountdownTimer = ({
|
|
24
|
+
const CountdownTimer = ({
|
|
25
|
+
targetDate,
|
|
26
|
+
resendSms,
|
|
27
|
+
resendSmsFetching,
|
|
28
|
+
resendSmsTranslation
|
|
29
|
+
}) => {
|
|
32
30
|
const [minutes, seconds] = useCountdown(targetDate);
|
|
33
31
|
|
|
34
32
|
if (minutes + seconds <= 0) {
|
|
35
33
|
return (
|
|
36
|
-
<SendSms
|
|
34
|
+
<SendSms
|
|
35
|
+
resendSms={resendSms}
|
|
36
|
+
resendSmsFetching={resendSmsFetching}
|
|
37
|
+
resendSmsTranslation={resendSmsTranslation}
|
|
38
|
+
/>
|
|
37
39
|
);
|
|
38
40
|
} else {
|
|
39
41
|
return <ShowCounter minutes={minutes} seconds={seconds} />;
|
|
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
8
8
|
import { formCreator } from '../../utils';
|
|
9
9
|
|
|
10
10
|
import CountdownTimer from '../countdown-timer/countdown-timer';
|
|
11
|
-
import { OtpForm, OtpFormProps } from './otp-form';
|
|
11
|
+
import { OtpForm, OtpFormProps, defaultTranslations } from './otp-form';
|
|
12
12
|
import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
|
|
13
13
|
import { setOtpResponse } from '../../redux/reducer';
|
|
14
14
|
import { Image } from '@akinon/next/components/image';
|
|
@@ -140,6 +140,9 @@ export const MasterpassOtpModal = ({
|
|
|
140
140
|
resendSmsFetching={isBusy}
|
|
141
141
|
targetDate={otpTime}
|
|
142
142
|
resendSms={resendSms}
|
|
143
|
+
resendSmsTranslation={
|
|
144
|
+
translations?.resend_sms ?? defaultTranslations.resend_sms
|
|
145
|
+
}
|
|
143
146
|
/>
|
|
144
147
|
</div>
|
|
145
148
|
</div>
|
|
@@ -4,10 +4,11 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { useForm } from 'react-hook-form';
|
|
5
5
|
import * as yup from 'yup';
|
|
6
6
|
|
|
7
|
-
const defaultTranslations = {
|
|
7
|
+
export const defaultTranslations = {
|
|
8
8
|
enter_the_verification_code: 'Enter the verification code',
|
|
9
9
|
sms_code: 'SMS Code',
|
|
10
|
-
verify: 'Verify'
|
|
10
|
+
verify: 'Verify',
|
|
11
|
+
resend_sms: 'Resend SMS'
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export interface OtpFormProps {
|