@truworth/twc-auth 1.2.2 → 1.2.4
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/assets/loading-spinner.json +1 -0
- package/build/src/api/auth.js +36 -0
- package/build/src/components/PasswordCriteria/hooks/usePasswordCriteria.js +1 -8
- package/build/src/components/PasswordCriteria/index.native.js +3 -3
- package/build/src/components/ScreenLayout/index.native.js +2 -2
- package/build/src/components/{EmailOTPVerify → VerifyEmailOTP}/index.js +2 -2
- package/build/src/components/VerifyEmailOTP/index.native.js +22 -0
- package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.js +2 -2
- package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.native.js +2 -2
- package/build/src/constants/defaultPolicy.js +9 -0
- package/build/src/contexts/AuthContext.js +1 -1
- package/build/src/enums/index.js +2 -0
- package/build/src/enums/loginMethod.enum.js +8 -0
- package/build/src/enums/registrationMethod.enum.js +7 -0
- package/build/src/helpers/Network.js +1 -1
- package/build/src/helpers/show-message/index.js +2 -2
- package/build/src/helpers/show-message/index.native.js +1 -1
- package/build/src/hooks/useRequest.js +1 -1
- package/build/src/index.js +3 -2
- package/build/src/navigator/index.native.js +8 -1
- package/build/src/screens/CreatePassword/hooks/internal/useCreatePassword.js +2 -15
- package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +22 -40
- package/build/src/screens/EnterEmail/index.js +7 -9
- package/build/src/screens/EnterEmail/index.native.js +11 -11
- package/build/src/screens/EnterEmail/types.js +1 -0
- package/build/src/screens/EnterPassword/index.js +25 -9
- package/build/src/screens/EnterPassword/index.native.js +28 -16
- package/build/src/screens/Login/components/LoginWebComponent/index.js +21 -4
- package/build/src/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.js +72 -0
- package/build/src/screens/LoginWithEmailOTP/index.js +8 -0
- package/build/src/screens/LoginWithEmailOTP/index.native.js +10 -0
- package/build/src/screens/ResetPassword/hooks/internal/useResetPassword.js +55 -0
- package/build/src/screens/ResetPassword/index.js +46 -0
- package/build/src/screens/ResetPassword/index.native.js +26 -0
- package/build/src/screens/ResetPassword/types.js +1 -0
- package/build/src/screens/SSOLogin/AuthWebView/index.js +9 -0
- package/build/src/screens/SSOLogin/AuthWebView/index.native.js +27 -0
- package/build/src/screens/SSOLogin/AuthWebView/types.js +1 -0
- package/build/src/screens/SSOLogin/AuthenticationMethods/hooks/internal/useSSOAuthenticationMethods.js +38 -0
- package/build/src/screens/SSOLogin/AuthenticationMethods/index.js +48 -0
- package/build/src/screens/SSOLogin/AuthenticationMethods/index.native.js +58 -0
- package/build/src/screens/SSOLogin/AuthenticationMethods/types.js +1 -0
- package/build/src/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.js +59 -0
- package/build/src/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.native.js +6 -0
- package/build/src/screens/SSOLogin/SSOCallback/hooks/internal/useSSOCallback.js +42 -0
- package/build/src/screens/SSOLogin/SSOCallback/index.js +9 -0
- package/build/src/screens/SSOLogin/SSOCallback/index.native.js +35 -0
- package/build/src/screens/SSOLogin/SSOCallback/types.js +1 -0
- package/build/src/screens/SSOLogin/SearchOrganization/hooks/internal/useSSOSearchOrganization.js +71 -0
- package/build/src/screens/SSOLogin/SearchOrganization/index.js +46 -0
- package/build/src/screens/SSOLogin/SearchOrganization/index.native.js +37 -0
- package/build/src/screens/SSOLogin/SearchOrganization/types.js +1 -0
- package/build/src/screens/SignUp/components/SignUpForm/index.js +92 -66
- package/build/src/screens/SignUp/components/SignUpWebComponent/index.js +22 -53
- package/build/src/screens/SignUp/hooks/internal/useSignUp.js +77 -81
- package/build/src/screens/SignUp/index.native.js +76 -77
- package/build/src/screens/UserConsent/hooks/internal/useConsent.js +11 -4
- package/build/src/screens/UserConsent/index.js +38 -18
- package/build/src/screens/UserConsent/index.native.js +1 -1
- package/build/src/screens/VerifyEmail/hooks/internal/useVerifyEmail.js +3 -3
- package/build/src/screens/VerifyEmail/index.js +2 -2
- package/build/src/screens/VerifyEmail/index.native.js +2 -2
- package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +7 -7
- package/build/src/screens/VerifyMobile/index.js +2 -2
- package/build/src/screens/VerifyMobile/index.native.js +2 -2
- package/build/src/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.js +74 -0
- package/build/src/screens/VerifyResetPasswordOTP/index.js +8 -0
- package/build/src/screens/VerifyResetPasswordOTP/index.native.js +14 -0
- package/build/src/screens/Welcome/index.js +2 -3
- package/build/src/screens/Welcome/index.native.js +1 -1
- package/build/src/types/types.js +2 -1
- package/build/types/api/auth.d.ts +11 -0
- package/build/types/components/PasswordCriteria/hooks/usePasswordCriteria.d.ts +2 -7
- package/build/types/components/ScreenLayout/index.native.d.ts +1 -1
- package/build/types/components/ScreenLayout/types.d.ts +1 -0
- package/build/types/components/VerifyEmailOTP/index.d.ts +3 -0
- package/build/types/components/VerifyEmailOTP/index.native.d.ts +3 -0
- package/build/types/components/{EmailOTPVerify/type.d.ts → VerifyEmailOTP/types.d.ts} +2 -2
- package/build/types/components/VerifyMobileOTP/index.d.ts +3 -0
- package/build/types/components/VerifyMobileOTP/index.native.d.ts +3 -0
- package/build/types/constants/defaultPolicy.d.ts +9 -0
- package/build/types/enums/index.d.ts +2 -0
- package/build/types/enums/loginMethod.enum.d.ts +7 -0
- package/build/types/enums/registrationMethod.enum.d.ts +6 -0
- package/build/types/helpers/show-message/index.d.ts +2 -2
- package/build/types/helpers/show-message/index.native.d.ts +2 -2
- package/build/types/helpers/show-message/types.d.ts +6 -2
- package/build/types/index.d.ts +3 -2
- package/build/types/navigator/index.native.d.ts +24 -1
- package/build/types/screens/EnterEmail/hooks/internal/useEnterEmail.d.ts +3 -4
- package/build/types/screens/EnterEmail/index.d.ts +2 -6
- package/build/types/screens/EnterEmail/types.d.ts +8 -0
- package/build/types/screens/EnterPassword/index.d.ts +1 -1
- package/build/types/screens/EnterPassword/index.native.d.ts +1 -1
- package/build/types/screens/EnterPassword/types.d.ts +17 -1
- package/build/types/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.d.ts +14 -0
- package/build/types/screens/LoginWithEmailOTP/index.d.ts +4 -0
- package/build/types/screens/LoginWithEmailOTP/index.native.d.ts +4 -0
- package/build/types/screens/ResetPassword/hooks/internal/useResetPassword.d.ts +28 -0
- package/build/types/screens/ResetPassword/index.d.ts +3 -0
- package/build/types/screens/ResetPassword/index.native.d.ts +4 -0
- package/build/types/screens/ResetPassword/types.d.ts +11 -0
- package/build/types/screens/SSOLogin/AuthWebView/index.d.ts +2 -0
- package/build/types/screens/SSOLogin/AuthWebView/index.native.d.ts +4 -0
- package/build/types/screens/SSOLogin/AuthWebView/types.d.ts +8 -0
- package/build/types/screens/SSOLogin/AuthenticationMethods/hooks/internal/useSSOAuthenticationMethods.d.ts +9 -0
- package/build/types/screens/SSOLogin/AuthenticationMethods/index.d.ts +3 -0
- package/build/types/screens/SSOLogin/AuthenticationMethods/index.native.d.ts +4 -0
- package/build/types/screens/SSOLogin/AuthenticationMethods/types.d.ts +11 -0
- package/build/types/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.d.ts +2 -0
- package/build/types/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.native.d.ts +2 -0
- package/build/types/screens/SSOLogin/SSOCallback/hooks/internal/useSSOCallback.d.ts +11 -0
- package/build/types/screens/SSOLogin/SSOCallback/index.d.ts +2 -0
- package/build/types/screens/SSOLogin/SSOCallback/index.native.d.ts +4 -0
- package/build/types/screens/SSOLogin/SSOCallback/types.d.ts +11 -0
- package/build/types/screens/SSOLogin/SearchOrganization/hooks/internal/useSSOSearchOrganization.d.ts +18 -0
- package/build/types/screens/SSOLogin/SearchOrganization/index.d.ts +3 -0
- package/build/types/screens/SSOLogin/SearchOrganization/index.native.d.ts +4 -0
- package/build/types/screens/SSOLogin/SearchOrganization/types.d.ts +13 -0
- package/build/types/screens/SignUp/components/SignUpForm/index.d.ts +1 -1
- package/build/types/screens/SignUp/components/SignUpForm/type.d.ts +1 -4
- package/build/types/screens/SignUp/components/SignUpWebComponent/types.d.ts +1 -16
- package/build/types/screens/SignUp/hooks/internal/useSignUp.d.ts +16 -18
- package/build/types/screens/SignUp/types.d.ts +29 -7
- package/build/types/screens/UserConsent/hooks/internal/useConsent.d.ts +1 -1
- package/build/types/screens/UserConsent/index.d.ts +1 -1
- package/build/types/screens/UserConsent/types.d.ts +19 -13
- package/build/types/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.d.ts +19 -0
- package/build/types/screens/VerifyResetPasswordOTP/index.d.ts +7 -0
- package/build/types/screens/VerifyResetPasswordOTP/index.native.d.ts +4 -0
- package/build/types/types/types.d.ts +24 -2
- package/package.json +7 -5
- package/build/src/components/EmailOTPVerify/index.native.js +0 -26
- package/build/types/components/EmailOTPVerify/index.d.ts +0 -3
- package/build/types/components/EmailOTPVerify/index.native.d.ts +0 -3
- package/build/types/components/VerifyOTP/index.d.ts +0 -3
- package/build/types/components/VerifyOTP/index.native.d.ts +0 -3
- /package/build/src/components/{VerifyOTP → VerifyEmailOTP}/types.js +0 -0
- /package/build/src/components/{EmailOTPVerify/type.js → VerifyMobileOTP/types.js} +0 -0
- /package/build/types/components/{VerifyOTP → VerifyMobileOTP}/types.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"v":"5.8.1","fr":30,"ip":0,"op":60,"w":300,"h":300,"nm":"loading_6","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":60,"s":[360]}],"ix":10},"p":{"a":0,"k":[150.00000000000003,150.00000000000003,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[30.000000000000004,30.000000000000004,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[300,300],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.12941176470588237,0.7411764705882353,0.7764705882352941,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":50,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[0]},{"t":60,"s":[99]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[1]},{"t":50,"s":[100]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":60,"s":[3]}],"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":300,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":30,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150.00000000000003,150.00000000000003,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[30.000000000000004,30.000000000000004,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[300,300],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.7450980392156863,0.9254901960784314,0.9372549019607843,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":50,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0}],"markers":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { axiosClient } from "./axiosClient";
|
|
2
|
+
/** Check if mobile exists */
|
|
3
|
+
const checkMobileExists = async (phone) => {
|
|
4
|
+
try {
|
|
5
|
+
const { data } = await axiosClient({
|
|
6
|
+
url: '/auth/mobile-exists',
|
|
7
|
+
method: 'POST',
|
|
8
|
+
data: { phone },
|
|
9
|
+
});
|
|
10
|
+
return { mobileExist: data?.exists, linkedAccounts: data?.memberDetails };
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
if (err?.response?.status == 404) {
|
|
14
|
+
return { mobileExist: false };
|
|
15
|
+
}
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/** Check if email exists */
|
|
20
|
+
const checkEmailExists = async (email) => {
|
|
21
|
+
try {
|
|
22
|
+
const { data } = await axiosClient({
|
|
23
|
+
url: '/auth/email-exists',
|
|
24
|
+
method: 'POST',
|
|
25
|
+
data: { email },
|
|
26
|
+
});
|
|
27
|
+
return { emailExist: data?.exists, loginType: data?.loginType };
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err?.response?.status === 404) {
|
|
31
|
+
return { emailExist: false };
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export { checkMobileExists, checkEmailExists };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { axiosClient } from "../../../api/axiosClient";
|
|
3
|
-
|
|
4
|
-
minLength: 6,
|
|
5
|
-
maxLength: 30,
|
|
6
|
-
numbers: true,
|
|
7
|
-
uppercase: true,
|
|
8
|
-
lowercase: true,
|
|
9
|
-
specialCharacters: true,
|
|
10
|
-
};
|
|
3
|
+
import { defaultPolicy } from "../../../constants/defaultPolicy";
|
|
11
4
|
const usePasswordCriteria = ({ email, password, onCriteriaChange, onMaxLengthChange }) => {
|
|
12
5
|
const { maxLength: defaultMaxLength, ...restDefaultPolicy } = defaultPolicy;
|
|
13
6
|
const [loading, setLoading] = useState(false);
|
|
@@ -4,7 +4,7 @@ import { Text, View } from 'react-native';
|
|
|
4
4
|
import { usePasswordCriteria } from './hooks/usePasswordCriteria';
|
|
5
5
|
const { gray, utility } = Colors;
|
|
6
6
|
const PasswordCriteria = ({ email, password, criteria, onCriteriaChange, onMaxLengthChange }) => {
|
|
7
|
-
const {
|
|
7
|
+
const { loading, passwordPolicy, renderLabel, } = usePasswordCriteria({ email, password, onCriteriaChange, onMaxLengthChange });
|
|
8
8
|
const getCriteriaColor = (isValid) => (isValid ? utility.success_main : gray.gray_600);
|
|
9
9
|
const getCriteriaBackground = (isValid) => (isValid ? utility.success_bg : gray.gray_100);
|
|
10
10
|
return (_jsx(View, { style: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', alignContent: 'space-between', marginTop: 8 }, children: Object.keys(passwordPolicy).map((item, index) => (loading
|
|
@@ -13,10 +13,10 @@ const PasswordCriteria = ({ email, password, criteria, onCriteriaChange, onMaxLe
|
|
|
13
13
|
_jsx(View, { style: {
|
|
14
14
|
marginRight: 8, marginTop: 8, borderRadius: 32,
|
|
15
15
|
paddingVertical: 4, paddingHorizontal: 12,
|
|
16
|
-
backgroundColor: getCriteriaBackground(criteria[item]),
|
|
16
|
+
backgroundColor: getCriteriaBackground(Boolean(criteria[item])),
|
|
17
17
|
}, children: _jsx(Text, { style: {
|
|
18
18
|
fontSize: 12, fontWeight: '500',
|
|
19
|
-
color: getCriteriaColor(criteria[item]),
|
|
19
|
+
color: getCriteriaColor(Boolean(criteria[item])),
|
|
20
20
|
}, children: renderLabel(item) }) }, index))) }));
|
|
21
21
|
};
|
|
22
22
|
export { PasswordCriteria };
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { View, Text } from 'react-native';
|
|
3
3
|
import { Colors, Header, RoundedButton } from '@truworth/twc-rn-common';
|
|
4
4
|
const { gray } = Colors;
|
|
5
|
-
const ScreenLayout = ({ children, title, subTitle, hideHeader, buttonProps, containerStyle, accessoryRight }) => {
|
|
5
|
+
const ScreenLayout = ({ children, headerTitle, title, subTitle, hideHeader, buttonProps, containerStyle, accessoryRight }) => {
|
|
6
6
|
return (_jsxs(_Fragment, { children: [!hideHeader &&
|
|
7
|
-
_jsx(Header, { accessoryRight: accessoryRight }), _jsxs(View, { style: [{ paddingVertical: 32, paddingHorizontal: 16 }, containerStyle], children: [Boolean(title) &&
|
|
7
|
+
_jsx(Header, { title: headerTitle, accessoryRight: accessoryRight }), _jsxs(View, { style: [{ paddingVertical: 32, paddingHorizontal: 16 }, containerStyle], children: [Boolean(title) &&
|
|
8
8
|
_jsx(Text, { textBreakStrategy: 'simple', style: {
|
|
9
9
|
fontSize: 20, fontWeight: '600', color: gray.gray_900,
|
|
10
10
|
lineHeight: 32, marginBottom: 32,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Flex, OTPInput, Typography } from "@truworth/twc-web-design";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
const
|
|
4
|
+
const VerifyEmailOTP = ({ validateOTP, resendOTP, resendOTPCounter, email, status }) => {
|
|
5
5
|
const [otp, setOtp] = useState('');
|
|
6
6
|
const [otpError, setOtpError] = useState(false);
|
|
7
7
|
useEffect(() => {
|
|
@@ -17,4 +17,4 @@ const EmailOTPVerify = ({ validateOTP, resendOTP, resendOTPCounter, email, statu
|
|
|
17
17
|
_jsx(Typography, { type: "utility", size: "medium", className: "mt-1", color: "text-utility-danger-main", children: "Please enter the correct OTP." }), (resendOTPCounter < 3) &&
|
|
18
18
|
_jsxs(Flex, { align: "center", justify: "between", className: 'mt-7', children: [_jsx(Typography, { type: "body", size: "medium", className: "font-semibold", color: "text-gray-400", children: "Didn't receive OTP?" }), _jsx(Button, { variant: 'link', size: 'small', className: "p-0 h-auto", onClick: resendOTP, children: "Resend Code" })] }), _jsx(Button, { label: "Continue", isFullWidth: true, variant: 'primary', className: "mt-7", onClick: () => validateOTP?.(otp), disabled: (otp?.length ?? 0) < 6 })] }));
|
|
19
19
|
};
|
|
20
|
-
export {
|
|
20
|
+
export { VerifyEmailOTP };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dimensions, Platform, ScrollView, Text, TouchableOpacity, View } from "react-native";
|
|
3
|
+
import { Layout } from "@ui-kitten/components";
|
|
4
|
+
import { Header, Colors, CustomKeyboardAvoidingView } from "@truworth/twc-rn-common";
|
|
5
|
+
import { OTPStatusLabel } from "../OTPStatusLabel/index.native";
|
|
6
|
+
import OTPInputView from "@twotalltotems/react-native-otp-input";
|
|
7
|
+
const { gray } = Colors;
|
|
8
|
+
const VerifyEmailOTP = ({ email, status, validateOTP, resendOTP, resendOTPCounter }) => {
|
|
9
|
+
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#FFFFFF' }, children: [_jsx(Header, {}), _jsxs(CustomKeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : undefined, keyboardVerticalOffset: 0, children: [_jsxs(ScrollView, { style: { paddingHorizontal: 20, paddingTop: 32, flex: 1 }, showsVerticalScrollIndicator: false, children: [_jsxs(Text, { textBreakStrategy: 'simple', style: {
|
|
10
|
+
fontSize: 20, fontWeight: '600', color: gray.gray_900,
|
|
11
|
+
lineHeight: 32, marginBottom: 32,
|
|
12
|
+
}, children: ["OTP sent to ", '\n', email] }), _jsx(View, { style: { justifyContent: 'center', flexDirection: 'row', marginBottom: 30, position: 'relative' }, children: _jsx(OTPInputView, { pinCount: 6, autoFocusOnLoad: false, codeInputFieldStyle: {
|
|
13
|
+
fontSize: 20, color: 'black',
|
|
14
|
+
height: 45, width: 30,
|
|
15
|
+
borderWidth: 0, borderBottomWidth: 1,
|
|
16
|
+
}, codeInputHighlightStyle: { borderColor: '#03DAC6' }, style: {
|
|
17
|
+
height: 50,
|
|
18
|
+
width: Dimensions.get('window').width - 100,
|
|
19
|
+
}, onCodeFilled: code => validateOTP(code) }) }), resendOTPCounter < 3 &&
|
|
20
|
+
_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center' }, children: [_jsxs(Text, { style: { fontSize: 14, fontWeight: '500', color: gray.gray_400, lineHeight: 20 }, children: ["Did not receive OTP?", ' '] }), _jsx(TouchableOpacity, { activeOpacity: 0.8, onPress: resendOTP, children: _jsx(Text, { style: { fontSize: 14, fontWeight: '500', color: '#2cbaa4', lineHeight: 20 }, children: "Re-send OTP" }) })] })] }), _jsx(View, { style: { alignSelf: 'flex-end', width: '100%' }, children: _jsx(OTPStatusLabel, { status: status }) })] })] }));
|
|
21
|
+
};
|
|
22
|
+
export { VerifyEmailOTP };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from "react";
|
|
3
3
|
import { Button, Flex, OTPInput, Typography } from "@truworth/twc-web-design";
|
|
4
|
-
const
|
|
4
|
+
const VerifyMobileOTP = ({ validateOTP, timer, resendOTP, phone, status, resendTextClassName }) => {
|
|
5
5
|
const [otp, setOtp] = useState('');
|
|
6
6
|
const [otpError, setOtpError] = useState(false);
|
|
7
7
|
useEffect(() => {
|
|
@@ -20,4 +20,4 @@ const OTPVerify = ({ validateOTP, timer, resendOTP, phone, status, resendTextCla
|
|
|
20
20
|
:
|
|
21
21
|
_jsxs(Typography, { type: 'utility', size: 'medium', className: `mt-3 ${resendTextClassName}`, children: ["Resend Code in ", timer > 0 ? `${timer} seconds` : 'OTP expired'] }), _jsx(Button, { label: "Continue", isFullWidth: true, onClick: () => validateOTP?.(otp), disabled: otp ? otp?.length < 6 : true, className: "mt-6" })] }));
|
|
22
22
|
};
|
|
23
|
-
export {
|
|
23
|
+
export { VerifyMobileOTP };
|
|
@@ -7,7 +7,7 @@ import { useAuthPackageContext } from '../../hooks/internal/useAuthPackageContex
|
|
|
7
7
|
import { OTPStatusLabel } from '../OTPStatusLabel/index.native';
|
|
8
8
|
import OTPInputView from '@twotalltotems/react-native-otp-input';
|
|
9
9
|
const { gray } = Colors;
|
|
10
|
-
const
|
|
10
|
+
const VerifyMobileOTP = ({ validateOTP, timer, status, resendOTP, phone }) => {
|
|
11
11
|
const [otp, setOTP] = useState('');
|
|
12
12
|
const { otpValue } = useAuthPackageContext();
|
|
13
13
|
useEffect(() => {
|
|
@@ -35,4 +35,4 @@ const OTPVerify = ({ validateOTP, timer, status, resendOTP, phone }) => {
|
|
|
35
35
|
resendOTP();
|
|
36
36
|
}, children: _jsx(Text, { style: { fontSize: 14, color: '#2cbaa4', fontWeight: '400', opacity: 1 }, children: "Re-send OTP" }) })] })] }), _jsx(View, { style: { width: '100%' }, children: _jsx(OTPStatusLabel, { status: status, timer: timer }) })] })] }));
|
|
37
37
|
};
|
|
38
|
-
export {
|
|
38
|
+
export { VerifyMobileOTP };
|
|
@@ -119,8 +119,8 @@ const AuthProvider = ({ children, LogoComponent, session, appConfig, onLogin, on
|
|
|
119
119
|
const clearSession = useCallback(() => {
|
|
120
120
|
setToken('');
|
|
121
121
|
setClient(null);
|
|
122
|
-
setProfile(null);
|
|
123
122
|
setRegistrationMethod(null);
|
|
123
|
+
setProfile(null);
|
|
124
124
|
}, []);
|
|
125
125
|
/**
|
|
126
126
|
* Helper to normalize and format user profile data
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var LoginMethodCode;
|
|
2
|
+
(function (LoginMethodCode) {
|
|
3
|
+
LoginMethodCode[LoginMethodCode["EmailPassword"] = 1] = "EmailPassword";
|
|
4
|
+
LoginMethodCode[LoginMethodCode["Facebook"] = 2] = "Facebook";
|
|
5
|
+
LoginMethodCode[LoginMethodCode["Google"] = 3] = "Google";
|
|
6
|
+
LoginMethodCode[LoginMethodCode["Apple"] = 4] = "Apple";
|
|
7
|
+
LoginMethodCode[LoginMethodCode["SSO"] = 5] = "SSO";
|
|
8
|
+
})(LoginMethodCode || (LoginMethodCode = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var RegistrationMethod;
|
|
2
|
+
(function (RegistrationMethod) {
|
|
3
|
+
RegistrationMethod["EMAIL"] = "email";
|
|
4
|
+
RegistrationMethod["SSO"] = "sso";
|
|
5
|
+
RegistrationMethod["MOBILE"] = "mobile";
|
|
6
|
+
RegistrationMethod["SOCIAL"] = "social";
|
|
7
|
+
})(RegistrationMethod || (RegistrationMethod = {}));
|
|
@@ -77,7 +77,7 @@ export const createHttpClient = ({ token, onRefreshSession, onLogout }) => {
|
|
|
77
77
|
const handleInvalidSession = async () => {
|
|
78
78
|
try {
|
|
79
79
|
await onLogout?.();
|
|
80
|
-
showMessage('Your session has expired. Please login again.');
|
|
80
|
+
showMessage({ message: 'Your session has expired. Please login again.' });
|
|
81
81
|
}
|
|
82
82
|
catch (err) {
|
|
83
83
|
console.error('Error logging out:', err);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { showNotification } from "@truworth/twc-web-design";
|
|
2
|
-
const showMessage = (message) => {
|
|
2
|
+
const showMessage = ({ message, type }) => {
|
|
3
3
|
if (message == null)
|
|
4
4
|
return;
|
|
5
5
|
const text = typeof message === 'string'
|
|
@@ -10,7 +10,7 @@ const showMessage = (message) => {
|
|
|
10
10
|
? String(message.message)
|
|
11
11
|
: String(message);
|
|
12
12
|
showNotification({
|
|
13
|
-
type: 'error',
|
|
13
|
+
type: type ?? 'error',
|
|
14
14
|
title: text,
|
|
15
15
|
showIcon: false,
|
|
16
16
|
duration: 3000,
|
package/build/src/index.js
CHANGED
|
@@ -10,5 +10,6 @@ export * from './api/axiosClient';
|
|
|
10
10
|
// export navigator/router
|
|
11
11
|
export * from './navigator';
|
|
12
12
|
// export components
|
|
13
|
-
export * from './screens/Login/components/LoginWebComponent';
|
|
14
|
-
export * from './screens/SignUp/components/SignUpWebComponent';
|
|
13
|
+
export * from './screens/Login/components/LoginWebComponent/index';
|
|
14
|
+
export * from './screens/SignUp/components/SignUpWebComponent/index';
|
|
15
|
+
export * from './screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index';
|
|
@@ -9,8 +9,15 @@ import CreatePassword from '../screens/CreatePassword/index.native';
|
|
|
9
9
|
import UserConsent from '../screens/UserConsent/index.native';
|
|
10
10
|
import VerifyMobile from '../screens/VerifyMobile/index.native';
|
|
11
11
|
import VerifyEmail from '../screens/VerifyEmail/index.native';
|
|
12
|
+
import LoginWithEmailOTP from '../screens/LoginWithEmailOTP/index.native';
|
|
13
|
+
import VerifyResetPasswordOTP from '../screens/VerifyResetPasswordOTP/index.native';
|
|
14
|
+
import ResetPassword from '../screens/ResetPassword/index.native';
|
|
15
|
+
import SSOSearchOrganization from '../screens/SSOLogin/SearchOrganization/index.native';
|
|
16
|
+
import SSOAuthenticationMethods from '../screens/SSOLogin/AuthenticationMethods/index.native';
|
|
17
|
+
import SSOAuthWebView from '../screens/SSOLogin/AuthWebView/index.native';
|
|
18
|
+
import SSOCallback from '../screens/SSOLogin/SSOCallback/index.native';
|
|
12
19
|
const { Navigator, Screen } = createNativeStackNavigator();
|
|
13
20
|
const AuthNavigator = () => {
|
|
14
|
-
return (_jsxs(Navigator, { screenOptions: { headerShown: false }, children: [_jsx(Screen, { name: "Welcome", component: Welcome }), _jsx(Screen, { name: "EnterEmail", component: EnterEmail }), _jsx(Screen, { name: "EnterPassword", component: EnterPassword }), _jsx(Screen, { name: "SignUp", component: SignUp }), _jsx(Screen, { name: "CountryCode", component: CountryCode }), _jsx(Screen, { name: "CreatePassword", component: CreatePassword }), _jsx(Screen, { name: "UserConsent", component: UserConsent }), _jsx(Screen, { name: "VerifyMobile", component: VerifyMobile }), _jsx(Screen, { name: "VerifyEmail", component: VerifyEmail })] }));
|
|
21
|
+
return (_jsxs(Navigator, { screenOptions: { headerShown: false }, children: [_jsx(Screen, { name: "Welcome", component: Welcome }), _jsx(Screen, { name: "EnterEmail", component: EnterEmail }), _jsx(Screen, { name: "EnterPassword", component: EnterPassword }), _jsx(Screen, { name: "SignUp", component: SignUp }), _jsx(Screen, { name: "CountryCode", component: CountryCode }), _jsx(Screen, { name: "CreatePassword", component: CreatePassword }), _jsx(Screen, { name: "UserConsent", component: UserConsent }), _jsx(Screen, { name: "VerifyMobile", component: VerifyMobile }), _jsx(Screen, { name: "VerifyEmail", component: VerifyEmail }), _jsx(Screen, { name: "LoginWithEmailOTP", component: LoginWithEmailOTP }), _jsx(Screen, { name: "VerifyResetPasswordOTP", component: VerifyResetPasswordOTP }), _jsx(Screen, { name: "ResetPassword", component: ResetPassword }), _jsx(Screen, { name: "SSOSearchOrganization", component: SSOSearchOrganization }), _jsx(Screen, { name: "SSOAuthenticationMethods", component: SSOAuthenticationMethods }), _jsx(Screen, { name: "SSOAuthWebView", component: SSOAuthWebView }), _jsx(Screen, { name: "SSOCallback", component: SSOCallback })] }));
|
|
15
22
|
};
|
|
16
23
|
export { AuthNavigator };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
+
import { defaultPolicy } from "../../../../constants/defaultPolicy";
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
* Internal hook for managing CreatePassword screen state and auth context integration.
|
|
@@ -10,13 +11,7 @@ const useCreatePassword = () => {
|
|
|
10
11
|
const [password, setPassword] = useState('');
|
|
11
12
|
const [confirmPassword, setConfirmPassword] = useState('');
|
|
12
13
|
const [maxLength, setMaxLength] = useState(defaultPolicy.maxLength);
|
|
13
|
-
const [criteria, setCriteria] = useState({
|
|
14
|
-
numbers: false,
|
|
15
|
-
minLength: false,
|
|
16
|
-
uppercase: false,
|
|
17
|
-
lowercase: false,
|
|
18
|
-
specialCharacters: false,
|
|
19
|
-
});
|
|
14
|
+
const [criteria, setCriteria] = useState({});
|
|
20
15
|
const handlePassword = (text) => {
|
|
21
16
|
setPassword(text.replace(/\s/g, ''));
|
|
22
17
|
};
|
|
@@ -42,11 +37,3 @@ const useCreatePassword = () => {
|
|
|
42
37
|
};
|
|
43
38
|
};
|
|
44
39
|
export { useCreatePassword };
|
|
45
|
-
const defaultPolicy = {
|
|
46
|
-
minLength: 6,
|
|
47
|
-
maxLength: 30,
|
|
48
|
-
numbers: true,
|
|
49
|
-
uppercase: true,
|
|
50
|
-
lowercase: true,
|
|
51
|
-
specialCharacters: true,
|
|
52
|
-
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
2
|
import { showMessage } from "../../../../helpers/show-message";
|
|
3
3
|
import { useAuthPackageContext } from "../../../../hooks/internal/useAuthPackageContext";
|
|
4
|
-
import {
|
|
4
|
+
import { checkEmailExists } from "../../../../api/auth";
|
|
5
|
+
import { LoginMethodCode } from "../../../../enums";
|
|
5
6
|
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
6
7
|
/**
|
|
7
8
|
* @internal
|
|
@@ -19,50 +20,31 @@ const useEnterEmail = () => {
|
|
|
19
20
|
setInvalidEmail(!emailRegex.test(value));
|
|
20
21
|
setEmail(value);
|
|
21
22
|
}, [emailRegex]);
|
|
22
|
-
const handleValidateEmail = ({
|
|
23
|
-
if (loading || isInvalidEmail || !email)
|
|
24
|
-
return;
|
|
23
|
+
const handleValidateEmail = async ({ onContinue }) => {
|
|
25
24
|
setLoading(true);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (code !== 1) {
|
|
39
|
-
let providerName = 'your social account';
|
|
40
|
-
switch (code) {
|
|
41
|
-
case 2:
|
|
42
|
-
providerName = 'Facebook';
|
|
43
|
-
break;
|
|
44
|
-
case 3:
|
|
45
|
-
providerName = 'Google';
|
|
46
|
-
break;
|
|
47
|
-
case 4:
|
|
48
|
-
providerName = 'Apple';
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
setLoginType(providerName);
|
|
25
|
+
try {
|
|
26
|
+
const { emailExist, loginType } = await checkEmailExists(email);
|
|
27
|
+
const code = Number(loginType);
|
|
28
|
+
if (emailExist && code !== LoginMethodCode.EmailPassword) {
|
|
29
|
+
const loginTypesMap = {
|
|
30
|
+
[LoginMethodCode.Facebook]: 'Facebook',
|
|
31
|
+
[LoginMethodCode.Google]: 'Google',
|
|
32
|
+
[LoginMethodCode.Apple]: 'Apple',
|
|
33
|
+
[LoginMethodCode.SSO]: 'SSO',
|
|
34
|
+
};
|
|
35
|
+
setLoginType(loginTypesMap[code] || 'your social account');
|
|
52
36
|
setLoginConflictModalVisible(true);
|
|
53
37
|
return;
|
|
54
38
|
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
39
|
+
onContinue({ emailExist });
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const errorMessage = err?.response?.data?.errors?.[0]?.message ?? 'Something went wrong';
|
|
43
|
+
showMessage({ message: errorMessage });
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
58
46
|
setLoading(false);
|
|
59
|
-
|
|
60
|
-
onResult({ email, emailExist: false });
|
|
61
|
-
}
|
|
62
|
-
if (err?.response?.status >= 500) {
|
|
63
|
-
showMessage('Something went wrong');
|
|
64
|
-
}
|
|
65
|
-
});
|
|
47
|
+
}
|
|
66
48
|
};
|
|
67
49
|
const clearText = useCallback(() => {
|
|
68
50
|
setEmail('');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Form, TextInput, useForm } from '@truworth/twc-web-design';
|
|
2
|
+
import { Button, Form, TextInput, useForm } from '@truworth/twc-web-design';
|
|
3
3
|
import { ConfirmationModal as LoginConflictModal } from '../../components/ConfirmationModal';
|
|
4
4
|
import { ScreenLayout } from "../../components/ScreenLayout";
|
|
5
5
|
import { useEnterEmail } from "./hooks/internal/useEnterEmail";
|
|
6
6
|
import { SupportDetails } from '../../components/SupportDetails';
|
|
7
|
-
const EnterEmail = ({
|
|
7
|
+
const EnterEmail = ({ onContinue, onPressSignInWithSSO }) => {
|
|
8
8
|
const { loading, email, isInvalidEmail, loginConflictModalVisible, loginConflictErrorTitle, loginConflictErrorDescription, enterEmail, appName, handleValidateEmail, setLoginConflictModalVisible, } = useEnterEmail();
|
|
9
9
|
const form = useForm({ defaultValues: { email } });
|
|
10
10
|
return (_jsxs(_Fragment, { children: [_jsxs(ScreenLayout, { title: `Hi, Welcome To ${appName}!`, subTitle: "Please enter email to get started.", buttonProps: {
|
|
@@ -12,19 +12,17 @@ const EnterEmail = ({ onResult }) => {
|
|
|
12
12
|
label: 'Continue',
|
|
13
13
|
onClick: () => {
|
|
14
14
|
if (!loading && !isInvalidEmail) {
|
|
15
|
-
handleValidateEmail({
|
|
15
|
+
handleValidateEmail({
|
|
16
|
+
onContinue: (params) => onContinue({ email, emailExist: params.emailExist })
|
|
17
|
+
});
|
|
16
18
|
}
|
|
17
19
|
},
|
|
18
20
|
disabled: isInvalidEmail || loading,
|
|
19
|
-
}, children: [_jsx(Form, { className: "w-full", form: form,
|
|
20
|
-
if (!loading && !isInvalidEmail) {
|
|
21
|
-
handleValidateEmail({ onResult });
|
|
22
|
-
}
|
|
23
|
-
}, children: _jsx(Form.Item, { name: "email", label: "Email", children: _jsx(TextInput, { type: "email", value: email, size: "medium", placeholder: "example@domain", ...form.register('email', {
|
|
21
|
+
}, children: [_jsx(Form, { className: "w-full", form: form, children: _jsx(Form.Item, { name: "email", label: "Email", children: _jsx(TextInput, { type: "email", value: email, size: "medium", placeholder: "example@domain", ...form.register('email', {
|
|
24
22
|
onChange: (e) => {
|
|
25
23
|
enterEmail(e.target.value);
|
|
26
24
|
}
|
|
27
25
|
}) }) }) }), loginConflictModalVisible &&
|
|
28
|
-
_jsx(LoginConflictModal, { title: loginConflictErrorTitle, primaryLabel: 'Okay', description: loginConflictErrorDescription, visible: loginConflictModalVisible, onProceed: () => setLoginConflictModalVisible(false), onClose: () => setLoginConflictModalVisible(false) })] }), _jsx(SupportDetails, {})] }));
|
|
26
|
+
_jsx(LoginConflictModal, { title: loginConflictErrorTitle, primaryLabel: 'Okay', description: loginConflictErrorDescription, visible: loginConflictModalVisible, onProceed: () => setLoginConflictModalVisible(false), onClose: () => setLoginConflictModalVisible(false) })] }), _jsx(Button, { isFullWidth: true, type: "button", label: 'Sign In with SSO', variant: 'secondary', className: 'flex-none mt-6', onClick: onPressSignInWithSSO }), _jsx(SupportDetails, {})] }));
|
|
29
27
|
};
|
|
30
28
|
export default EnterEmail;
|
|
@@ -5,26 +5,26 @@ import { Colors, TextInputField } from '@truworth/twc-rn-common';
|
|
|
5
5
|
import { useEnterEmail } from './hooks/internal/useEnterEmail';
|
|
6
6
|
import { ScreenLayout } from '../../components/ScreenLayout/index.native';
|
|
7
7
|
import { ConfirmationModal as LoginConflictModal } from '../../components/ConfirmationModal';
|
|
8
|
+
import { RegistrationMethod } from '../../enums';
|
|
8
9
|
const { utility } = Colors;
|
|
9
10
|
const EnterEmail = ({ navigation }) => {
|
|
10
11
|
const { loading, email, isInvalidEmail, loginConflictModalVisible, loginConflictErrorTitle, loginConflictErrorDescription, enterEmail, clearText, handleValidateEmail, onRegistrationMethodChange, setLoginConflictModalVisible, } = useEnterEmail();
|
|
12
|
+
const onContinue = (params) => {
|
|
13
|
+
if (params.emailExist) {
|
|
14
|
+
navigation.navigate('EnterPassword', { email });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
onRegistrationMethodChange(RegistrationMethod.EMAIL);
|
|
18
|
+
navigation.navigate('SignUp', { email });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
11
21
|
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#FFFFFF' }, children: [_jsx(ScreenLayout, { title: "Enter Your Email", buttonProps: {
|
|
12
22
|
loading,
|
|
13
23
|
label: 'Continue',
|
|
14
24
|
onPress: () => {
|
|
15
25
|
Keyboard.dismiss();
|
|
16
26
|
if (!loading && !isInvalidEmail) {
|
|
17
|
-
handleValidateEmail({
|
|
18
|
-
onResult: (params) => {
|
|
19
|
-
if (params.emailExist) {
|
|
20
|
-
navigation.navigate('EnterPassword', { email });
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
onRegistrationMethodChange('email');
|
|
24
|
-
navigation.navigate('SignUp', { email });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
27
|
+
handleValidateEmail({ onContinue });
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
disabled: isInvalidEmail || loading,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Button, Flex, Form, PasswordInput, ResponsiveModal, Typography, useForm } from '@truworth/twc-web-design';
|
|
3
4
|
import { ScreenLayout } from "../../components/ScreenLayout";
|
|
4
5
|
import { useEnterPassword } from './hooks/internal/useEnterPassword';
|
|
5
6
|
import { SupportDetails } from '../../components/SupportDetails';
|
|
6
|
-
|
|
7
|
+
import LoginWithEmailOTP from '../LoginWithEmailOTP';
|
|
8
|
+
import VerifyResetPasswordOTP from '../VerifyResetPasswordOTP';
|
|
9
|
+
const EnterPassword = ({ email, onPressBack, onVerifiedResetPasswordOTP }) => {
|
|
10
|
+
const [showResetPasswordOTPModal, setShowResetPasswordOTPModal] = useState(false);
|
|
11
|
+
const [showLoginWithEmailOTPModal, setShowLoginWithEmailOTPModal] = useState(false);
|
|
7
12
|
const { loading, password, isInvalidPassword, handleSubmit, onPassword, appName } = useEnterPassword();
|
|
8
13
|
const form = useForm({ defaultValues: { password } });
|
|
9
|
-
return (_jsxs(_Fragment, { children: [
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ScreenLayout, { title: `Hi, Welcome To ${appName}!`, subTitle: email, buttonProps: {
|
|
10
15
|
loading,
|
|
11
16
|
label: 'Continue',
|
|
12
17
|
onClick: () => { if (email)
|
|
13
18
|
handleSubmit({ email, source: 'web' }); },
|
|
14
19
|
disabled: !password || !email || loading,
|
|
15
|
-
}, onPressBack: onPressBack, children: _jsx(Form, { className: "w-full", form: form, onSubmit: () => { if (email)
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
}, onPressBack: onPressBack, children: [_jsx(Form, { className: "w-full", form: form, onSubmit: () => { if (email)
|
|
21
|
+
handleSubmit({ email, source: 'web' }); }, children: _jsx(Form.Item, { name: "password", label: "Password", description: isInvalidPassword &&
|
|
22
|
+
_jsx(Typography, { type: "body", size: "small", className: "h-1", color: "text-utility-danger-main", children: "Email and password do not match!" }), children: _jsx(PasswordInput, { placeholder: "Enter your password", value: password, showStrengthIndicator: false, className: `border rounded-md px-3 py-2
|
|
18
23
|
${isInvalidPassword ? "border-red-500" : "border-gray-300"}`, ...form.register('password', {
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
onChange: (e) => onPassword(e.target.value)
|
|
25
|
+
}) }) }) }), _jsx(Button, { type: "button", size: 'small', variant: 'link', label: "Forgot Password?", className: "px-0 h-auto ml-auto block mt-4", onClick: () => setShowResetPasswordOTPModal(true) })] }), _jsxs(Flex, { align: "center", className: "mt-6 mb-6", children: [_jsx(Flex, { className: "flex-1 border-t border-gray-300" }), _jsx(Typography, { type: 'body', size: 'small', className: "text-gray-500 px-4", children: "OR" }), _jsx(Flex, { className: "flex-1 border-t border-gray-300" })] }), _jsx(Button, { label: 'Sign In With OTP', variant: 'secondary', className: 'flex-none', isFullWidth: true, type: "button", onClick: () => setShowLoginWithEmailOTPModal(true) }), _jsx(SupportDetails, {}), showResetPasswordOTPModal &&
|
|
26
|
+
_jsx(VerifyResetPasswordOTPModal, { email: email, show: showResetPasswordOTPModal, hide: () => setShowResetPasswordOTPModal(false), onVerifiedOTP: (sessionToken) => {
|
|
27
|
+
setShowResetPasswordOTPModal(false);
|
|
28
|
+
onVerifiedResetPasswordOTP(sessionToken);
|
|
29
|
+
} }), showLoginWithEmailOTPModal &&
|
|
30
|
+
_jsx(LoginWithEmailOTPModal, { email: email, show: showLoginWithEmailOTPModal, hide: () => setShowLoginWithEmailOTPModal(false) })] }));
|
|
31
|
+
};
|
|
32
|
+
const LoginWithEmailOTPModal = ({ show, hide, email }) => {
|
|
33
|
+
return (_jsx(ResponsiveModal, { open: show, onClose: hide, title: _jsx(Typography, { type: "heading", size: "h6", className: "text-center mb-0", children: "Verify Your Email" }), showCloseButton: false, maskClosable: false, size: 'sm', children: _jsx(LoginWithEmailOTP, { email: email }) }));
|
|
34
|
+
};
|
|
35
|
+
const VerifyResetPasswordOTPModal = ({ show, hide, email, onVerifiedOTP }) => {
|
|
36
|
+
return (_jsx(ResponsiveModal, { title: "Reset Your Password", open: show, onClose: hide, maskClosable: false, showCloseButton: false, size: 'sm', children: _jsx(VerifyResetPasswordOTP, { email: email, onVerifiedOTP: onVerifiedOTP }) }));
|
|
21
37
|
};
|
|
22
38
|
export default EnterPassword;
|
|
@@ -1,23 +1,35 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { TextInputField } from '@truworth/twc-rn-common';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View, Text, Platform, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { RoundedButton, TextInputField, Colors } from '@truworth/twc-rn-common';
|
|
4
4
|
import { Layout } from '@ui-kitten/components';
|
|
5
5
|
import { ScreenLayout } from '../../components/ScreenLayout/index.native';
|
|
6
6
|
import { useEnterPassword } from './hooks/internal/useEnterPassword';
|
|
7
|
-
const
|
|
7
|
+
const { primary } = Colors;
|
|
8
|
+
const EnterPassword = ({ navigation, route }) => {
|
|
8
9
|
const { email } = route.params;
|
|
9
10
|
const { loading, password, isPasswordVisible, togglePasswordVisibility, isInvalidPassword, handleSubmit, onPassword } = useEnterPassword();
|
|
10
|
-
return (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#FFFFFF' }, children: [_jsxs(ScreenLayout, { title: "Enter Your Password", buttonProps: {
|
|
12
|
+
loading,
|
|
13
|
+
label: 'Continue',
|
|
14
|
+
onPress: () => { if (email)
|
|
15
|
+
handleSubmit({ email, source: Platform.OS }); },
|
|
16
|
+
disabled: password.length == 0 || isInvalidPassword || loading,
|
|
17
|
+
}, children: [_jsx(View, { style: { position: 'relative' }, children: _jsx(TextInputField, { placeholder: 'Enter password...', onChangeValue: onPassword, secureTextEntry: !isPasswordVisible, value: password, rightIcon2: isPasswordVisible
|
|
18
|
+
? 'eye-outline'
|
|
19
|
+
: 'eye-off-outline', onPressRightIcon2: () => togglePasswordVisibility(), error: {
|
|
20
|
+
show: isInvalidPassword,
|
|
21
|
+
message: isInvalidPassword ? 'Email and password do not match!' : ''
|
|
22
|
+
}, autoFocus: true }) }), _jsx(TouchableOpacity, { activeOpacity: 0.8, style: { marginTop: isInvalidPassword ? 0 : 10, alignSelf: 'flex-end' }, onPress: () => navigation.navigate('VerifyResetPasswordOTP', { email }), children: _jsx(Text, { style: {
|
|
23
|
+
fontSize: 12, fontWeight: '600',
|
|
24
|
+
color: primary.primary_main, lineHeight: 20,
|
|
25
|
+
}, children: "Forgot Password?" }) })] }), _jsxs(View, { style: { paddingHorizontal: 16 }, children: [_jsxs(View, { style: {
|
|
26
|
+
flexDirection: 'row', justifyContent: 'center',
|
|
27
|
+
alignItems: 'center', marginBottom: 14, marginTop: 14,
|
|
28
|
+
}, children: [_jsx(View, { style: { width: 12, height: 1, backgroundColor: '#7F7F7F' } }), _jsx(Text, { style: {
|
|
29
|
+
fontSize: 12, fontWeight: '600', color: '#7F7F7F',
|
|
30
|
+
lineHeight: 20, textAlign: 'center',
|
|
31
|
+
marginHorizontal: 6,
|
|
32
|
+
}, children: "OR" }), _jsx(View, { style: { width: 12, height: 1, backgroundColor: '#7F7F7F' } })] }), email &&
|
|
33
|
+
_jsx(RoundedButton, { type: "text", size: "medium", label: "Sign In With OTP", onPress: () => navigation.navigate('LoginWithEmailOTP', { email }) })] })] }));
|
|
22
34
|
};
|
|
23
35
|
export default EnterPassword;
|