2025-07-26 22:05:27 -05:00
|
|
|
import { useFocusEffect } from 'expo-router'
|
|
|
|
|
import React, { useState } from 'react'
|
2025-08-05 16:44:14 -05:00
|
|
|
import { StyleSheet, Text, View } from 'react-native'
|
2025-08-08 00:49:33 -05:00
|
|
|
import { CompactPostComponent } from '../../components/CompactPostComponent'
|
|
|
|
|
import { Post } from '../../models/postModel'
|
2025-07-26 22:05:27 -05:00
|
|
|
|
2025-08-07 23:28:05 -05:00
|
|
|
// TODO:
|
|
|
|
|
// Overhaul posts display to use compact posts - once you click in you should see
|
|
|
|
|
// all the details provided by the user as well as buttons to approve or deny.
|
|
|
|
|
// Eventually I will also add the user to this page so the reviewer can click into
|
|
|
|
|
// the posters account and see their history. I would like to make a point system as well.
|
|
|
|
|
// When the buttons are pressed the user will be prompted to enter information
|
|
|
|
|
// on WHY the post was approved or denied.
|
|
|
|
|
|
2025-08-08 00:49:33 -05:00
|
|
|
export default function OverviewScreen() {
|
2025-07-26 22:05:27 -05:00
|
|
|
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
|
2025-08-05 10:22:48 -05:00
|
|
|
fetchData()
|
2025-07-26 22:05:27 -05:00
|
|
|
return () => {
|
|
|
|
|
// Do something when the screen is unfocused
|
|
|
|
|
// Useful for cleanup functions
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-05 10:22:48 -05:00
|
|
|
async function fetchData() {
|
|
|
|
|
fetch('http://localhost:3000/api/v1/posts/status/created')
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((json) => {
|
|
|
|
|
setPosts(json.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-26 22:05:27 -05:00
|
|
|
return (
|
2025-07-30 16:24:09 -05:00
|
|
|
<View style={styles.wrapper}>
|
2025-08-06 13:36:47 -05:00
|
|
|
<Text style={styles.title}>Posts</Text>
|
|
|
|
|
{posts?.length ? (
|
2025-08-08 00:49:33 -05:00
|
|
|
posts.map((el) => <CompactPostComponent key={el._id} {...el} />)
|
2025-08-06 13:36:47 -05:00
|
|
|
) : (
|
|
|
|
|
<View style={styles.caughtUpContainer}>
|
|
|
|
|
<Text style={styles.caughtUpText}>All caught up!</Text>
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
2025-07-26 22:05:27 -05:00
|
|
|
</View>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2025-07-30 16:24:09 -05:00
|
|
|
wrapper: {
|
2025-07-26 22:05:27 -05:00
|
|
|
flex: 1,
|
2025-08-06 13:36:47 -05:00
|
|
|
backgroundColor: '#25292e',
|
|
|
|
|
padding: 16,
|
2025-07-26 22:05:27 -05:00
|
|
|
alignItems: 'center',
|
|
|
|
|
overflow: 'scroll'
|
|
|
|
|
},
|
2025-08-06 13:36:47 -05:00
|
|
|
title: {
|
2025-07-30 16:24:09 -05:00
|
|
|
color: '#fff',
|
|
|
|
|
justifyContent: 'center'
|
2025-07-26 22:05:27 -05:00
|
|
|
},
|
|
|
|
|
posts: {
|
2025-07-30 16:24:09 -05:00
|
|
|
marginTop: 10,
|
2025-07-26 22:05:27 -05:00
|
|
|
backgroundColor: '#363c43ff',
|
2025-07-30 16:24:09 -05:00
|
|
|
padding: 10,
|
|
|
|
|
width: '90%',
|
|
|
|
|
borderRadius: 5
|
2025-08-05 10:22:48 -05:00
|
|
|
},
|
|
|
|
|
caughtUpContainer: {
|
|
|
|
|
flex: 1,
|
|
|
|
|
alignContent: 'center',
|
|
|
|
|
justifyContent: 'center'
|
|
|
|
|
},
|
|
|
|
|
caughtUpText: {
|
|
|
|
|
color: '#787b80ff'
|
2025-07-26 22:05:27 -05:00
|
|
|
}
|
|
|
|
|
})
|