diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx index e9cdf092..0c17c777 100644 --- a/src/context/AuthContext.tsx +++ b/src/context/AuthContext.tsx @@ -4,19 +4,25 @@ import { loggedInUserType } from './type'; type authContextProviderType = { loggedInUserData: loggedInUserType | null; + goalsData: loggedInUserType | null; isLoading: boolean; setIsLoading: () => void; setLoggedInUserData: (userData: loggedInUserType | null) => void; + setGoalsData: (userData: loggedInUserType | null) => void; }; export const AuthContext = React.createContext({ isLoading: false, loggedInUserData: null, + goalsData: null, setIsLoading: () => { return; }, setLoggedInUserData: () => { return; }, + setGoalsData: () => { + return; + }, }); type authProviderProps = { diff --git a/src/context/type.ts b/src/context/type.ts index 222f8e86..d6ec28c3 100644 --- a/src/context/type.ts +++ b/src/context/type.ts @@ -3,6 +3,11 @@ export type loggedInUserType = { name: string; profileUrl: string; status: string; + twitter_id?: string; + linkedin_id?: string; + github_id: string; + username: string; + token: string; }; export interface User { diff --git a/src/react-native-walkthrough-tooltip.d.ts b/src/react-native-walkthrough-tooltip.d.ts new file mode 100644 index 00000000..3812f8eb --- /dev/null +++ b/src/react-native-walkthrough-tooltip.d.ts @@ -0,0 +1,20 @@ +declare module 'react-native-walkthrough-tooltip' { + import React from 'react'; + import { GestureResponderEvent, ViewStyle } from 'react-native'; + + export interface TooltipProps { + isVisible?: boolean; + content?: React.ReactElement; + placement?: 'top' | 'bottom' | 'left' | 'right' | 'center'; + onClose?: (event: GestureResponderEvent) => void; + closeOnContentInteraction?: boolean; + closeOnBackgroundInteraction?: boolean; + backgroundStyle?: ViewStyle; + contentStyle?: ViewStyle; + tooltipStyle?: ViewStyle; + arrowStyle?: ViewStyle; + children?: React.ReactNode; + } + + export default function Tooltip(props: TooltipProps): JSX.Element; +} diff --git a/src/screens/AuthScreen/AuthScreen.tsx b/src/screens/AuthScreen/AuthScreen.tsx index 2528fd75..825fb918 100644 --- a/src/screens/AuthScreen/AuthScreen.tsx +++ b/src/screens/AuthScreen/AuthScreen.tsx @@ -19,20 +19,25 @@ import { AuthContext } from '../../context/AuthContext'; import { getUserData, goalsAuth, requestCameraPermission } from './Util'; import { storeData } from '../../utils/dataStore'; import AuthApis from '../../constants/apiConstant/AuthApi'; -// import { AuthApisStaging } from '../../constants/apiConstant/AuthApi'; -import { CameraScreen } from 'react-native-camera-kit'; +import { Camera } from 'react-native-camera-kit'; import CustomModal from '../../components/Modal/CustomModal'; import LoadingScreen from '../../components/LoadingScreen'; import Tooltip from 'react-native-walkthrough-tooltip'; import { useSelector } from 'react-redux'; -// import Github from '../../constants/images/Image'; import Images from '../../constants/images/Image'; import GithubSvg from '../../../assets/svgs/github_logo.js'; import WebSvg from '../../../assets/svgs/web'; +type RootState = { + localFeatureFlag: { + isProdEnvironment: boolean; + }; +}; const baseUrl = AuthApis.GITHUB_AUTH_API; const AuthScreen = () => { - const { isProdEnvironment } = useSelector((store) => store.localFeatureFlag); + const { isProdEnvironment } = useSelector( + (store: RootState) => store.localFeatureFlag, + ); const { setLoggedInUserData, setGoalsData } = useContext(AuthContext); const [loading, setLoading] = useState(false); const [cameraActive, setCameraActive] = useState(false); @@ -45,7 +50,7 @@ const AuthScreen = () => { redirectURL: 'https://realdevsquad.com/', }; - function buildUrl(url, params) { + function buildUrl(url: string, params: { [key: string]: string }) { const queryString = Object.keys(params) .map((key) => `${key}=${params[key]}`) .join('&'); @@ -59,7 +64,7 @@ const AuthScreen = () => { Platform.OS !== 'android' || requestCameraPermission(); Linking.getInitialURL(); - const handleDeepLink = async (event) => { + const handleDeepLink = async (event: { url: string }) => { const token = event.url.split('token=')[1]; token && updateUserData(token); // store token in redux }; @@ -143,8 +148,6 @@ const AuthScreen = () => { const qrCodeLogin = async () => { const deviceId = await DeviceInfo.getUniqueId(); - // const url = `${AuthApis.QR_AUTH_API}?device_id=${deviceId}` - const url = isProdEnvironment ? `${AuthApis.QR_AUTH_API}?device_id=${deviceId}` : `${AuthApis.QR_AUTH_API_STAGING}?device_id=${deviceId}`; @@ -220,7 +223,8 @@ const AuthScreen = () => { console.log(err, 'Error QR login'); Toast.show({ type: 'error', - text1: err, + text1: + (err as Error).message || 'Something went wrong, please try again', position: 'bottom', bottomOffset: 80, }); @@ -274,23 +278,9 @@ const AuthScreen = () => { - - {/* { - isProdEnvironment - ? dispatch({ type: 'DEV' }) - : dispatch({ type: 'PROD' }); - }} - > - - - {isProdEnvironment ? 'Switch to DEV' : 'Switch to Prod'} - - - */} {cameraActive && ( -