From 913c4cf3f7fa00bd3b0bfbd1fa2a6104f0c0e356 Mon Sep 17 00:00:00 2001 From: Will Baumbach Date: Wed, 30 Jul 2025 13:44:37 -0500 Subject: [PATCH] adding display of all posts in posts tab --- app/(tabs)/posts.tsx | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/app/(tabs)/posts.tsx b/app/(tabs)/posts.tsx index 09dfcbb..9d50464 100644 --- a/app/(tabs)/posts.tsx +++ b/app/(tabs)/posts.tsx @@ -1,6 +1,6 @@ import { useFocusEffect } from 'expo-router' import React, { useState } from 'react' -import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' +import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native' import { Post } from '../models/postModel' export default function PostsScreen() { @@ -24,25 +24,51 @@ export default function PostsScreen() { }, []) ) - function approvePost(postID: string) { + async function approvePost(postID: string) { // add code to update post to approved status 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' + }) + }) } - function denyPost(postID: string) { + async function denyPost(postID: string) { // add code to update post to remove status 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' + }) + }) } return ( Posts - + { posts && posts.map(el => ( {el._id} + + + {el.notes} denyPost(el._id)}>