From 6dfe544e1d1b9df5bbc23dbe24fcc356c9c00444 Mon Sep 17 00:00:00 2001 From: Will Baumbach Date: Thu, 7 Aug 2025 23:23:46 -0500 Subject: [PATCH] changing post display on profile to a more compact display that eventually you will be able to click into for more details - I think i will do the same on the posts page and have the admins enter information about why the post was approved or denied --- app/(tabs)/home.tsx | 17 +++--- app/(tabs)/profile.tsx | 4 +- app/components/CompactPostComponent.tsx | 73 +++++++++++++++++++++++++ app/components/PostComponent.tsx | 9 +-- app/models/postModel.ts | 2 + 5 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 app/components/CompactPostComponent.tsx diff --git a/app/(tabs)/home.tsx b/app/(tabs)/home.tsx index aece044..74054a4 100644 --- a/app/(tabs)/home.tsx +++ b/app/(tabs)/home.tsx @@ -97,7 +97,7 @@ export default function App() { Retake - Continue + Submit @@ -142,8 +142,7 @@ const styles = StyleSheet.create({ flex: 1, backgroundColor: '#25292e', justifyContent: 'center', - paddingHorizontal: 25, - paddingVertical: 200 + padding: 32 }, centeredView: { flex: 1, @@ -198,16 +197,18 @@ const styles = StyleSheet.create({ flex: 1 }, buttonContainer: { - flex: 0.2, flexDirection: 'row', - backgroundColor: 'orange', + justifyContent: 'space-evenly', marginTop: 15, borderRadius: 5 }, button: { - flex: 1, - alignSelf: 'center', - alignItems: 'center' + paddingHorizontal: 12, + height: 50, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: 'rgb(192, 196, 199)', + borderRadius: 5 }, text: { fontSize: 24, diff --git a/app/(tabs)/profile.tsx b/app/(tabs)/profile.tsx index 0afde3c..324d697 100644 --- a/app/(tabs)/profile.tsx +++ b/app/(tabs)/profile.tsx @@ -2,7 +2,7 @@ import { useUser } from '@clerk/clerk-react' import { useFocusEffect } from 'expo-router' import React, { useState } from 'react' import { Image, StyleSheet, Text, View } from 'react-native' -import { PostComponent } from '../components/PostComponent' +import { CompactPostComponent } from '../components/CompactPostComponent' import { SignOutButton } from '../components/SignOutButton' import { Post } from '../models/postModel' @@ -50,7 +50,7 @@ export default function PostsScreen() { {posts?.length ? ( - posts.map((el) => ) + posts.map((el) => ) ) : ( Your posts will show up here! diff --git a/app/components/CompactPostComponent.tsx b/app/components/CompactPostComponent.tsx new file mode 100644 index 0000000..4d091a3 --- /dev/null +++ b/app/components/CompactPostComponent.tsx @@ -0,0 +1,73 @@ +import { useUser } from '@clerk/clerk-react' +import React from 'react' +import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' +import { Post, StatusEnum } from '../models/postModel' + +export const CompactPostComponent: React.FC = (post) => { + const { user } = useUser() + console.log() + console.log() + + return ( + + + {post.notes} + + {post.status === StatusEnum.Created && ( + Created + )} + {post.status === StatusEnum.Pending && ( + Pending + )} + {post.status === StatusEnum.Denied && Denied} + {post.status === StatusEnum.Approved && ( + Approved + )} + + + + {post.address} + {new Date(post.date).toLocaleDateString()} + + + ) +} + +const styles = StyleSheet.create({ + text: { + color: '#fff', + justifyContent: 'center' + }, + subtext: { + color: '#b9b9b9ff', + justifyContent: 'center' + }, + posts: { + marginTop: 10, + backgroundColor: '#373d44ff', + borderColor: '#626e7aff', + borderStyle: 'solid', + borderWidth: 1, + borderRadius: 12, + padding: 10, + width: '100%' + }, + header: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + marginBottom: 16 + }, + footer: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, + date: { + paddingVertical: 3, + borderRadius: 6, + color: '#ffffff', + fontSize: 16 + }, + statusTag: { paddingVertical: 3, paddingHorizontal: 10, borderRadius: 6, fontSize: 16 }, + created: { backgroundColor: '#0d6efd', color: '#ffffff' }, + pending: { backgroundColor: '#ffc107', color: '#000000' }, + denied: { backgroundColor: '#dc3545', color: '#ffffff' }, + approved: { backgroundColor: '#198754', color: '#ffffff' } +}) diff --git a/app/components/PostComponent.tsx b/app/components/PostComponent.tsx index dcfa786..4645bbc 100644 --- a/app/components/PostComponent.tsx +++ b/app/components/PostComponent.tsx @@ -10,6 +10,7 @@ type PostComponentProps = { export const PostComponent: React.FC = ({ post, fetchData }) => { const { user } = useUser() + const isProfileView = window.location.href.includes('/profile') async function approvePost(postID: string) { console.log('Approving post ' + postID) @@ -54,7 +55,7 @@ export const PostComponent: React.FC = ({ post, fetchData }) /> {post.notes} - {user?.publicMetadata.role !== 'admin' && ( + {isProfileView ? ( {post.status === StatusEnum.Created && ( Created @@ -67,8 +68,8 @@ export const PostComponent: React.FC = ({ post, fetchData }) Approved )} - )} - {user?.publicMetadata.role === 'admin' && ( + ) : null} + {!isProfileView ? ( denyPost(post._id)}> = ({ post, fetchData }) - )} + ) : null} ) } diff --git a/app/models/postModel.ts b/app/models/postModel.ts index e3052b7..c11459c 100644 --- a/app/models/postModel.ts +++ b/app/models/postModel.ts @@ -1,5 +1,7 @@ export interface Post { _id: string + address: string + date: Date notes: string photo: string status: StatusEnum