@truworth/twc-auth 1.2.3 → 1.2.5
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/README.md +1 -4
- package/build/assets/loading-spinner.json +1 -0
- package/build/src/api/auth.js +36 -0
- package/build/src/api/axiosClient/index.js +1 -1
- package/build/src/api/axiosClient/index.native.js +1 -1
- package/build/src/components/ScreenLayout/index.native.js +2 -2
- package/build/src/components/VerifyEmailOTP/index.native.js +14 -11
- package/build/src/components/VerifyMobileOTP/index.js +8 -6
- package/build/src/components/VerifyMobileOTP/index.native.js +6 -11
- package/build/src/constants/base-url/index.js +5 -0
- package/build/src/constants/base-url/index.native.js +1 -0
- package/build/src/constants/cdn-url/index.js +2 -1
- package/build/src/contexts/AuthContext.js +4 -2
- 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/index.js +3 -2
- package/build/src/navigator/index.native.js +9 -1
- package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +58 -66
- package/build/src/screens/EnterEmail/index.js +11 -15
- package/build/src/screens/EnterEmail/index.native.js +14 -17
- package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/hooks/internal/useExistingAccountsSheet.js +36 -0
- package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/index.js +33 -0
- package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/index.native.js +73 -0
- package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/types.js +1 -0
- package/build/src/screens/EnterMobile/hooks/internal/useEnterMobile.js +67 -0
- package/build/src/screens/EnterMobile/index.js +82 -0
- package/build/src/screens/EnterMobile/index.native.js +56 -0
- package/build/src/screens/EnterMobile/types.js +1 -0
- package/build/src/screens/EnterPassword/hooks/internal/useEnterPassword.js +42 -31
- package/build/src/screens/EnterPassword/index.js +17 -8
- package/build/src/screens/EnterPassword/index.native.js +5 -10
- package/build/src/screens/Login/components/LoginWebComponent/index.js +19 -15
- package/build/src/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.js +8 -5
- package/build/src/screens/LoginWithMobileOTP/hooks/internal/useLoginWithMobileOTP.js +71 -0
- package/build/src/screens/LoginWithMobileOTP/index.js +8 -0
- package/build/src/screens/LoginWithMobileOTP/index.native.js +10 -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 +49 -0
- package/build/src/screens/SSOLogin/AuthenticationMethods/index.native.js +54 -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 +109 -68
- 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 +90 -90
- package/build/src/screens/UserConsent/hooks/internal/useConsent.js +10 -3
- package/build/src/screens/UserConsent/index.js +39 -19
- package/build/src/screens/UserConsent/index.native.js +1 -1
- package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/hooks/internal/useVerifyLinkPrimaryAccountEmailOTP.js +73 -0
- package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/index.js +8 -0
- package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/index.native.js +14 -0
- package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/types.js +1 -0
- package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/hooks/internal/useVerifyLinkPrimaryAccountMobileOTP.js +82 -0
- package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/index.js +8 -0
- package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/index.native.js +10 -0
- package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/types.js +1 -0
- package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +2 -2
- package/build/src/screens/Welcome/index.js +5 -5
- package/build/src/screens/Welcome/index.native.js +1 -1
- package/build/src/types/types.js +1 -1
- package/build/types/api/auth.d.ts +11 -0
- 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/VerifyMobileOTP/index.d.ts +1 -1
- package/build/types/components/VerifyMobileOTP/types.d.ts +0 -1
- package/build/types/constants/base-url/index.d.ts +1 -0
- package/build/types/constants/base-url/index.native.d.ts +1 -0
- package/build/types/constants/cdn-url/index.d.ts +2 -1
- package/build/types/contexts/AuthContext.d.ts +2 -1
- package/build/types/contexts/type.d.ts +3 -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/index.d.ts +3 -2
- package/build/types/navigator/index.native.d.ts +28 -1
- package/build/types/screens/EnterEmail/hooks/internal/useEnterEmail.d.ts +11 -15
- package/build/types/screens/EnterEmail/index.d.ts +2 -6
- package/build/types/screens/EnterEmail/types.d.ts +13 -0
- package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/hooks/internal/useExistingAccountsSheet.d.ts +13 -0
- package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/index.d.ts +3 -0
- package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/index.native.d.ts +3 -0
- package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/types.d.ts +28 -0
- package/build/types/screens/EnterMobile/hooks/internal/useEnterMobile.d.ts +15 -0
- package/build/types/screens/EnterMobile/index.d.ts +4 -0
- package/build/types/screens/EnterMobile/index.native.d.ts +4 -0
- package/build/types/screens/EnterMobile/types.d.ts +44 -0
- package/build/types/screens/EnterPassword/hooks/internal/useEnterPassword.d.ts +8 -8
- package/build/types/screens/EnterPassword/index.d.ts +1 -1
- package/build/types/screens/EnterPassword/types.d.ts +6 -2
- package/build/types/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.d.ts +1 -1
- package/build/types/screens/LoginWithMobileOTP/hooks/internal/useLoginWithMobileOTP.d.ts +11 -0
- package/build/types/screens/LoginWithMobileOTP/index.d.ts +5 -0
- package/build/types/screens/LoginWithMobileOTP/index.native.d.ts +4 -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 +12 -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/VerifyLinkPrimaryAccountEmailOTP/hooks/internal/useVerifyLinkPrimaryAccountEmailOTP.d.ts +15 -0
- package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/index.d.ts +3 -0
- package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/index.native.d.ts +4 -0
- package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/types.d.ts +14 -0
- package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/hooks/internal/useVerifyLinkPrimaryAccountMobileOTP.d.ts +17 -0
- package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/index.d.ts +3 -0
- package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/index.native.d.ts +4 -0
- package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/types.d.ts +5 -0
- package/build/types/types/types.d.ts +16 -2
- package/package.json +6 -8
- package/build/types/screens/Login/components/LoginWebComponent/types.d.ts +0 -6
- /package/build/src/screens/{Login/components/LoginWebComponent → EnterEmail}/types.js +0 -0
package/README.md
CHANGED
|
@@ -70,7 +70,6 @@ Truworth Auth Module - A comprehensive authentication solution for React Native
|
|
|
70
70
|
| react | >=18.2.0 |
|
|
71
71
|
| react-native | >=0.74.5 |
|
|
72
72
|
| react-native-fast-image | >=8.6.3 |
|
|
73
|
-
| react-native-freshchat-sdk | >=4.6.6 |
|
|
74
73
|
| react-native-gesture-handler | >=2.16.0 |
|
|
75
74
|
| react-native-linear-gradient | >=2.8.3 |
|
|
76
75
|
| react-native-modalize | >=2.1.1 |
|
|
@@ -80,13 +79,12 @@ Truworth Auth Module - A comprehensive authentication solution for React Native
|
|
|
80
79
|
| react-native-svg | >=15.8.0 |
|
|
81
80
|
| react-native-vector-icons | >=9.2.0 |
|
|
82
81
|
|
|
83
|
-
> Note: lottie-react-native, react-native-fast-image
|
|
82
|
+
> Note: lottie-react-native, react-native-fast-image are optional and only needed if your app uses features that depend on them.
|
|
84
83
|
|
|
85
84
|
#### Web Dependencies
|
|
86
85
|
|
|
87
86
|
| Package | Version |
|
|
88
87
|
| ------------------------ | -------- |
|
|
89
|
-
| @truworth/twc-web-common | ^1.0.11 |
|
|
90
88
|
| @truworth/twc-web-design | ^1.9.0 |
|
|
91
89
|
| antd | ^5.6.3 |
|
|
92
90
|
| framer-motion | ^12.6.2 |
|
|
@@ -108,7 +106,6 @@ Truworth Auth Module - A comprehensive authentication solution for React Native
|
|
|
108
106
|
```bash
|
|
109
107
|
npm install \
|
|
110
108
|
next@^15.0.4 \
|
|
111
|
-
@truworth/twc-web-common@^1.0.11 \
|
|
112
109
|
@truworth/twc-web-design@^1.9.0 \
|
|
113
110
|
antd@^5.6.3 \
|
|
114
111
|
framer-motion@^12.6.2 \
|
|
@@ -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 };
|
|
@@ -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,19 +1,22 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Dimensions, Platform, ScrollView, Text, TouchableOpacity, View } from "react-native";
|
|
3
3
|
import { Layout } from "@ui-kitten/components";
|
|
4
4
|
import { Header, Colors, CustomKeyboardAvoidingView } from "@truworth/twc-rn-common";
|
|
5
|
-
import { ScreenLayout } from "../ScreenLayout";
|
|
6
5
|
import { OTPStatusLabel } from "../OTPStatusLabel/index.native";
|
|
7
6
|
import OTPInputView from "@twotalltotems/react-native-otp-input";
|
|
7
|
+
const { gray } = Colors;
|
|
8
8
|
const VerifyEmailOTP = ({ email, status, validateOTP, resendOTP, resendOTPCounter }) => {
|
|
9
|
-
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 }) })] })] }));
|
|
18
21
|
};
|
|
19
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 VerifyMobileOTP = ({ validateOTP, timer, resendOTP, phone, status
|
|
4
|
+
const VerifyMobileOTP = ({ validateOTP, timer, resendOTP, phone, status }) => {
|
|
5
5
|
const [otp, setOtp] = useState('');
|
|
6
6
|
const [otpError, setOtpError] = useState(false);
|
|
7
7
|
useEffect(() => {
|
|
@@ -10,14 +10,16 @@ const VerifyMobileOTP = ({ validateOTP, timer, resendOTP, phone, status, resendT
|
|
|
10
10
|
setOtp('');
|
|
11
11
|
}
|
|
12
12
|
}, [status]);
|
|
13
|
-
|
|
14
|
-
return (_jsxs(_Fragment, { children: [defaultPhoneDisplayText, _jsx(OTPInput, { value: otp, onChange: (code) => {
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Typography, { type: 'body', size: 'large', className: 'mb-6 text-gray-400 text-center', children: ["OTP sent to", _jsx("span", { className: 'pl-2 text-secondary-dark', children: phone ? `XXXXXXX${phone.slice(-3)}` : 'your registered mobile number' })] }), _jsx(OTPInput, { value: otp, onChange: (code) => {
|
|
15
14
|
setOtp(code);
|
|
16
15
|
setOtpError(false);
|
|
17
16
|
}, error: otpError, maxLength: 6, className: `!w-auto ${otpError ? '!border-destructive' : ''}` }), otpError &&
|
|
18
|
-
_jsx(Typography, { type: "utility", size: "medium", className: "mt-4", color: "text-utility-danger-main", children: "Please enter the correct OTP." }),
|
|
19
|
-
_jsxs(Flex, { justify: 'between', align: 'center', className: 'mt-4', children: [_jsx(Typography, { type: 'utility', size: 'medium',
|
|
17
|
+
_jsx(Typography, { type: "utility", size: "medium", className: "mt-4", color: "text-utility-danger-main", children: "Please enter the correct OTP." }), timer <= 0 ?
|
|
18
|
+
_jsxs(Flex, { justify: 'between', align: 'center', className: 'mt-4', children: [_jsx(Typography, { type: 'utility', size: 'medium', children: "Didn't receive OTP?" }), _jsx(Button, { label: 'Re-send OTP', size: 'small', variant: 'link', onClick: () => {
|
|
19
|
+
setOtp('');
|
|
20
|
+
resendOTP();
|
|
21
|
+
} })] })
|
|
20
22
|
:
|
|
21
|
-
_jsxs(Typography, { type: 'utility', size: 'medium', className:
|
|
23
|
+
_jsxs(Typography, { type: 'utility', size: 'medium', className: 'mt-3', children: ["Resend Code in ", timer, " seconds"] }), _jsx(Button, { label: "Continue", isFullWidth: true, onClick: () => validateOTP?.(otp), disabled: otp ? otp?.length < 6 : true, className: "mt-6" })] }));
|
|
22
24
|
};
|
|
23
25
|
export { VerifyMobileOTP };
|
|
@@ -8,30 +8,25 @@ import { OTPStatusLabel } from '../OTPStatusLabel/index.native';
|
|
|
8
8
|
import OTPInputView from '@twotalltotems/react-native-otp-input';
|
|
9
9
|
const { gray } = Colors;
|
|
10
10
|
const VerifyMobileOTP = ({ validateOTP, timer, status, resendOTP, phone }) => {
|
|
11
|
-
const [otp,
|
|
11
|
+
const [otp, setOtp] = useState('');
|
|
12
12
|
const { otpValue } = useAuthPackageContext();
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (otp?.length === 6) {
|
|
15
|
-
validateOTP(otp);
|
|
16
|
-
}
|
|
17
|
-
}, [otp]);
|
|
18
13
|
useEffect(() => {
|
|
19
14
|
if (otpValue && otpValue.length == 6) {
|
|
20
|
-
|
|
15
|
+
setOtp(otpValue);
|
|
21
16
|
}
|
|
22
17
|
}, [otpValue]);
|
|
23
18
|
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 }, children: [_jsxs(Text, { textBreakStrategy: 'simple', style: {
|
|
24
19
|
fontSize: 20, fontWeight: '600', color: gray.gray_900,
|
|
25
20
|
lineHeight: 32, marginBottom: 32,
|
|
26
|
-
}, children: ["OTP sent to ", '\n', phone ? phone.replace(/\d(?=\d{4})/g, 'x') : ''] }), _jsx(View, { style: { justifyContent: 'center', flexDirection: 'row', marginBottom: 30, position: 'relative' }, children: _jsx(OTPInputView, { pinCount: 6, autoFocusOnLoad: false, onCodeChanged: text =>
|
|
21
|
+
}, children: ["OTP sent to ", '\n', phone ? phone.replace(/\d(?=\d{4})/g, 'x') : ''] }), _jsx(View, { style: { justifyContent: 'center', flexDirection: 'row', marginBottom: 30, position: 'relative' }, children: _jsx(OTPInputView, { pinCount: 6, autoFocusOnLoad: false, onCodeChanged: text => setOtp(text), codeInputFieldStyle: {
|
|
27
22
|
fontSize: 20, color: 'black', width: 30,
|
|
28
23
|
height: 45, borderWidth: 0, borderBottomWidth: 1,
|
|
29
24
|
}, codeInputHighlightStyle: { borderColor: '#03DAC6' }, style: {
|
|
30
25
|
height: 50,
|
|
31
26
|
width: Dimensions.get('window').width - 100,
|
|
32
|
-
}, code: otp ?? '', onCodeFilled: code =>
|
|
33
|
-
_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center' }, children: [
|
|
34
|
-
|
|
27
|
+
}, code: otp ?? '', onCodeFilled: code => validateOTP(code) }) }), timer <= 0 &&
|
|
28
|
+
_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
|
+
setOtp('');
|
|
35
30
|
resendOTP();
|
|
36
31
|
}, 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
32
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BASE_URL = process.env.BASE_URL;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const MEMBER_IMAGES_URL = process.env.NEXT_PUBLIC_MEMBER_IMAGES_URL;
|
|
2
|
+
export const CDN_IMAGES_URL = process.env.NEXT_PUBLIC_CDN_IMAGES_URL;
|
|
@@ -31,8 +31,9 @@ const AuthPackageContext = React.createContext(null);
|
|
|
31
31
|
* @param onLogout - Optional callback after successful logout
|
|
32
32
|
* @param onLaunchAuthSession - Optional callback after successfully launching the auth session. For example, it can be used to set the Firebase notification token or request Android permissions.
|
|
33
33
|
* @param onRefreshSession - Optional handler for refreshing user session
|
|
34
|
+
* @param openChatSupport - Optional callback to open chat support
|
|
34
35
|
*/
|
|
35
|
-
const AuthProvider = ({ children, LogoComponent, session, appConfig, onLogin, onLogout, onLaunchAuthSession, onRefreshSession }) => {
|
|
36
|
+
const AuthProvider = ({ children, LogoComponent, session, appConfig, onLogin, onLogout, onLaunchAuthSession, onRefreshSession, openChatSupport }) => {
|
|
36
37
|
const [isLoadingProfile, setIsLoadingProfile] = useState(false);
|
|
37
38
|
const [profile, setProfile] = useState(null);
|
|
38
39
|
const [client, setClient] = useState(null);
|
|
@@ -119,8 +120,8 @@ const AuthProvider = ({ children, LogoComponent, session, appConfig, onLogin, on
|
|
|
119
120
|
const clearSession = useCallback(() => {
|
|
120
121
|
setToken('');
|
|
121
122
|
setClient(null);
|
|
122
|
-
setProfile(null);
|
|
123
123
|
setRegistrationMethod(null);
|
|
124
|
+
setProfile(null);
|
|
124
125
|
}, []);
|
|
125
126
|
/**
|
|
126
127
|
* Helper to normalize and format user profile data
|
|
@@ -177,6 +178,7 @@ const AuthProvider = ({ children, LogoComponent, session, appConfig, onLogin, on
|
|
|
177
178
|
onTokenChange: (token) => setToken(token),
|
|
178
179
|
onRegistrationMethodChange: (method) => setRegistrationMethod(method),
|
|
179
180
|
otpValue,
|
|
181
|
+
openChatSupport
|
|
180
182
|
};
|
|
181
183
|
return (_jsx(AuthContext.Provider, { value: AuthContextValues, children: _jsx(AuthPackageContext.Provider, { value: AuthPackageContextValues, children: children }) }));
|
|
182
184
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var LoginMethodCode;
|
|
2
|
+
(function (LoginMethodCode) {
|
|
3
|
+
LoginMethodCode[LoginMethodCode["Email"] = 1] = "Email";
|
|
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 = {}));
|
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';
|
|
@@ -12,8 +12,16 @@ import VerifyEmail from '../screens/VerifyEmail/index.native';
|
|
|
12
12
|
import LoginWithEmailOTP from '../screens/LoginWithEmailOTP/index.native';
|
|
13
13
|
import VerifyResetPasswordOTP from '../screens/VerifyResetPasswordOTP/index.native';
|
|
14
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';
|
|
19
|
+
import LoginWithMobileOTP from '../screens/LoginWithMobileOTP/index.native';
|
|
20
|
+
import EnterMobile from '../screens/EnterMobile/index.native';
|
|
21
|
+
import VerifyLinkPrimaryAccountEmailOTP from '../screens/VerifyLinkPrimaryAccountEmailOTP/index.native';
|
|
22
|
+
import VerifyLinkPrimaryAccountMobileOTP from '../screens/VerifyLinkPrimaryAccountMobileOTP/index.native';
|
|
15
23
|
const { Navigator, Screen } = createNativeStackNavigator();
|
|
16
24
|
const AuthNavigator = () => {
|
|
17
|
-
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 })] }));
|
|
25
|
+
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: "LoginWithMobileOTP", component: LoginWithMobileOTP }), _jsx(Screen, { name: "EnterMobile", component: EnterMobile }), _jsx(Screen, { name: "VerifyLinkPrimaryAccountEmailOTP", component: VerifyLinkPrimaryAccountEmailOTP }), _jsx(Screen, { name: "VerifyLinkPrimaryAccountMobileOTP", component: VerifyLinkPrimaryAccountMobileOTP }), _jsx(Screen, { name: "SSOSearchOrganization", component: SSOSearchOrganization }), _jsx(Screen, { name: "SSOAuthenticationMethods", component: SSOAuthenticationMethods }), _jsx(Screen, { name: "SSOAuthWebView", component: SSOAuthWebView }), _jsx(Screen, { name: "SSOCallback", component: SSOCallback })] }));
|
|
18
26
|
};
|
|
19
27
|
export { AuthNavigator };
|
|
@@ -1,86 +1,78 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
2
|
import { showMessage } from "../../../../helpers/show-message";
|
|
3
3
|
import { useAuthPackageContext } from "../../../../hooks/internal/useAuthPackageContext";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { checkEmailExists } from "../../../../api/auth";
|
|
5
|
+
import { LoginMethodCode, RegistrationMethod } from "../../../../enums";
|
|
6
|
+
const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\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
|
|
8
|
-
*
|
|
9
|
+
* Hook for managing Enter Email screen logic and authentication integration.
|
|
9
10
|
*/
|
|
10
11
|
const useEnterEmail = () => {
|
|
12
|
+
const [email, setEmail] = useState("");
|
|
13
|
+
const [loginType, setLoginType] = useState("");
|
|
11
14
|
const [loading, setLoading] = useState(false);
|
|
12
|
-
const [
|
|
13
|
-
const [
|
|
14
|
-
const [loginType, setLoginType] = useState('');
|
|
15
|
-
const [email, setEmail] = useState('');
|
|
15
|
+
const [isEmailValid, setIsEmailValid] = useState(false);
|
|
16
|
+
const [isLoginConflictModalVisible, setIsLoginConflictModalVisible] = useState(false);
|
|
16
17
|
const { appConfig, onRegistrationMethodChange } = useAuthPackageContext();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Handles email input change with validation
|
|
20
|
+
*/
|
|
21
|
+
const handleEmailChange = useCallback((value) => {
|
|
22
|
+
const normalizedEmail = value.toLowerCase().trim();
|
|
23
|
+
setEmail(normalizedEmail);
|
|
24
|
+
setIsEmailValid(EMAIL_REGEX.test(normalizedEmail));
|
|
25
|
+
}, []);
|
|
26
|
+
/**
|
|
27
|
+
* Validates email existence and handles login conflicts
|
|
28
|
+
*/
|
|
29
|
+
const handleEmailExists = useCallback(async ({ onValidate }) => {
|
|
25
30
|
setLoading(true);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
try {
|
|
32
|
+
const { emailExist, loginType } = await checkEmailExists(email);
|
|
33
|
+
const loginCode = Number(loginType);
|
|
34
|
+
if (emailExist && loginCode !== LoginMethodCode.Email) {
|
|
35
|
+
const loginMethodMap = {
|
|
36
|
+
[LoginMethodCode.Facebook]: "Facebook",
|
|
37
|
+
[LoginMethodCode.Google]: "Google",
|
|
38
|
+
[LoginMethodCode.Apple]: "Apple",
|
|
39
|
+
[LoginMethodCode.SSO]: "SSO",
|
|
40
|
+
};
|
|
41
|
+
setLoginType(loginMethodMap[loginCode] || "your social account");
|
|
42
|
+
setIsLoginConflictModalVisible(true);
|
|
36
43
|
return;
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
break;
|
|
47
|
-
case 4:
|
|
48
|
-
providerName = 'Apple';
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
setLoginType(providerName);
|
|
52
|
-
setLoginConflictModalVisible(true);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
onResult({ email, emailExist: true });
|
|
56
|
-
}).catch(err => {
|
|
57
|
-
console.log(err);
|
|
45
|
+
onRegistrationMethodChange(RegistrationMethod.EMAIL);
|
|
46
|
+
onValidate({ emailExist });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const message = error?.response?.data?.errors?.[0]?.message ?? "Something went wrong";
|
|
50
|
+
showMessage({ message });
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
58
53
|
setLoading(false);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const clearText = useCallback(() => {
|
|
68
|
-
setEmail('');
|
|
69
|
-
setInvalidEmail(true);
|
|
54
|
+
}
|
|
55
|
+
}, [email]);
|
|
56
|
+
/**
|
|
57
|
+
* Clears email input field
|
|
58
|
+
*/
|
|
59
|
+
const handleClearEmail = useCallback(() => {
|
|
60
|
+
setEmail("");
|
|
61
|
+
setIsEmailValid(false);
|
|
70
62
|
}, []);
|
|
71
63
|
return {
|
|
72
64
|
email,
|
|
73
|
-
|
|
74
|
-
isInvalidEmail,
|
|
65
|
+
isEmailValid,
|
|
75
66
|
loading,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
handleEmailChange,
|
|
68
|
+
handleEmailExists,
|
|
69
|
+
handleClearEmail,
|
|
70
|
+
isLoginConflictModalVisible,
|
|
71
|
+
setIsLoginConflictModalVisible,
|
|
81
72
|
onRegistrationMethodChange,
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
appName: appConfig.appName,
|
|
74
|
+
loginConflictTitle: `Sign in with ${loginType}`,
|
|
75
|
+
loginConflictDescription: `Looks like you previously registered using ${loginType}. Please go back and sign in with ${loginType}.`,
|
|
84
76
|
};
|
|
85
77
|
};
|
|
86
78
|
export { useEnterEmail };
|
|
@@ -1,30 +1,26 @@
|
|
|
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 = ({
|
|
8
|
-
const {
|
|
7
|
+
const EnterEmail = ({ onContinue, onPressSignInWithSSO }) => {
|
|
8
|
+
const { email, isEmailValid, handleEmailChange, appName, handleEmailExists, loading, loginConflictTitle, loginConflictDescription, isLoginConflictModalVisible, setIsLoginConflictModalVisible } = 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: {
|
|
11
11
|
loading,
|
|
12
12
|
label: 'Continue',
|
|
13
13
|
onClick: () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
handleEmailExists({
|
|
15
|
+
onValidate: ({ emailExist }) => onContinue({ email, emailExist })
|
|
16
|
+
});
|
|
17
17
|
},
|
|
18
|
-
disabled:
|
|
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', {
|
|
18
|
+
disabled: !isEmailValid,
|
|
19
|
+
}, 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
20
|
onChange: (e) => {
|
|
25
|
-
|
|
21
|
+
handleEmailChange(e.target.value);
|
|
26
22
|
}
|
|
27
|
-
}) }) }) }),
|
|
28
|
-
_jsx(LoginConflictModal, { title:
|
|
23
|
+
}) }) }) }), isLoginConflictModalVisible &&
|
|
24
|
+
_jsx(LoginConflictModal, { title: loginConflictTitle, description: loginConflictDescription, visible: isLoginConflictModalVisible, onProceed: () => setIsLoginConflictModalVisible(false), onClose: () => setIsLoginConflictModalVisible(false), primaryLabel: 'Okay' })] }), _jsx(Button, { isFullWidth: true, type: "button", label: 'Sign In with SSO', variant: 'secondary', className: 'flex-none mt-6', onClick: onPressSignInWithSSO }), _jsx(SupportDetails, {})] }));
|
|
29
25
|
};
|
|
30
26
|
export default EnterEmail;
|
|
@@ -5,30 +5,27 @@ 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
|
-
const {
|
|
11
|
+
const { email, isEmailValid, handleEmailChange, handleClearEmail, handleEmailExists, loading, loginConflictTitle, loginConflictDescription, isLoginConflictModalVisible, setIsLoginConflictModalVisible } = useEnterEmail();
|
|
12
|
+
const onValidate = (params) => {
|
|
13
|
+
if (params.emailExist) {
|
|
14
|
+
navigation.navigate('EnterPassword', { email });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
navigation.navigate('SignUp', { email });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
11
20
|
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#FFFFFF' }, children: [_jsx(ScreenLayout, { title: "Enter Your Email", buttonProps: {
|
|
12
21
|
loading,
|
|
13
22
|
label: 'Continue',
|
|
14
23
|
onPress: () => {
|
|
15
24
|
Keyboard.dismiss();
|
|
16
|
-
|
|
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
|
-
});
|
|
28
|
-
}
|
|
25
|
+
handleEmailExists({ onValidate });
|
|
29
26
|
},
|
|
30
|
-
disabled:
|
|
31
|
-
}, children: _jsx(TextInputField, { value: email, placeholder: 'Enter here...', onChangeValue:
|
|
32
|
-
_jsx(LoginConflictModal, { title:
|
|
27
|
+
disabled: !isEmailValid,
|
|
28
|
+
}, children: _jsx(TextInputField, { value: email, placeholder: 'Enter here...', onChangeValue: handleEmailChange, rightIcon2: email.length > 0 ? 'close' : '', onPressRightIcon2: handleClearEmail, autoFocus: true, autoCapitalize: 'none', keyboardType: 'email-address' }) }), isLoginConflictModalVisible &&
|
|
29
|
+
_jsx(LoginConflictModal, { title: loginConflictTitle, description: loginConflictDescription, visible: isLoginConflictModalVisible, onProceed: () => setIsLoginConflictModalVisible(false), onClose: () => setIsLoginConflictModalVisible(false), iconColor: utility.warning_main, primaryLabel: 'Okay' })] }));
|
|
33
30
|
};
|
|
34
31
|
export default EnterEmail;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { axiosClient } from '../../../../../../api/axiosClient';
|
|
3
|
+
import { showMessage } from "../../../../../../helpers/show-message";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Internal hook for managing useExistingAccountsSheet hook state and auth context integration. Not exposed to package consumers.
|
|
7
|
+
*/
|
|
8
|
+
const useExistingAccountsSheet = () => {
|
|
9
|
+
const [loading, setLoading] = useState(false);
|
|
10
|
+
const [selectedAccount, setSelectedAccount] = useState(null);
|
|
11
|
+
const linkPrimaryAccount = useCallback(({ phone, onInitiateLinking }) => {
|
|
12
|
+
setLoading(true);
|
|
13
|
+
axiosClient({
|
|
14
|
+
url: '/auth/mobile/link-primary-account/initiate',
|
|
15
|
+
method: 'POST',
|
|
16
|
+
data: {
|
|
17
|
+
phone,
|
|
18
|
+
memberId: selectedAccount?.memberId,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
.then((res) => onInitiateLinking(res.data))
|
|
22
|
+
.catch((error) => {
|
|
23
|
+
console.log(error);
|
|
24
|
+
const message = error?.response?.data?.errors?.[0]?.message ?? 'Unable to initiate linking. Please try again.';
|
|
25
|
+
showMessage({ message });
|
|
26
|
+
})
|
|
27
|
+
.finally(() => setLoading(false));
|
|
28
|
+
}, [selectedAccount]);
|
|
29
|
+
return {
|
|
30
|
+
loading,
|
|
31
|
+
linkPrimaryAccount,
|
|
32
|
+
selectedAccount,
|
|
33
|
+
setSelectedAccount
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export { useExistingAccountsSheet };
|