Initial commit
This commit is contained in:
34
screens/UsersScreen.tsx
Normal file
34
screens/UsersScreen.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { View, Text, FlatList, StyleSheet } from 'react-native';
|
||||
import { apiService } from '../services/api';
|
||||
|
||||
export default function UsersScreen({ filter }: { filter: string }) {
|
||||
const [users, setUsers] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
apiService.getUsers().then(setUsers);
|
||||
}, []);
|
||||
|
||||
const filtered = users.filter((u: any) => u.name.toLowerCase().includes(filter.toLowerCase()));
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<FlatList
|
||||
data={filtered}
|
||||
keyExtractor={(item: any) => item.id.toString()}
|
||||
renderItem={({ item }: any) => (
|
||||
<View style={styles.item}>
|
||||
<Text style={styles.name}>{item.name}</Text>
|
||||
<Text>{item.email}</Text>
|
||||
</View>
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, padding: 16 },
|
||||
item: { padding: 16, borderBottomWidth: 1 },
|
||||
name: { fontWeight: 'bold' },
|
||||
});
|
||||
Reference in New Issue
Block a user