Skip to content

Commit eb061d9

Browse files
committed
fix: fixed phone number country code issue
1 parent 5c0f3a5 commit eb061d9

4 files changed

Lines changed: 62 additions & 83 deletions

File tree

frontend/app/(tabs)/_layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Tabs } from 'expo-router';
33
export default function TabLayout() {
44
return (
55
<Tabs screenOptions={{ headerShown: false }}>
6-
<Tabs.Screen name="home" options={{ title: 'Home' }} />
7-
<Tabs.Screen name="search" options={{ title: 'Search' }} />
8-
<Tabs.Screen name="events" options={{ title: 'Events' }} />
6+
<Tabs.Screen name="home/index" options={{ title: 'Home' }} />
7+
<Tabs.Screen name="search/index" options={{ title: 'Search' }} />
8+
<Tabs.Screen name="events/index" options={{ title: 'Events' }} />
99
<Tabs.Screen name="events/[id]" options={{ href: null }} />
10-
<Tabs.Screen name="profile" options={{ title: 'Profile' }} />
10+
<Tabs.Screen name="profile/index" options={{ title: 'Profile' }} />
1111
</Tabs>
1212
);
1313
}

frontend/app/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function RootLayout() {
88

99
useEffect(() => {
1010
async function loadIntro() {
11-
const value = await AsyncStorage.getItem('hasSeenInto');
11+
const value = await AsyncStorage.getItem('hasSeenIntro');
1212
setHasSeenIntro(value === 'true');
1313
}
1414
loadIntro();
Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import {
2-
View,
3-
Text,
4-
TextInput,
5-
StyleSheet,
6-
Pressable,
7-
} from "react-native";
8-
import { SafeAreaView } from "react-native-safe-area-context";
9-
import { useState } from "react";
10-
import { useRouter } from "expo-router";
11-
import { verifyOtp } from "@/services/auth/otp.service";
12-
import { useLocalSearchParams } from "expo-router/build/hooks";
1+
import { View, Text, TextInput, StyleSheet, Pressable } from 'react-native';
2+
import { SafeAreaView } from 'react-native-safe-area-context';
3+
import { useState } from 'react';
4+
import { useRouter } from 'expo-router';
5+
import { verifyOtp } from '@/services/auth/otp.service';
6+
import { useLocalSearchParams } from 'expo-router/build/hooks';
137

148
export default function OtpScreen() {
15-
const [otp, setOtp] = useState("");
9+
const [otp, setOtp] = useState('');
1610
const [loading, setLoading] = useState(false);
1711
const router = useRouter();
1812
const { phone } = useLocalSearchParams();
@@ -27,10 +21,10 @@ export default function OtpScreen() {
2721
if (!res?.success) return;
2822

2923
if (res.userExists) {
30-
router.replace("/(tabs)/home");
24+
router.replace('/(tabs)/home');
3125
} else {
3226
router.replace({
33-
pathname: "/(auth)/register",
27+
pathname: '/(auth)/register',
3428
params: {
3529
otpId: res.otpId,
3630
phoneNumber: phone.toString(),
@@ -46,10 +40,8 @@ export default function OtpScreen() {
4640
<Text style={styles.title}>Enter OTP</Text>
4741

4842
<Text style={styles.description}>
49-
We’ve sent a one-time password to{" "}
50-
<Text style={styles.phone}>
51-
{phone}
52-
</Text>
43+
We’ve sent a one-time password to{' '}
44+
<Text style={styles.phone}>{phone}</Text>
5345
</Text>
5446

5547
<TextInput
@@ -65,20 +57,18 @@ export default function OtpScreen() {
6557
<Pressable
6658
style={[
6759
styles.button,
68-
(otp.length < 4 || loading) &&
69-
styles.buttonDisabled,
60+
(otp.length < 4 || loading) && styles.buttonDisabled,
7061
]}
7162
onPress={handleVerify}
7263
disabled={otp.length < 4 || loading}
7364
>
7465
<Text style={styles.buttonText}>
75-
{loading ? "Verifying..." : "Verify OTP"}
66+
{loading ? 'Verifying...' : 'Verify OTP'}
7667
</Text>
7768
</Pressable>
7869

7970
<Text style={styles.resend}>
80-
Didn’t receive OTP?{" "}
81-
<Text style={styles.resendLink}>Resend</Text>
71+
Didn’t receive OTP? <Text style={styles.resendLink}>Resend</Text>
8272
</Text>
8373
</View>
8474
</View>
@@ -88,7 +78,7 @@ export default function OtpScreen() {
8878
const styles = StyleSheet.create({
8979
safeArea: {
9080
flex: 1,
91-
backgroundColor: "#EAF5EC",
81+
backgroundColor: '#EAF5EC',
9282
},
9383

9484
container: {
@@ -98,30 +88,30 @@ const styles = StyleSheet.create({
9888

9989
content: {
10090
flex: 1,
101-
justifyContent: "center",
91+
justifyContent: 'center',
10292
},
10393

10494
title: {
10595
fontSize: 24,
106-
fontWeight: "700",
107-
color: "#111",
96+
fontWeight: '700',
97+
color: '#111',
10898
marginBottom: 8,
10999
},
110100

111101
description: {
112102
fontSize: 14,
113-
color: "#555",
103+
color: '#555',
114104
lineHeight: 20,
115105
marginBottom: 32,
116106
},
117107

118108
phone: {
119-
fontWeight: "600",
120-
color: "#111",
109+
fontWeight: '600',
110+
color: '#111',
121111
},
122112

123113
otpInput: {
124-
backgroundColor: "#FFF",
114+
backgroundColor: '#FFF',
125115
borderRadius: 16,
126116
height: 56,
127117
fontSize: 20,
@@ -130,10 +120,10 @@ const styles = StyleSheet.create({
130120
},
131121

132122
button: {
133-
backgroundColor: "#000",
123+
backgroundColor: '#000',
134124
paddingVertical: 16,
135125
borderRadius: 16,
136-
alignItems: "center",
126+
alignItems: 'center',
137127
marginBottom: 16,
138128
},
139129

@@ -142,19 +132,19 @@ const styles = StyleSheet.create({
142132
},
143133

144134
buttonText: {
145-
color: "#FFF",
135+
color: '#FFF',
146136
fontSize: 16,
147-
fontWeight: "600",
137+
fontWeight: '600',
148138
},
149139

150140
resend: {
151-
textAlign: "center",
141+
textAlign: 'center',
152142
fontSize: 13,
153-
color: "#555",
143+
color: '#555',
154144
},
155145

156146
resendLink: {
157-
fontWeight: "600",
158-
color: "#000",
147+
fontWeight: '600',
148+
color: '#000',
159149
},
160150
});
Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
1-
import {
2-
View,
3-
Text,
4-
TextInput,
5-
StyleSheet,
6-
Pressable,
7-
} from "react-native";
8-
import { SafeAreaView } from "react-native-safe-area-context";
9-
import { useState } from "react";
10-
import { router } from "expo-router";
11-
import { sendOtp } from "@/services/auth/otp.service";
1+
import { View, Text, TextInput, StyleSheet, Pressable } from 'react-native';
2+
import { SafeAreaView } from 'react-native-safe-area-context';
3+
import { useState } from 'react';
4+
import { router } from 'expo-router';
5+
import { sendOtp } from '@/services/auth/otp.service';
126

137
export default function PhoneScreen() {
14-
const [phone, setPhone] = useState("");
8+
const [phone, setPhone] = useState('');
159

16-
const handleContinue = async() => {
10+
const handleContinue = async () => {
1711
if (!phone) return;
18-
const res = await sendOtp(phone)
12+
const fullPhoneNumber = `+91${phone}`;
13+
const res = await sendOtp(fullPhoneNumber);
1914

20-
if(res.success){
15+
if (res.success) {
2116
router.push({
22-
pathname: "/(auth)/otp",
23-
params: { phone },
17+
pathname: '/(auth)/otp',
18+
params: { phone:fullPhoneNumber },
2419
});
2520
}
26-
2721
};
2822

2923
return (
3024
<SafeAreaView style={styles.safeArea}>
3125
<View style={styles.container}>
32-
3326
<View style={styles.content}>
3427
<Text style={styles.title}>Enter your phone number</Text>
3528

@@ -45,16 +38,12 @@ export default function PhoneScreen() {
4538
keyboardType="phone-pad"
4639
value={phone}
4740
onChangeText={setPhone}
48-
maxLength={13}
41+
maxLength={10}
4942
/>
5043
</View>
5144

52-
5345
<Pressable
54-
style={[
55-
styles.button,
56-
!phone && styles.buttonDisabled,
57-
]}
46+
style={[styles.button, !phone && styles.buttonDisabled]}
5847
onPress={handleContinue}
5948
disabled={!phone}
6049
>
@@ -68,7 +57,7 @@ export default function PhoneScreen() {
6857
const styles = StyleSheet.create({
6958
safeArea: {
7059
flex: 1,
71-
backgroundColor: "#EAF5EC",
60+
backgroundColor: '#EAF5EC',
7261
},
7362

7463
container: {
@@ -78,27 +67,27 @@ const styles = StyleSheet.create({
7867

7968
content: {
8069
flex: 1,
81-
justifyContent: "center",
70+
justifyContent: 'center',
8271
},
8372

8473
title: {
8574
fontSize: 24,
86-
fontWeight: "700",
87-
color: "#111",
75+
fontWeight: '700',
76+
color: '#111',
8877
marginBottom: 8,
8978
},
9079

9180
description: {
9281
fontSize: 14,
93-
color: "#555",
82+
color: '#555',
9483
lineHeight: 20,
9584
marginBottom: 24,
9685
},
9786

9887
inputWrapper: {
99-
flexDirection: "row",
100-
alignItems: "center",
101-
backgroundColor: "#FFF",
88+
flexDirection: 'row',
89+
alignItems: 'center',
90+
backgroundColor: '#FFF',
10291
borderRadius: 14,
10392
paddingHorizontal: 14,
10493
height: 52,
@@ -107,7 +96,7 @@ const styles = StyleSheet.create({
10796

10897
countryCode: {
10998
fontSize: 16,
110-
fontWeight: "600",
99+
fontWeight: '600',
111100
marginRight: 8,
112101
},
113102

@@ -117,19 +106,19 @@ const styles = StyleSheet.create({
117106
},
118107

119108
button: {
120-
backgroundColor: "#000",
109+
backgroundColor: '#000',
121110
paddingVertical: 16,
122111
borderRadius: 16,
123-
alignItems: "center",
112+
alignItems: 'center',
124113
},
125114

126115
buttonDisabled: {
127116
opacity: 0.5,
128117
},
129118

130119
buttonText: {
131-
color: "#FFF",
120+
color: '#FFF',
132121
fontSize: 16,
133-
fontWeight: "600",
122+
fontWeight: '600',
134123
},
135124
});

0 commit comments

Comments
 (0)