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)}>