@truworth/twc-auth 1.2.7 → 1.2.8
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/build/src/components/VerifyMobileOTP/index.native.js +6 -1
- package/build/src/contexts/AuthContext.js +0 -1
- package/build/src/screens/EnterPassword/hooks/internal/useEnterPassword.js +5 -1
- package/build/src/screens/EnterPassword/index.native.js +5 -2
- package/build/types/screens/EnterPassword/hooks/internal/useEnterPassword.d.ts +1 -0
- package/package.json +1 -1
|
@@ -10,6 +10,11 @@ const { gray } = Colors;
|
|
|
10
10
|
const VerifyMobileOTP = ({ validateOTP, timer, status, resendOTP, phone }) => {
|
|
11
11
|
const [otp, setOtp] = useState('');
|
|
12
12
|
const { otpValue } = useAuthPackageContext();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (otp && otp.length == 6) {
|
|
15
|
+
return validateOTP(otp);
|
|
16
|
+
}
|
|
17
|
+
}, [otp]);
|
|
13
18
|
useEffect(() => {
|
|
14
19
|
if (otpValue && otpValue.length == 6) {
|
|
15
20
|
setOtp(otpValue);
|
|
@@ -24,7 +29,7 @@ const VerifyMobileOTP = ({ validateOTP, timer, status, resendOTP, phone }) => {
|
|
|
24
29
|
}, codeInputHighlightStyle: { borderColor: '#03DAC6' }, style: {
|
|
25
30
|
height: 50,
|
|
26
31
|
width: Dimensions.get('window').width - 100,
|
|
27
|
-
}, code: otp ?? '', onCodeFilled: code =>
|
|
32
|
+
}, code: otp ?? '', onCodeFilled: code => setOtp(code) }) }), timer <= 0 &&
|
|
28
33
|
_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center' }, children: [_jsx(Text, { style: { fontSize: 12, color: '#000', fontWeight: '400', opacity: 0.5 }, children: "Did not receive OTP?" }), _jsx(TouchableOpacity, { disabled: timer > 0, onPress: () => {
|
|
29
34
|
setOtp('');
|
|
30
35
|
resendOTP();
|
|
@@ -9,12 +9,14 @@ import { showMessage } from "../../../../helpers/show-message";
|
|
|
9
9
|
const useEnterPassword = () => {
|
|
10
10
|
const [password, setPassword] = useState("");
|
|
11
11
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
12
|
+
const [invalidPassword, setInvalidPassword] = useState(false);
|
|
12
13
|
const [loading, setLoading] = useState(false);
|
|
13
14
|
const { onTokenChange, onLogin, appConfig } = useAuthPackageContext();
|
|
14
15
|
const togglePasswordVisibility = useCallback(() => {
|
|
15
16
|
setIsPasswordVisible((prev) => !prev);
|
|
16
17
|
}, []);
|
|
17
18
|
const handlePasswordChange = useCallback((value) => {
|
|
19
|
+
setInvalidPassword(false);
|
|
18
20
|
setPassword(value);
|
|
19
21
|
}, []);
|
|
20
22
|
const handleSubmit = useCallback(async ({ email, source, verifyEmailOTP }) => {
|
|
@@ -46,6 +48,7 @@ const useEnterPassword = () => {
|
|
|
46
48
|
catch (error) {
|
|
47
49
|
const errorMessage = error?.response?.data?.errors?.[0]?.message;
|
|
48
50
|
if (error?.response?.status === 400) {
|
|
51
|
+
setInvalidPassword(true);
|
|
49
52
|
showMessage({ message: errorMessage ?? 'Email and password do not match!' });
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
@@ -67,7 +70,8 @@ const useEnterPassword = () => {
|
|
|
67
70
|
handleSubmit,
|
|
68
71
|
isDisabled,
|
|
69
72
|
handlePasswordChange,
|
|
70
|
-
appName: appConfig.appName
|
|
73
|
+
appName: appConfig.appName,
|
|
74
|
+
invalidPassword
|
|
71
75
|
};
|
|
72
76
|
};
|
|
73
77
|
export { useEnterPassword };
|
|
@@ -7,7 +7,7 @@ import { useEnterPassword } from './hooks/internal/useEnterPassword';
|
|
|
7
7
|
const { primary } = Colors;
|
|
8
8
|
const EnterPassword = ({ navigation, route }) => {
|
|
9
9
|
const { email } = route.params;
|
|
10
|
-
const { loading, password, isPasswordVisible, togglePasswordVisibility, handlePasswordChange, isDisabled, handleSubmit } = useEnterPassword();
|
|
10
|
+
const { loading, password, isPasswordVisible, togglePasswordVisibility, handlePasswordChange, isDisabled, handleSubmit, invalidPassword } = useEnterPassword();
|
|
11
11
|
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: primary.white }, children: [_jsxs(ScreenLayout, { title: "Enter Your Password", buttonProps: {
|
|
12
12
|
loading,
|
|
13
13
|
label: 'Continue',
|
|
@@ -22,7 +22,10 @@ const EnterPassword = ({ navigation, route }) => {
|
|
|
22
22
|
});
|
|
23
23
|
},
|
|
24
24
|
disabled: isDisabled,
|
|
25
|
-
}, children: [_jsx(View, { style: { position: 'relative' }, children: _jsx(TextInputField, { placeholder: 'Enter password...', onChangeValue: handlePasswordChange, secureTextEntry: !isPasswordVisible, value: password, rightIcon2: isPasswordVisible ? 'eye-outline' : 'eye-off-outline', onPressRightIcon2: () => togglePasswordVisibility(),
|
|
25
|
+
}, children: [_jsx(View, { style: { position: 'relative' }, children: _jsx(TextInputField, { placeholder: 'Enter password...', onChangeValue: handlePasswordChange, secureTextEntry: !isPasswordVisible, value: password, rightIcon2: isPasswordVisible ? 'eye-outline' : 'eye-off-outline', onPressRightIcon2: () => togglePasswordVisibility(), error: {
|
|
26
|
+
show: invalidPassword,
|
|
27
|
+
message: 'Email and password do not match!'
|
|
28
|
+
}, autoFocus: true }) }), _jsx(TouchableOpacity, { activeOpacity: 0.8, style: { marginTop: 10, alignSelf: 'flex-end' }, onPress: () => navigation.navigate('VerifyResetPasswordOTP', { email }), children: _jsx(Text, { style: {
|
|
26
29
|
fontSize: 12, fontWeight: '600',
|
|
27
30
|
color: primary.primary_main, lineHeight: 20,
|
|
28
31
|
}, children: "Forgot Password?" }) })] }), _jsxs(View, { style: { paddingHorizontal: 16 }, children: [_jsxs(View, { style: {
|