mirror of
				https://github.com/Blair-SGA-Dev-Team/blazerapp.git
				synced 2025-11-03 15:21:12 -05:00 
			
		
		
		
	Added announcements page
This commit is contained in:
		
							parent
							
								
									93f0bc8ad9
								
							
						
					
					
						commit
						4b14f130cc
					
				@ -6,6 +6,7 @@ import {
 | 
				
			|||||||
  View,
 | 
					  View,
 | 
				
			||||||
  Text,
 | 
					  Text,
 | 
				
			||||||
  StatusBar,
 | 
					  StatusBar,
 | 
				
			||||||
 | 
					  FlatList,
 | 
				
			||||||
} from 'react-native';
 | 
					} from 'react-native';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -16,11 +17,49 @@ import {
 | 
				
			|||||||
  ReloadInstructions,
 | 
					  ReloadInstructions,
 | 
				
			||||||
} from 'react-native/Libraries/NewAppScreen';
 | 
					} from 'react-native/Libraries/NewAppScreen';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import styles from './styles/liststyles'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const Announcement = ({item}) => {
 | 
				
			||||||
 | 
						return (
 | 
				
			||||||
 | 
							<View style={styles.item}>
 | 
				
			||||||
 | 
								<Text style={styles.title}>{item.item.message}</Text>
 | 
				
			||||||
 | 
							</View>
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Announcements extends React.Component {
 | 
					class Announcements extends React.Component {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						constructor(props) {
 | 
				
			||||||
 | 
							super(props)
 | 
				
			||||||
 | 
							this.state = {
 | 
				
			||||||
 | 
								data: []
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						componentDidMount() {
 | 
				
			||||||
 | 
							fetch('https://6dc2642ae9b3.ngrok.io/api/en/announcements',{
 | 
				
			||||||
 | 
								headers: {
 | 
				
			||||||
 | 
									'Cache-Control': 'no-cache'
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
 | 
							.then((response) => {
 | 
				
			||||||
 | 
								return response.text();
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							.then((json) => {
 | 
				
			||||||
 | 
								this.setState({data: JSON.parse(json).data});
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							.catch((error) => console.error(error))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	render() {
 | 
						render() {
 | 
				
			||||||
		return (
 | 
							return (
 | 
				
			||||||
			<View>
 | 
								<View style={styles.container}>
 | 
				
			||||||
			
 | 
									<FlatList
 | 
				
			||||||
 | 
										data={this.state.data}
 | 
				
			||||||
 | 
										renderItem={item=><Announcement item={item}/>}
 | 
				
			||||||
 | 
										keyExtractor={item=>JSON.stringify(item)}
 | 
				
			||||||
 | 
									/>
 | 
				
			||||||
			</View>
 | 
								</View>
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -56,9 +56,6 @@ class LunchEvents extends React.Component {
 | 
				
			|||||||
			this.setState({data: JSON.parse(json)});
 | 
								this.setState({data: JSON.parse(json)});
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		.catch((error) => console.error(error))
 | 
							.catch((error) => console.error(error))
 | 
				
			||||||
		.finally(() => {
 | 
					 | 
				
			||||||
			this.setState({ isLoading: false });
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	render() {
 | 
						render() {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user