@truworth/twc-auth 1.1.0 → 1.2.1
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 +239 -306
- package/build/assets/animation/redirect-home.json +1101 -0
- package/build/assets/cross_icon copy.svg +5 -0
- package/build/assets/cross_icon.svg +5 -0
- package/build/assets/gender-diversity.svg +22 -0
- package/build/assets/logo.svg +55 -0
- package/build/assets/okay_icon copy.svg +3 -0
- package/build/assets/okay_icon.svg +3 -0
- package/build/src/api/axiosClient/index.js +5 -0
- package/build/src/api/axiosClient/index.native.js +5 -0
- package/build/src/components/AdvancedTransitionWrapper/index.js +380 -0
- package/build/src/components/AdvancedTransitionWrapper/index.native.js +10 -0
- package/build/src/components/AdvancedTransitionWrapper/types.js +1 -0
- package/build/src/components/ConfirmationModal/index.js +11 -0
- package/build/src/components/ConfirmationModal/index.native.js +15 -0
- package/build/src/components/ConfirmationModal/types.js +1 -0
- package/build/src/components/EmailOTPVerify/index.js +20 -0
- package/build/src/components/EmailOTPVerify/index.native.js +26 -0
- package/build/src/components/EmailOTPVerify/type.js +1 -0
- package/build/src/components/IonIcon/index.js +11 -0
- package/build/src/components/IonIcon/index.native.js +9 -0
- package/build/src/components/IonIcon/types.js +1 -0
- package/build/src/components/OTPStatusLabel/index.js +10 -0
- package/build/src/components/OTPStatusLabel/index.native.js +21 -0
- package/build/src/components/OTPStatusLabel/types.js +1 -0
- package/build/src/components/PasswordCriteria/hooks/usePasswordCriteria.js +78 -0
- package/build/src/components/PasswordCriteria/index.js +47 -0
- package/build/src/components/PasswordCriteria/index.native.js +19 -0
- package/build/src/components/PasswordCriteria/types.js +1 -0
- package/build/src/components/ScreenLayout/index.js +12 -0
- package/build/src/components/ScreenLayout/index.native.js +18 -0
- package/build/src/components/ScreenLayout/types.js +1 -0
- package/build/src/components/SupportDetails/index.js +9 -0
- package/build/src/components/SupportDetails/index.native.js +6 -0
- package/build/src/components/VerifyOTP/index.js +23 -0
- package/build/src/components/VerifyOTP/index.native.js +38 -0
- package/build/src/components/VerifyOTP/types.js +1 -0
- package/build/src/constants/cdn-url/index.js +1 -0
- package/build/src/constants/cdn-url/index.native.js +5 -0
- package/build/src/contexts/AuthContext.js +184 -0
- package/build/src/contexts/type.js +1 -0
- package/build/src/helpers/Network.js +93 -0
- package/build/src/helpers/Validation.js +12 -0
- package/build/src/helpers/show-message/index.js +19 -0
- package/build/src/helpers/show-message/index.native.js +14 -0
- package/build/src/helpers/show-message/types.js +1 -0
- package/build/src/helpers/types.js +1 -0
- package/build/src/hooks/internal/useAuthPackageContext.js +9 -0
- package/build/src/hooks/internal/useTimer.js +40 -0
- package/build/src/hooks/useAuthContext.js +10 -0
- package/build/src/hooks/useRequest.js +38 -0
- package/build/src/index.js +12 -0
- package/build/src/navigator/index.js +10 -0
- package/build/src/navigator/index.native.js +16 -0
- package/build/src/screens/CountryCode/components/CountryCodeDropdown/index.js +38 -0
- package/build/src/screens/CountryCode/components/CountryCodeDropdown/index.native.js +6 -0
- package/build/src/screens/CountryCode/components/CountryCodeDropdown/types.js +1 -0
- package/build/src/screens/CountryCode/hooks/internal/useCountryCode.js +38 -0
- package/build/src/screens/CountryCode/index.js +10 -0
- package/build/src/screens/CountryCode/index.native.js +37 -0
- package/build/src/screens/CountryCode/type.js +1 -0
- package/build/src/screens/CreatePassword/hooks/internal/useCreatePassword.js +52 -0
- package/build/src/screens/CreatePassword/index.js +43 -0
- package/build/src/screens/CreatePassword/index.native.js +32 -0
- package/build/src/screens/CreatePassword/type.js +1 -0
- package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +86 -0
- package/build/src/screens/EnterEmail/index.js +30 -0
- package/build/src/screens/EnterEmail/index.native.js +34 -0
- package/build/src/screens/EnterPassword/hooks/internal/useEnterPassword.js +47 -0
- package/build/src/screens/EnterPassword/index.js +22 -0
- package/build/src/screens/EnterPassword/index.native.js +23 -0
- package/build/src/screens/EnterPassword/types.js +1 -0
- package/build/src/screens/Login/components/LoginWebComponent/index.js +44 -0
- package/build/src/screens/Login/components/LoginWebComponent/index.native.js +6 -0
- package/build/src/screens/Login/index.js +10 -0
- package/build/src/screens/Login/index.native.js +6 -0
- package/build/src/screens/SignUp/components/SignUpForm/index.js +181 -0
- package/build/src/screens/SignUp/components/SignUpForm/index.native.js +6 -0
- package/build/src/screens/SignUp/components/SignUpForm/type.js +1 -0
- package/build/src/screens/SignUp/components/SignUpWebComponent/index.js +82 -0
- package/build/src/screens/SignUp/components/SignUpWebComponent/index.native.js +6 -0
- package/build/src/screens/SignUp/components/SignUpWebComponent/types.js +1 -0
- package/build/src/screens/SignUp/hooks/internal/useSignUp.js +138 -0
- package/build/src/screens/SignUp/index.js +6 -0
- package/build/src/screens/SignUp/index.native.js +185 -0
- package/build/src/screens/SignUp/types.js +1 -0
- package/build/src/screens/UserConsent/hooks/internal/useConsent.js +48 -0
- package/build/src/screens/UserConsent/index.js +69 -0
- package/build/src/screens/UserConsent/index.native.js +46 -0
- package/build/src/screens/UserConsent/types.js +1 -0
- package/build/src/screens/VerifyEmail/hooks/internal/useVerifyEmail.js +69 -0
- package/build/src/screens/VerifyEmail/index.js +8 -0
- package/build/src/screens/VerifyEmail/index.native.js +14 -0
- package/build/src/screens/VerifyEmail/types.js +1 -0
- package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +73 -0
- package/build/src/screens/VerifyMobile/index.js +8 -0
- package/build/src/screens/VerifyMobile/index.native.js +9 -0
- package/build/src/screens/VerifyMobile/types.js +1 -0
- package/build/src/screens/Welcome/hooks/internal/useWelcome.js +21 -0
- package/build/src/screens/Welcome/index.js +28 -0
- package/build/src/screens/Welcome/index.native.js +41 -0
- package/build/src/types/types.js +1 -0
- package/build/types/api/axiosClient/index.d.ts +1 -0
- package/build/types/api/axiosClient/index.native.d.ts +1 -0
- package/build/types/components/AdvancedTransitionWrapper/index.d.ts +3 -0
- package/build/types/components/AdvancedTransitionWrapper/index.native.d.ts +5 -0
- package/build/types/components/AdvancedTransitionWrapper/types.d.ts +25 -0
- package/build/types/components/ConfirmationModal/index.d.ts +3 -0
- package/build/types/components/ConfirmationModal/index.native.d.ts +3 -0
- package/build/types/components/ConfirmationModal/types.d.ts +13 -0
- package/build/types/components/EmailOTPVerify/index.d.ts +3 -0
- package/build/types/components/EmailOTPVerify/index.native.d.ts +3 -0
- package/build/types/components/EmailOTPVerify/type.d.ts +9 -0
- package/build/types/components/IonIcon/index.d.ts +3 -0
- package/build/types/components/IonIcon/index.native.d.ts +4 -0
- package/build/types/components/IonIcon/types.d.ts +6 -0
- package/build/types/components/OTPStatusLabel/index.d.ts +2 -0
- package/build/types/components/OTPStatusLabel/index.native.d.ts +3 -0
- package/build/types/components/OTPStatusLabel/types.d.ts +6 -0
- package/build/types/components/PasswordCriteria/hooks/usePasswordCriteria.d.ts +13 -0
- package/build/types/components/PasswordCriteria/index.d.ts +3 -0
- package/build/types/components/PasswordCriteria/index.native.d.ts +3 -0
- package/build/types/components/PasswordCriteria/types.d.ts +15 -0
- package/build/types/components/ScreenLayout/index.d.ts +3 -0
- package/build/types/components/ScreenLayout/index.native.d.ts +3 -0
- package/build/types/components/ScreenLayout/types.d.ts +12 -0
- package/build/types/components/SupportDetails/index.d.ts +2 -0
- package/build/types/components/SupportDetails/index.native.d.ts +2 -0
- package/build/types/components/VerifyOTP/index.d.ts +3 -0
- package/build/types/components/VerifyOTP/index.native.d.ts +3 -0
- package/build/types/components/VerifyOTP/types.d.ts +10 -0
- package/build/types/constants/cdn-url/index.d.ts +1 -0
- package/build/types/constants/cdn-url/index.native.d.ts +3 -0
- package/build/types/contexts/AuthContext.d.ts +36 -0
- package/build/types/contexts/type.d.ts +58 -0
- package/build/types/helpers/Network.d.ts +5 -0
- package/build/types/helpers/Validation.d.ts +2 -0
- package/build/types/helpers/show-message/index.d.ts +3 -0
- package/build/types/helpers/show-message/index.native.d.ts +3 -0
- package/build/types/helpers/show-message/types.d.ts +2 -0
- package/build/types/helpers/types.d.ts +13 -0
- package/build/types/hooks/internal/useAuthPackageContext.d.ts +1 -0
- package/build/types/hooks/internal/useTimer.d.ts +3 -0
- package/build/types/hooks/useAuthContext.d.ts +2 -0
- package/build/types/hooks/useRequest.d.ts +5 -0
- package/build/types/index.d.ts +8 -0
- package/build/types/navigator/index.d.ts +2 -0
- package/build/types/navigator/index.native.d.ts +36 -0
- package/build/types/screens/CountryCode/components/CountryCodeDropdown/index.d.ts +3 -0
- package/build/types/screens/CountryCode/components/CountryCodeDropdown/index.native.d.ts +2 -0
- package/build/types/screens/CountryCode/components/CountryCodeDropdown/types.d.ts +17 -0
- package/build/types/screens/CountryCode/hooks/internal/useCountryCode.d.ts +12 -0
- package/build/types/screens/CountryCode/index.d.ts +2 -0
- package/build/types/screens/CountryCode/index.native.d.ts +2 -0
- package/build/types/screens/CountryCode/type.d.ts +11 -0
- package/build/types/screens/CreatePassword/hooks/internal/useCreatePassword.d.ts +26 -0
- package/build/types/screens/CreatePassword/index.d.ts +3 -0
- package/build/types/screens/CreatePassword/index.native.d.ts +4 -0
- package/build/types/screens/CreatePassword/type.d.ts +43 -0
- package/build/types/screens/EnterEmail/hooks/internal/useEnterEmail.d.ts +24 -0
- package/build/types/screens/EnterEmail/index.d.ts +7 -0
- package/build/types/screens/EnterEmail/index.native.d.ts +4 -0
- package/build/types/screens/EnterPassword/hooks/internal/useEnterPassword.d.ts +20 -0
- package/build/types/screens/EnterPassword/index.d.ts +3 -0
- package/build/types/screens/EnterPassword/index.native.d.ts +4 -0
- package/build/types/screens/EnterPassword/types.d.ts +5 -0
- package/build/types/screens/Login/components/LoginWebComponent/index.d.ts +2 -0
- package/build/types/screens/Login/components/LoginWebComponent/index.native.d.ts +2 -0
- package/build/types/screens/Login/index.d.ts +2 -0
- package/build/types/screens/Login/index.native.d.ts +2 -0
- package/build/types/screens/SignUp/components/SignUpForm/index.d.ts +3 -0
- package/build/types/screens/SignUp/components/SignUpForm/index.native.d.ts +2 -0
- package/build/types/screens/SignUp/components/SignUpForm/type.d.ts +9 -0
- package/build/types/screens/SignUp/components/SignUpWebComponent/index.d.ts +2 -0
- package/build/types/screens/SignUp/components/SignUpWebComponent/index.native.d.ts +2 -0
- package/build/types/screens/SignUp/components/SignUpWebComponent/types.d.ts +24 -0
- package/build/types/screens/SignUp/hooks/internal/useSignUp.d.ts +50 -0
- package/build/types/screens/SignUp/index.d.ts +2 -0
- package/build/types/screens/SignUp/index.native.d.ts +4 -0
- package/build/types/screens/SignUp/types.d.ts +18 -0
- package/build/types/screens/UserConsent/hooks/internal/useConsent.d.ts +10 -0
- package/build/types/screens/UserConsent/index.d.ts +3 -0
- package/build/types/screens/UserConsent/index.native.d.ts +4 -0
- package/build/types/screens/UserConsent/types.d.ts +27 -0
- package/build/types/screens/VerifyEmail/hooks/internal/useVerifyEmail.d.ts +19 -0
- package/build/types/screens/VerifyEmail/index.d.ts +3 -0
- package/build/types/screens/VerifyEmail/index.native.d.ts +4 -0
- package/build/types/screens/VerifyEmail/types.d.ts +8 -0
- package/build/types/screens/VerifyMobile/hooks/internal/useVerifyMobile.d.ts +14 -0
- package/build/types/screens/VerifyMobile/index.d.ts +3 -0
- package/build/types/screens/VerifyMobile/index.native.d.ts +4 -0
- package/build/types/screens/VerifyMobile/types.d.ts +5 -0
- package/build/types/screens/Welcome/hooks/internal/useWelcome.d.ts +14 -0
- package/build/types/screens/Welcome/index.d.ts +4 -0
- package/build/types/screens/Welcome/index.native.d.ts +4 -0
- package/build/types/types/types.d.ts +90 -0
- package/get-metro-config.js +40 -0
- package/get-next-config.js +26 -0
- package/package.json +86 -38
- package/dist/index.esm.js +0 -2028
- package/dist/index.umd.js +0 -70
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { showMessage } from "../../../../helpers/show-message";
|
|
3
|
+
import { useInterval } from "../../../../hooks/internal/useTimer";
|
|
4
|
+
import { axiosClient } from "../../../../api/axiosClient";
|
|
5
|
+
import { useAuthPackageContext } from "../../../../hooks/internal/useAuthPackageContext";
|
|
6
|
+
const initialTimer = 180;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Hook for managing VerifyMobile screen state and auth context integration.
|
|
10
|
+
* This hook is not exposed to package consumers.
|
|
11
|
+
*/
|
|
12
|
+
const useVerifyMobile = ({ sessionToken }) => {
|
|
13
|
+
const [sessionTokenState, setSessionToken] = useState(sessionToken || '');
|
|
14
|
+
const [timer, setTimer] = useState(initialTimer);
|
|
15
|
+
const [status, setStatus] = useState('timer');
|
|
16
|
+
const { onLogin } = useAuthPackageContext();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
resendOTP();
|
|
19
|
+
}, []);
|
|
20
|
+
useInterval(() => {
|
|
21
|
+
if (!timer) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setTimer(timer - 1);
|
|
25
|
+
}, 1000);
|
|
26
|
+
const resendOTP = useCallback(() => {
|
|
27
|
+
setStatus('loading');
|
|
28
|
+
axiosClient({
|
|
29
|
+
url: '/auth/registration/mobile/send-otp',
|
|
30
|
+
method: 'POST',
|
|
31
|
+
data: { sessionToken: sessionTokenState },
|
|
32
|
+
}).then((res) => {
|
|
33
|
+
setSessionToken(res.data.sessionToken);
|
|
34
|
+
setStatus('timer');
|
|
35
|
+
setTimer(initialTimer);
|
|
36
|
+
}).catch((err) => {
|
|
37
|
+
console.log(err);
|
|
38
|
+
const msg = err?.response?.data?.errors?.[0]?.message ?? 'Unable to send OTP. Please try again.';
|
|
39
|
+
showMessage(msg);
|
|
40
|
+
setStatus('timer');
|
|
41
|
+
});
|
|
42
|
+
}, [sessionTokenState]);
|
|
43
|
+
const validateOTP = useCallback((otp) => {
|
|
44
|
+
setStatus('loading');
|
|
45
|
+
axiosClient({
|
|
46
|
+
url: '/auth/registration/mobile/verify-otp',
|
|
47
|
+
method: 'POST',
|
|
48
|
+
data: { otp, sessionToken: sessionTokenState },
|
|
49
|
+
}).then((res) => {
|
|
50
|
+
setStatus('valid');
|
|
51
|
+
const { token, member } = res.data;
|
|
52
|
+
onLogin({ token, member });
|
|
53
|
+
}).catch((err) => {
|
|
54
|
+
if (err?.response?.status === 400) {
|
|
55
|
+
setStatus('invalid');
|
|
56
|
+
setTimeout(() => setStatus('timer'), 5000);
|
|
57
|
+
showMessage(err?.response?.data?.errors?.[0]?.message ?? 'Invalid OTP. Please try again.');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const msg = err?.response?.data?.errors?.[0]?.message ?? 'Verification failed. Please try again.';
|
|
61
|
+
showMessage(msg);
|
|
62
|
+
setStatus('timer');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}, [sessionTokenState]);
|
|
66
|
+
return {
|
|
67
|
+
timer,
|
|
68
|
+
status,
|
|
69
|
+
resendOTP,
|
|
70
|
+
validateOTP
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export { useVerifyMobile };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OTPVerify } from "../../components/VerifyOTP";
|
|
3
|
+
import { useVerifyMobile } from "./hooks/internal/useVerifyMobile";
|
|
4
|
+
const VerifyMobile = ({ sessionToken, phone }) => {
|
|
5
|
+
const { timer, status, validateOTP, resendOTP, } = useVerifyMobile({ sessionToken });
|
|
6
|
+
return (_jsx(OTPVerify, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
|
|
7
|
+
};
|
|
8
|
+
export default VerifyMobile;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OTPVerify } from '../../components/VerifyOTP';
|
|
3
|
+
import { useVerifyMobile } from './hooks/internal/useVerifyMobile';
|
|
4
|
+
const VerifyMobile = ({ route }) => {
|
|
5
|
+
const { sessionToken, phone } = route.params || {};
|
|
6
|
+
const { timer, status, validateOTP, resendOTP, } = useVerifyMobile({ sessionToken });
|
|
7
|
+
return (_jsx(OTPVerify, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
|
|
8
|
+
};
|
|
9
|
+
export default VerifyMobile;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useAuthContext } from "../../../../hooks/useAuthContext";
|
|
3
|
+
import { useAuthPackageContext } from "../../../../hooks/internal/useAuthPackageContext";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Hook for managing Welcome screen state and auth context integration.
|
|
7
|
+
* This hook is not exposed to package consumers.
|
|
8
|
+
*/
|
|
9
|
+
const useWelcome = () => {
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [showSocialLoginModal, setShowSocialLoginModal] = useState(false);
|
|
12
|
+
const { LogoComponent, onLaunchAuthSession } = useAuthPackageContext();
|
|
13
|
+
return {
|
|
14
|
+
loading,
|
|
15
|
+
setLoading,
|
|
16
|
+
showSocialLoginModal, setShowSocialLoginModal,
|
|
17
|
+
LogoComponent,
|
|
18
|
+
onLaunchAuthSession
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { useWelcome };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Image from "next/image";
|
|
4
|
+
import { CDN_IMAGES_URL, IonIcon } from "@truworth/twc-web-common";
|
|
5
|
+
import { Button, Flex, Typography } from "@truworth/twc-web-design";
|
|
6
|
+
import { AdvancedTransitionWrapper } from "../../components/AdvancedTransitionWrapper";
|
|
7
|
+
import { useWelcome } from "./hooks/internal/useWelcome";
|
|
8
|
+
const Welcome = ({ onClickEnterEmail }) => {
|
|
9
|
+
const { LogoComponent } = useWelcome();
|
|
10
|
+
const renderLogo = () => {
|
|
11
|
+
if (!LogoComponent) {
|
|
12
|
+
return (_jsx(Image, { alt: "Truworth Wellness logo", width: 160, height: 35, className: 'md:mt-0 mt-6 md:h-[40px] h-[30px]', src: `${CDN_IMAGES_URL}/new-twc_logo.svg` }));
|
|
13
|
+
}
|
|
14
|
+
// If it's already a React element, return it as is
|
|
15
|
+
if (React.isValidElement(LogoComponent)) {
|
|
16
|
+
return LogoComponent;
|
|
17
|
+
}
|
|
18
|
+
// If it's a function component, render it
|
|
19
|
+
if (typeof LogoComponent === 'function') {
|
|
20
|
+
const Component = LogoComponent;
|
|
21
|
+
return _jsx(Component, {});
|
|
22
|
+
}
|
|
23
|
+
// Fallback to default logo
|
|
24
|
+
return (_jsx(Image, { alt: "Truworth Wellness logo", width: 160, height: 35, className: 'md:mt-0 mt-6 md:h-[40px] h-[30px]', src: `${CDN_IMAGES_URL}/new-twc_logo.svg` }));
|
|
25
|
+
};
|
|
26
|
+
return (_jsx(AdvancedTransitionWrapper, { type: 'slide', duration: 0.3, children: _jsxs(Flex, { justify: 'center', align: "center", direction: 'column', className: 'h-screen w-[80%] mx-auto gap-6', children: [renderLogo(), _jsxs(Flex, { justify: "center", align: "center", direction: "column", className: 'gap-2', children: [_jsx(Typography, { type: 'heading', size: 'h5', className: 'text-center text-[#1A1A1A] font-semibold', children: "Welcome!" }), _jsx(Typography, { type: 'utility', size: 'large', color: "gray-400", className: 'text-center font-semibold', children: "Select an option to proceed" })] }), _jsx(Button, { label: "Enter Your Email", variant: "secondary", onClick: onClickEnterEmail, leftIcon: _jsx(IonIcon, { name: "mail", style: { fontSize: 20 } }), isFullWidth: true })] }) }));
|
|
27
|
+
};
|
|
28
|
+
export default Welcome;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
4
|
+
import { View, Text, BackHandler, ScrollView } from 'react-native';
|
|
5
|
+
import { Colors, LoadingModal, RoundedButton } from '@truworth/twc-rn-common';
|
|
6
|
+
import { Layout } from '@ui-kitten/components';
|
|
7
|
+
import { useWelcome } from './hooks/internal/useWelcome';
|
|
8
|
+
import Logo from '../../../assets/logo.svg';
|
|
9
|
+
const { gray } = Colors;
|
|
10
|
+
const Welcome = ({ navigation }) => {
|
|
11
|
+
const { loading, LogoComponent, onLaunchAuthSession } = useWelcome();
|
|
12
|
+
useFocusEffect(useCallback(() => {
|
|
13
|
+
onLaunchAuthSession?.();
|
|
14
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', () => true);
|
|
15
|
+
return () => backHandler.remove();
|
|
16
|
+
}, []));
|
|
17
|
+
const renderLogo = () => {
|
|
18
|
+
if (!LogoComponent) {
|
|
19
|
+
return (_jsx(View, { style: { marginTop: 70, alignSelf: 'center' }, children: _jsx(Logo, {}) }));
|
|
20
|
+
}
|
|
21
|
+
// If it's already a React element, return it as is
|
|
22
|
+
if (React.isValidElement(LogoComponent)) {
|
|
23
|
+
return LogoComponent;
|
|
24
|
+
}
|
|
25
|
+
// If it's a function component, render it
|
|
26
|
+
if (typeof LogoComponent === 'function') {
|
|
27
|
+
const Component = LogoComponent;
|
|
28
|
+
return _jsx(Component, {});
|
|
29
|
+
}
|
|
30
|
+
// Fallback to default logo
|
|
31
|
+
return (_jsx(View, { style: { marginTop: 70, alignSelf: 'center' }, children: _jsx(Logo, {}) }));
|
|
32
|
+
};
|
|
33
|
+
return (_jsxs(Layout, { style: { flex: 1, backgroundColor: '#FFFFFF' }, children: [_jsx(ScrollView, { showsVerticalScrollIndicator: false, children: _jsxs(View, { style: { padding: 16 }, children: [renderLogo(), _jsx(Text, { style: {
|
|
34
|
+
fontSize: 32, fontWeight: '600', color: gray.gray_900,
|
|
35
|
+
marginTop: 56, textAlign: 'center', lineHeight: 48,
|
|
36
|
+
}, children: "Welcome!" }), _jsx(Text, { style: {
|
|
37
|
+
fontSize: 16, fontWeight: '500', color: gray.gray_400,
|
|
38
|
+
marginTop: 4, lineHeight: 24, textAlign: 'center',
|
|
39
|
+
}, children: "Select an option to proceed" }), _jsx(View, { style: { marginTop: 48 }, children: _jsx(RoundedButton, { type: "secondary", label: "Enter Your Email", leftIcon: "mail", size: "large", onPress: () => navigation.navigate('EnterEmail') }) })] }) }), _jsx(LoadingModal, { loading: loading })] }));
|
|
40
|
+
};
|
|
41
|
+
export default Welcome;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const axiosClient: import("axios").AxiosInstance;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const axiosClient: import("axios").AxiosInstance;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AdvancedTransitionWrapperProps } from './types';
|
|
2
|
+
declare const AdvancedTransitionWrapper: ({ children, isVisible, direction, type, duration, delay, className, staggerChildren, staggerDelay, exitBeforeEnter, bounce, damping, mass, velocity, depth, perspective, intensity, customEnterVariants, customExitVariants, }: AdvancedTransitionWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export { AdvancedTransitionWrapper };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type AdvancedTransitionDirection = 'up' | 'down' | 'left' | 'right';
|
|
3
|
+
type AdvancedTransitionType = 'slide' | 'fade' | 'scale' | 'rotate' | 'flip' | 'elastic' | 'spring' | 'glide' | 'zoom' | 'blur';
|
|
4
|
+
interface AdvancedTransitionWrapperProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
isVisible?: boolean;
|
|
7
|
+
direction?: AdvancedTransitionDirection;
|
|
8
|
+
type?: AdvancedTransitionType;
|
|
9
|
+
duration?: number;
|
|
10
|
+
delay?: number;
|
|
11
|
+
className?: string;
|
|
12
|
+
staggerChildren?: boolean;
|
|
13
|
+
staggerDelay?: number;
|
|
14
|
+
exitBeforeEnter?: boolean;
|
|
15
|
+
bounce?: number;
|
|
16
|
+
damping?: number;
|
|
17
|
+
mass?: number;
|
|
18
|
+
velocity?: number;
|
|
19
|
+
depth?: number;
|
|
20
|
+
perspective?: number;
|
|
21
|
+
intensity?: number;
|
|
22
|
+
customEnterVariants?: any;
|
|
23
|
+
customExitVariants?: any;
|
|
24
|
+
}
|
|
25
|
+
export type { AdvancedTransitionDirection, AdvancedTransitionType, AdvancedTransitionWrapperProps };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ConfirmationModalProps } from './types';
|
|
2
|
+
declare const ConfirmationModal: ({ title, visible, onClose, onProceed, onDismiss, primaryLabel, secondaryLabel, iconName, iconColor, description }: ConfirmationModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export { ConfirmationModal };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ConfirmationModalProps } from './types';
|
|
2
|
+
declare const ConfirmationModal: ({ title, visible, onClose, onProceed, onDismiss, primaryLabel, secondaryLabel, iconName, iconColor, description }: ConfirmationModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export { ConfirmationModal };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ConfirmationModalProps = {
|
|
2
|
+
title: string;
|
|
3
|
+
visible: boolean;
|
|
4
|
+
primaryLabel: string;
|
|
5
|
+
secondaryLabel?: string;
|
|
6
|
+
iconName?: string;
|
|
7
|
+
iconColor?: string;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onProceed?: () => void;
|
|
10
|
+
onDismiss?: () => void;
|
|
11
|
+
description?: string;
|
|
12
|
+
};
|
|
13
|
+
export type { ConfirmationModalProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OTPStatus } from "../OTPStatusLabel/types";
|
|
2
|
+
type EmailOTPVerifyProps = {
|
|
3
|
+
validateOTP: (otp: string) => void | Promise<void>;
|
|
4
|
+
resendOTP: () => void | Promise<void>;
|
|
5
|
+
resendOTPCounter: number;
|
|
6
|
+
email?: string;
|
|
7
|
+
status: OTPStatus | string;
|
|
8
|
+
};
|
|
9
|
+
export type { EmailOTPVerifyProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UsePasswordCriteriaProps } from "../types";
|
|
2
|
+
declare const usePasswordCriteria: ({ email, password, onCriteriaChange, onMaxLengthChange }: UsePasswordCriteriaProps) => {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
passwordPolicy: {
|
|
5
|
+
minLength: number;
|
|
6
|
+
numbers: boolean;
|
|
7
|
+
uppercase: boolean;
|
|
8
|
+
lowercase: boolean;
|
|
9
|
+
specialCharacters: boolean;
|
|
10
|
+
};
|
|
11
|
+
renderLabel: (criteria: string) => string;
|
|
12
|
+
};
|
|
13
|
+
export { usePasswordCriteria };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
interface PasswordCriteriaProps {
|
|
3
|
+
email: string;
|
|
4
|
+
password: string;
|
|
5
|
+
criteria: Record<string, boolean>;
|
|
6
|
+
onCriteriaChange: Dispatch<SetStateAction<Record<string, boolean>>>;
|
|
7
|
+
onMaxLengthChange: Dispatch<SetStateAction<number>>;
|
|
8
|
+
}
|
|
9
|
+
interface UsePasswordCriteriaProps {
|
|
10
|
+
email: string;
|
|
11
|
+
password: string;
|
|
12
|
+
onCriteriaChange: Dispatch<SetStateAction<Record<string, boolean>>>;
|
|
13
|
+
onMaxLengthChange: Dispatch<SetStateAction<number>>;
|
|
14
|
+
}
|
|
15
|
+
export type { PasswordCriteriaProps, UsePasswordCriteriaProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ViewStyle } from "react-native";
|
|
2
|
+
interface ScreenLayoutProps {
|
|
3
|
+
title: React.ReactNode;
|
|
4
|
+
subTitle?: React.ReactNode;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
buttonProps?: any;
|
|
7
|
+
hideHeader?: boolean;
|
|
8
|
+
containerStyle?: ViewStyle;
|
|
9
|
+
accessoryRight?: React.ReactElement;
|
|
10
|
+
onPressBack?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export type { ScreenLayoutProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OTPStatus } from "../OTPStatusLabel/types";
|
|
2
|
+
interface OTPVerifyProps {
|
|
3
|
+
validateOTP: (otp: string) => void;
|
|
4
|
+
timer: number;
|
|
5
|
+
status: OTPStatus | string;
|
|
6
|
+
resendOTP: () => void;
|
|
7
|
+
phone?: string;
|
|
8
|
+
resendTextClassName?: string;
|
|
9
|
+
}
|
|
10
|
+
export type { OTPVerifyProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MEMBER_IMAGES_URL } from "@truworth/twc-web-common";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AuthContextProps, AuthContextValue, AuthPackageContextValue } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* Public Auth Authentication Context
|
|
5
|
+
*
|
|
6
|
+
* Exposed to consumers of the Auth package.
|
|
7
|
+
* Provides access to user profile, client info, logout, and helper utilities.
|
|
8
|
+
*/
|
|
9
|
+
declare const AuthContext: React.Context<AuthContextValue | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Package Auth Authentication Context
|
|
12
|
+
*
|
|
13
|
+
* Not meant for public use. Contains lower-level auth state such as
|
|
14
|
+
* token, login/logout functions, and refresh session.
|
|
15
|
+
*/
|
|
16
|
+
declare const AuthPackageContext: React.Context<AuthPackageContextValue | null>;
|
|
17
|
+
/**
|
|
18
|
+
* AuthProvider
|
|
19
|
+
*
|
|
20
|
+
* Provides authentication state and actions to children.
|
|
21
|
+
* Wraps both AuthContext (public) and AuthPackageContext (internal).
|
|
22
|
+
*
|
|
23
|
+
* @param children - React children to be rendered inside the provider
|
|
24
|
+
* @param LogoComponent - Optional component for branding/logo in auth flows
|
|
25
|
+
* @param session - Initial session containing token & sessionTimeout (if available)
|
|
26
|
+
* @param supportEmail - Optional support email for auth flows
|
|
27
|
+
* @param appConfig - Optional app config for auth flows
|
|
28
|
+
* @param onLogin - Optional callback after successful login
|
|
29
|
+
* @param onLogout - Optional callback after successful logout
|
|
30
|
+
* @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.
|
|
31
|
+
* @param onRefreshSession - Optional handler for refreshing user session
|
|
32
|
+
*/
|
|
33
|
+
declare const AuthProvider: ({ children, LogoComponent, session, appConfig, onLogin, onLogout, onLaunchAuthSession, onRefreshSession }: AuthContextProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export { AuthProvider };
|
|
35
|
+
export default AuthContext;
|
|
36
|
+
export { AuthPackageContext };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ClientProfile, MemberProfile, Profile, Partner, RegistrationMethod } from '../types/types';
|
|
3
|
+
interface LoginResponse {
|
|
4
|
+
token: string;
|
|
5
|
+
member?: MemberProfile;
|
|
6
|
+
}
|
|
7
|
+
interface RefreshSessionResponse {
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
interface AppConfig {
|
|
11
|
+
appName?: string;
|
|
12
|
+
supportEmail?: string;
|
|
13
|
+
privacyPolicyUrl?: string;
|
|
14
|
+
termsAndConditionsUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
interface AuthContextProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
LogoComponent?: React.ComponentType | React.ReactElement;
|
|
19
|
+
session: {
|
|
20
|
+
token: string;
|
|
21
|
+
sessionTimeout?: boolean;
|
|
22
|
+
};
|
|
23
|
+
appConfig?: AppConfig;
|
|
24
|
+
onLogin: (result: LoginResponse) => void;
|
|
25
|
+
onLogout: () => Promise<any>;
|
|
26
|
+
onRefreshSession?: (result: RefreshSessionResponse) => Promise<void>;
|
|
27
|
+
onLaunchAuthSession?: () => void;
|
|
28
|
+
}
|
|
29
|
+
interface AuthContextValue {
|
|
30
|
+
isLoadingProfile?: boolean;
|
|
31
|
+
member?: MemberProfile | null;
|
|
32
|
+
client?: ClientProfile | null;
|
|
33
|
+
logout: () => Promise<any>;
|
|
34
|
+
onLaunchAuthSession?: () => void;
|
|
35
|
+
getUserProfile?: () => Promise<any>;
|
|
36
|
+
onOtpReceived?: (otp: string) => void;
|
|
37
|
+
}
|
|
38
|
+
interface AuthPackageContextValue {
|
|
39
|
+
token: string;
|
|
40
|
+
LogoComponent?: React.ComponentType | React.ReactElement;
|
|
41
|
+
appConfig: AppConfig;
|
|
42
|
+
onTokenChange: (token: string) => void;
|
|
43
|
+
onLogin: (result: LoginResponse) => void;
|
|
44
|
+
logout: () => void;
|
|
45
|
+
refreshSession?: (result: RefreshSessionResponse) => Promise<void>;
|
|
46
|
+
onLaunchAuthSession?: () => void;
|
|
47
|
+
registrationMethod: RegistrationMethod;
|
|
48
|
+
onRegistrationMethodChange: (method: RegistrationMethod) => void;
|
|
49
|
+
otpValue?: string;
|
|
50
|
+
}
|
|
51
|
+
interface AuthConfigResponse {
|
|
52
|
+
profile: Profile;
|
|
53
|
+
config: any;
|
|
54
|
+
screenRecording: boolean;
|
|
55
|
+
isInternational: boolean;
|
|
56
|
+
defaultCircle: any;
|
|
57
|
+
}
|
|
58
|
+
export type { LoginResponse, AuthContextProps, AuthContextValue, MemberProfile, ClientProfile, AuthConfigResponse, Profile, Partner, AuthPackageContextValue, RefreshSessionResponse };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NetworkProps } from './types';
|
|
2
|
+
import type { BaseRequestOptions } from '../types/types';
|
|
3
|
+
export declare const createHttpClient: ({ token, onRefreshSession, onLogout }: NetworkProps) => {
|
|
4
|
+
request: ({ url, method, data, ...axiosOptions }: BaseRequestOptions) => Promise<unknown>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RefreshSessionResponse } from "../contexts/type";
|
|
2
|
+
import type { AxiosRequestConfig } from "axios";
|
|
3
|
+
interface RequestOptionsProps extends AxiosRequestConfig {
|
|
4
|
+
token?: string;
|
|
5
|
+
logout: () => Promise<any>;
|
|
6
|
+
refreshSession: (result: RefreshSessionResponse) => Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
interface NetworkProps {
|
|
9
|
+
token: string;
|
|
10
|
+
onRefreshSession?: (token: string) => Promise<any>;
|
|
11
|
+
onLogout?: () => Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
export type { RequestOptionsProps, NetworkProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAuthPackageContext: () => import("../..").AuthPackageContextValue;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './contexts/AuthContext';
|
|
2
|
+
export { default as AuthContext } from './contexts/AuthContext';
|
|
3
|
+
export * from './contexts/type';
|
|
4
|
+
export * from './hooks/useAuthContext';
|
|
5
|
+
export * from './hooks/useRequest';
|
|
6
|
+
export * from './navigator';
|
|
7
|
+
export * from './screens/Login/components/LoginWebComponent';
|
|
8
|
+
export * from './screens/SignUp/components/SignUpWebComponent';
|