Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions app/(auth)/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
KeyboardAvoidingView,
Platform,
TouchableOpacity,
Image,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useRouter } from 'expo-router';
import { ChevronLeft, Camera } from 'lucide-react-native';
import { ChevronLeft, Camera, AlertCircle, X } from 'lucide-react-native';
import { colors } from '../../constants/colors';
import { Button } from '../../components/shared/Button';
import { Input } from '../../components/shared/Input';
Expand All @@ -31,6 +30,7 @@ export default function RegisterScreen() {

const [displayName, setDisplayName] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
const [submitError, setSubmitError] = useState<string | null>(null);

// Learner fields
const [school, setSchool] = useState('');
Expand All @@ -50,6 +50,7 @@ export default function RegisterScreen() {
const handleComplete = async () => {
if (!isValid) return;
setIsSubmitting(true);
setSubmitError(null);

try {
const profile: LearnerProfile = {
Expand All @@ -68,8 +69,10 @@ export default function RegisterScreen() {
await setTokens('mock-access-token', 'mock-refresh-token');
await setWallet(publicKey ?? '');

} catch {
// Error handled — user stays on screen
} catch (err) {
const message =
err instanceof Error ? err.message : 'An unexpected error occurred while saving your profile.';
setSubmitError(message);
} finally {
setIsSubmitting(false);
}
Expand Down Expand Up @@ -121,6 +124,25 @@ export default function RegisterScreen() {
</Text>
</View>

{/* Error banner */}
{submitError && (
<View
className="rounded-xl p-3 flex-row items-start gap-2 mb-2"
style={{ backgroundColor: colors.errorDim }}
>
<AlertCircle size={16} color={colors.error} style={{ marginTop: 2 }} />
<Text className="text-sm flex-1" style={{ color: colors.error }}>
{submitError}
</Text>
<TouchableOpacity
onPress={() => setSubmitError(null)}
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
>
<X size={16} color={colors.error} />
</TouchableOpacity>
</View>
)}

<View className="flex-col gap-4">
{/* Avatar Upload Area */}
<View className="flex-col items-center justify-center mb-4 mt-2">
Expand Down
1 change: 0 additions & 1 deletion app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default function TabsLayout() {
tabBarIcon: ({ color, size }) => <Calendar color={color} size={size} />,
}}
/>
/>
<Tabs.Screen
name="reputation"
options={{
Expand Down
Loading
Loading