From 4b17ff286037c6bb55cea7329e3123bf4808c797 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Wed, 16 Oct 2024 16:18:13 +0530 Subject: Add LoginScreen with OTP functionality --- src/screens/Auth/LoginScreen.js | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/screens/Auth/LoginScreen.js (limited to 'src/screens/Auth') diff --git a/src/screens/Auth/LoginScreen.js b/src/screens/Auth/LoginScreen.js new file mode 100644 index 0000000..6b11a5b --- /dev/null +++ b/src/screens/Auth/LoginScreen.js @@ -0,0 +1,45 @@ +import React, { useState } from 'react'; +import { View, TextInput, Button, Text } from 'react-native'; +import { login, verifyOtp } from '../../services/authService'; + +const LoginScreen = ({ navigation }) => { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [otp, setOtp] = useState(''); + const [isOtpSent, setIsOtpSent] = useState(false); + + const handleLogin = async () => { + try { + const response = await login(email, password); + if (response.data.otpSent) setIsOtpSent(true); + } catch (error) { + console.error('Login error:', error); + } + }; + + const verifyOtp = async () => { + try { + const response = await verifyOtp(email, otp); + if (response.data.success) navigation.navigate('MallSelection'); + } catch (error) { + console.error('OTP verification error:', error); + } + }; + + return ( + + + +