2020-08-22 20:01:15 -04:00
|
|
|
import React, { useState } from 'react';
|
2020-08-09 20:56:12 -04:00
|
|
|
import {
|
|
|
|
SafeAreaView,
|
|
|
|
StyleSheet,
|
|
|
|
ScrollView,
|
|
|
|
View,
|
|
|
|
Text,
|
|
|
|
StatusBar,
|
2020-08-22 20:01:15 -04:00
|
|
|
FlatList,
|
|
|
|
TouchableOpacity,
|
2020-08-09 20:56:12 -04:00
|
|
|
} from 'react-native';
|
|
|
|
|
|
|
|
import {
|
|
|
|
Header,
|
|
|
|
LearnMoreLinks,
|
|
|
|
Colors,
|
|
|
|
DebugInstructions,
|
|
|
|
ReloadInstructions,
|
|
|
|
} from 'react-native/Libraries/NewAppScreen';
|
2020-08-22 20:01:15 -04:00
|
|
|
import styles from './styles/liststyles';
|
|
|
|
import { url } from './resources/fetchInfo.json';
|
|
|
|
|
|
|
|
const SSLElement = ({item}) => {
|
|
|
|
const [visible, setVisible] = useState(0)
|
|
|
|
const extra = visible?(<Text>{'\n'}{item.item.title} {"\n\n"}Details: {item.item.text}{"\n\n"}Where: {item.item.loc}{"\n\n"}Teacher: {item.item.teacher}</Text>):(<></>);
|
|
|
|
return(
|
|
|
|
<View>
|
|
|
|
<TouchableOpacity style={styles.item} onPress={()=>setVisible(!visible)} activeOpacity={0.8}>
|
|
|
|
<Text style={styles.title}>{item.item.name}</Text>
|
|
|
|
{extra}
|
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
2020-08-09 20:56:12 -04:00
|
|
|
|
|
|
|
class SSLOps extends React.Component {
|
2020-08-22 20:01:15 -04:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
|
|
|
data: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
fetch(`${url}/api/en/sslOps`,{
|
|
|
|
headers: {
|
|
|
|
'Cache-Control': 'no-cache'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.then((response) => {
|
|
|
|
console.log(response);
|
|
|
|
return response.text();
|
|
|
|
})
|
|
|
|
.then((json) => {
|
|
|
|
this.setState({data: JSON.parse(json).ops});
|
|
|
|
})
|
|
|
|
.catch((error) => console.error(error))
|
|
|
|
}
|
|
|
|
|
2020-08-09 20:56:12 -04:00
|
|
|
render() {
|
2020-08-22 20:01:15 -04:00
|
|
|
console.log(this.state.data)
|
2020-08-09 20:56:12 -04:00
|
|
|
return (
|
2020-08-22 20:01:15 -04:00
|
|
|
<View style={styles.container}>
|
|
|
|
<FlatList
|
|
|
|
data={this.state.data}
|
|
|
|
renderItem={item=><SSLElement item={item}/>}
|
|
|
|
keyExtractor={item=>JSON.stringify(item)}
|
|
|
|
/>
|
2020-08-09 20:56:12 -04:00
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SSLOps;
|