// ...existing imports... import { apiService } from '../services/api'; // ...existing code... export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => { // ...existing state... const login = async (nationalId: string, password: string) => { try { setIsLoading(true); // Call the real API const user = await apiService.getUserDetails(nationalId, password); // Store user data await AsyncStorage.setItem('user', JSON.stringify(user)); await AsyncStorage.setItem('authToken', user.authToken); setUser(user); } catch (error) { console.error('Login error:', error); throw new Error('Invalid credentials or network error'); } finally { setIsLoading(false); } }; // ...existing code... };