From 6d31bf277f05c3cef1f280aabda7d2426f8e79a4 Mon Sep 17 00:00:00 2001 From: M10T Date: Fri, 14 Aug 2020 11:57:45 -0400 Subject: [PATCH] Added Challenge of the Week --- app/ChallengeWeek.js | 55 ++++++++++++++++++++++++++++++++++++++++++++ app/Clubs.js | 3 --- app/More.js | 13 ++++++++++- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 app/ChallengeWeek.js diff --git a/app/ChallengeWeek.js b/app/ChallengeWeek.js new file mode 100644 index 0000000..b7f0244 --- /dev/null +++ b/app/ChallengeWeek.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { + SafeAreaView, + StyleSheet, + ScrollView, + View, + Text, + StatusBar, +} from 'react-native'; + +import { + Header, + LearnMoreLinks, + Colors, + DebugInstructions, + ReloadInstructions, +} from 'react-native/Libraries/NewAppScreen'; + +import { url } from './resources/fetchInfo.json' + +class ChallengeWeek extends React.Component { + constructor(props) { + super(props) + this.state = { + isLoading: true + } + } + + componentDidMount() { + fetch(`${url}/api/en/challenge`,{ + headers: { + 'Cache-Control': 'no-cache' + }} + ).then((response) => { + return response.text(); + }).then((json) => { + this.setState({data: JSON.parse(json),isLoading:false}); + }).catch((error) => console.error(error)) + } + + render() { + if (this.state.isLoading) { + return + } else { + return ( + + {this.state.data.title} + {this.state.data.text} + + ) + } + } +} + +export default ChallengeWeek; \ No newline at end of file diff --git a/app/Clubs.js b/app/Clubs.js index d69cc67..c6816c1 100644 --- a/app/Clubs.js +++ b/app/Clubs.js @@ -55,12 +55,9 @@ class Clubs extends React.Component { 'Cache-Control': 'no-cache' } }) .then((response) => { - //console.log(response.text()); return response.text(); }) .then((json) => { - //onsole.log("done bitch?") - //console.log(json); this.setState({data: JSON.parse(json).clubs}); this.setState({dataSearch:JSON.parse(json).clubs }); }) diff --git a/app/More.js b/app/More.js index b34a6fa..9461c46 100644 --- a/app/More.js +++ b/app/More.js @@ -27,6 +27,7 @@ import Resources from './Resources' import StudentWeek from './StudentWeek' import SSLOps from './SSLOps' import LunchEvents from './LunchEvents' +import ChallengeWeek from './ChallengeWeek' import { LinearGradient } from 'react-native-linear-gradient' const Stack = createStackNavigator() @@ -46,7 +47,8 @@ class MoreSwitch extends React.Component { {name:"Resources",key:"resources"}, {name:"Student of the Week",key:"studentweek"}, {name:"Lunch Events",key:"lunchevent"}, - {name:"SSL Opportunities",key:"sslops"} + {name:"SSL Opportunities",key:"sslops"}, + {name:"Challenge of the Week",key:"challengeweek"}, ]} renderItem={({item})=> this.props.navigation.navigate(item.key)}> @@ -118,6 +120,15 @@ class More extends React.Component { headerLeft:null }} /> + )