diff --git a/app/Staff.js b/app/Staff.js
index 79dbf8f..2901ee1 100644
--- a/app/Staff.js
+++ b/app/Staff.js
@@ -6,6 +6,7 @@ import {
View,
Text,
StatusBar,
+ ActivityIndicator,
FlatList,
TouchableOpacity
} from 'react-native';
@@ -17,62 +18,87 @@ import {
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
-
-import { url } from './resources/fetchInfo.json'
+import { SearchBar } from 'react-native-elements';
import styles from './styles/liststyles'
+import { url } from './resources/fetchInfo.json'
-const TeacherElement = ({item}) => {
+const StaffElement = ({item}) => {
+ console.log(item)
const [visible, setVisible] = useState(0)
- const extra = [...item.item.emails.map(email=>(Email: {email}))]
+ const extra = visible?({'\n'}Email: {item.item.emails}):(<>>);
return(
setVisible(!visible)} activeOpacity={0.8}>
{item.item.name}
- {visible?extra:<>>}
+ {extra}
)
}
-
class Staff extends React.Component {
-
+
+
constructor(props) {
- super(props)
- this.state = {
- isLoading: true
- }
- }
-
- componentDidMount() {
- fetch(`${url}/api/en/teachers`,{
- headers: {
- 'Cache-Control': 'no-cache'
- }
- }
- )
- .then((response) => {
- return response.text();
- })
- .then((json) => {
- this.setState({data: JSON.parse(json).data});
- })
- .catch((error) => console.error(error))
- .finally(()=>this.setState({isLoading:false}))
- }
-
- render() {
- if(this.state.isLoading) return ()
-
- return (
-
- }
- keyExtractor={(item,index)=>JSON.stringify(item)+index}
- />
-
- )
- }
+ super(props);
+
+ this.state = {
+ data: [],
+ dataSearch:[],
+ isLoading: true,
+ search:""
+ };
+ }
+
+ componentDidMount() {
+
+ fetch(`${url}/api/en/teachers`,{
+ headers: {
+ 'Cache-Control': 'no-cache'
+ } })
+ .then((response) => {
+ return response.text();
+ })
+ .then((json) => {
+ this.setState({data: JSON.parse(json).data[0].staff});
+ this.setState({dataSearch:JSON.parse(json).data[0].staff});
+ })
+ .catch((error) => console.error(error))
+ .finally(() => {
+ this.setState({ isLoading: false });
+ });
+
+ }
+ updateSearch = (search) => {
+ this.setState({ search:search });
+ const searchPool = search.startsWith(this.state.search)?this.state.dataSearch:this.state.data;
+ const ds = searchPool.filter((thing)=>{return thing.name.toLowerCase().startsWith(search.toLowerCase())})
+ this.setState({dataSearch: ds})
+ };
+ clearSearch = (search)=>{
+ const ds = this.state.data;
+ this.setState({dataSearch:ds})
+ }
+ render() {
+ const { data , dataSearch, isLoading,search} = this.state;
+ console.log(data)
+
+ return (
+
+
+ }
+ keyExtractor={item => JSON.stringify(item)}
+ />
+
+ );
+ }
}
export default Staff;
\ No newline at end of file
diff --git a/app/styles/liststyles.js b/app/styles/liststyles.js
index ba1885c..2281e4b 100644
--- a/app/styles/liststyles.js
+++ b/app/styles/liststyles.js
@@ -10,6 +10,7 @@ const styles = StyleSheet.create({
padding: 20,
marginVertical: 8,
marginHorizontal: 16,
+ borderRadius: 8,
},
title: {
fontSize: 32,