import React from 'react' import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native' import { Post } from '../models/postModel' type PostComponentProps = { post: Post fetchData: () => void } export const PostComponent: React.FC = ({ post, fetchData }) => { async function approvePost(postID: string) { console.log('Approving post ' + postID) await fetch(`http://localhost:3000/api/v1/posts/${postID}`, { method: 'PATCH', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'approved' }) }).then(() => { fetchData() }) } async function denyPost(postID: string) { console.log('Denying post ' + postID) await fetch(`http://localhost:3000/api/v1/posts/${postID}`, { method: 'PATCH', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'denied' }) }).then(() => { fetchData() }) } return ( {post._id} {post.notes} denyPost(post._id)}> Deny approvePost(post._id)}> Approve ) } const styles = StyleSheet.create({ text: { color: '#fff', justifyContent: 'center' }, posts: { marginTop: 10, backgroundColor: '#363c43ff', padding: 10, width: '90%', borderRadius: 5 } })