aboutsummaryrefslogtreecommitdiffstats
path: root/src/screens
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:18:13 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-10-16 16:18:13 +0530
commit4b17ff286037c6bb55cea7329e3123bf4808c797 (patch)
treeb39f9d6ffc9a7547140011e5891e8816c216ebde /src/screens
parentf9af2a7f47dc23ff138a226b5b3cedf1f50d0776 (diff)
downloadmall-app-4b17ff286037c6bb55cea7329e3123bf4808c797.tar.gz
mall-app-4b17ff286037c6bb55cea7329e3123bf4808c797.tar.bz2
mall-app-4b17ff286037c6bb55cea7329e3123bf4808c797.zip
Add LoginScreen with OTP functionality
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/Auth/LoginScreen.js45
1 files changed, 45 insertions, 0 deletions
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 (
+ <View>
+ <TextInput placeholder="Email" value={email} onChangeText={setEmail} />
+ <TextInput placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry />
+ <Button title="Login" onPress={handleLogin} />
+
+ {isOtpSent && (
+ <View>
+ <TextInput placeholder="Enter OTP" value={otp} onChangeText={setOtp} />
+ <Button title="Verify OTP" onPress={verifyOtp} />
+ </View>
+ )}
+ </View>
+ );
+};
+
+export default LoginScreen;