adding picture display with cloudfront and working on ios take photo and post flow

This commit is contained in:
Will Baumbach
2025-07-30 16:24:09 -05:00
parent 913c4cf3f7
commit e49674a755
9 changed files with 13524 additions and 13450 deletions

View File

@@ -4,19 +4,18 @@ import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import { Post } from '../models/postModel'
export default function PostsScreen() {
const cloudfrontURL = process.env.CLOUDFRONT_URL
const [posts, setPosts] = useState<Post[]>()
useFocusEffect(
React.useCallback(() => {
// Do something when the screen is focused
// TODO: add endpoint to get only non approved or denied status posts
fetch('http://localhost:3000/api/v1/posts')
fetch('http://localhost:3000/api/v1/posts/status/created')
.then((res) => res.json())
.then((json) => {
console.log(json)
setPosts(json.data)
});
})
return () => {
// Do something when the screen is unfocused
// Useful for cleanup functions
@@ -55,54 +54,79 @@ export default function PostsScreen() {
}
return (
<View style={styles.container}>
<Text style={styles.text}>Posts</Text>
<View style={{ width: '90%', marginTop: 200 }}></View>
{
posts && posts.map(el => (
<View key={el._id} style={styles.posts}>
<Text style={{ color: '#fff' }}>{el._id}</Text>
<View style={{ alignItems: 'center', marginVertical: 10 }}>
<Image
source={{ uri: el.photo }}
style={{ width: 200, height: 200, borderRadius: 8 }}
resizeMode="cover"
/>
<View style={styles.wrapper}>
<View style={styles.container}>
<Text style={styles.text}>Posts</Text>
{posts &&
posts.map((el) => (
<View key={el._id} style={styles.posts}>
<Text style={styles.text}>{el._id}</Text>
<View style={{ alignItems: 'center', marginVertical: 10 }}>
<Image
source={{ uri: el.photo }}
style={{ width: 200, height: 200, borderRadius: 8 }}
resizeMode='cover'
/>
</View>
<Text style={{ color: '#fff' }}>{el.notes}</Text>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 10 }}>
<TouchableOpacity style={{ flex: 1, marginRight: 5 }} onPress={() => denyPost(el._id)}>
<Text
style={{
backgroundColor: '#bf3636ff',
color: '#fff',
textAlign: 'center',
padding: 8,
borderRadius: 4
}}
>
Deny
</Text>
</TouchableOpacity>
<TouchableOpacity
style={{ flex: 1, marginLeft: 5 }}
onPress={() => approvePost(el._id)}
>
<Text
style={{
backgroundColor: '#17be3bff',
color: '#fff',
textAlign: 'center',
padding: 8,
borderRadius: 4
}}
>
Approve
</Text>
</TouchableOpacity>
</View>
</View>
<Text style={{ color: '#fff' }}>{el.notes}</Text>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginTop: 10 }}>
<TouchableOpacity style={{ flex: 1, marginRight: 5 }} onPress={() => denyPost(el._id)}>
<Text style={{ backgroundColor: '#bf3636ff', color: '#fff', textAlign: 'center', padding: 8, borderRadius: 4 }}>
Deny
</Text>
</TouchableOpacity>
<TouchableOpacity style={{ flex: 1, marginLeft: 5 }} onPress={() => approvePost(el._id)}>
<Text style={{ backgroundColor: '#17be3bff', color: '#fff', textAlign: 'center', padding: 8, borderRadius: 4 }}>
Approve
</Text>
</TouchableOpacity>
</View>
</View>
))
}
))}
</View>
</View>
)
}
const styles = StyleSheet.create({
container: {
wrapper: {
flex: 1,
backgroundColor: '#25292e',
justifyContent: 'center',
padding: 5
},
container: {
flex: 1,
alignItems: 'center',
overflow: 'scroll'
},
text: {
color: '#fff'
color: '#fff',
justifyContent: 'center'
},
posts: {
marginBottom: 10,
marginTop: 10,
backgroundColor: '#363c43ff',
padding: 10
padding: 10,
width: '90%',
borderRadius: 5
}
})