import { useState } from 'react'; import { StyleSheet, Text, View, TextInput, Button, ScrollView, ActivityIndicator } from 'react-native'; import JecnaapiReactNative from 'jecnaapi-react-native'; export default function App() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [result, setResult] = useState('No data yet. Please login.'); const handleTestLoginAndFetch = async () => { if (!username || !password) { setResult('Error: Enter username and password'); return; } setLoading(true); setResult('Logging in...'); try { // 1. Call the raw native Kotlin bridge const loginSuccess = await JecnaapiReactNative.login(username, password); if (loginSuccess) { setResult('Login Successful! Fetching profile...'); // 2. Fetch the raw JSON string const rawProfileString = await JecnaapiReactNative.getStudentProfile(); // 3. Manually parse it (since you kept the default export) const profile = JSON.parse(rawProfileString); // Display it nicely on screen setResult(JSON.stringify(profile, null, 2)); } else { setResult('Login failed. Check credentials.'); } } catch (error: any) { setResult(`Bridge Error: ${error.message}`); } finally { setLoading(false); } }; return ( JecnaAPI Native Tester