2025-08-08 00:49:33 -05:00
|
|
|
import { router } from 'expo-router'
|
2025-08-07 23:23:46 -05:00
|
|
|
import React from 'react'
|
|
|
|
|
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
2025-08-08 00:49:33 -05:00
|
|
|
|
2025-08-07 23:23:46 -05:00
|
|
|
import { Post, StatusEnum } from '../models/postModel'
|
|
|
|
|
|
|
|
|
|
export const CompactPostComponent: React.FC<Post> = (post) => {
|
|
|
|
|
return (
|
2025-08-08 09:45:45 -05:00
|
|
|
<TouchableOpacity
|
|
|
|
|
key={post._id}
|
|
|
|
|
style={styles.posts}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
router.push({
|
|
|
|
|
pathname: '/posts/details',
|
|
|
|
|
params: {
|
|
|
|
|
id: post._id
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-08-07 23:23:46 -05:00
|
|
|
<View style={styles.header}>
|
2025-08-08 09:45:45 -05:00
|
|
|
<Text style={[styles.text, styles.title]}>{post.notes}</Text>
|
2025-08-07 23:23:46 -05:00
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
2025-08-08 09:45:45 -05:00
|
|
|
{post.status === StatusEnum.Created && <Text style={[styles.open, styles.statusTag]}>Open</Text>}
|
2025-08-07 23:23:46 -05:00
|
|
|
{post.status === StatusEnum.Pending && (
|
|
|
|
|
<Text style={[styles.pending, styles.statusTag]}>Pending</Text>
|
|
|
|
|
)}
|
|
|
|
|
{post.status === StatusEnum.Denied && <Text style={[styles.denied, styles.statusTag]}>Denied</Text>}
|
|
|
|
|
{post.status === StatusEnum.Approved && (
|
|
|
|
|
<Text style={[styles.approved, styles.statusTag]}>Approved</Text>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={styles.footer}>
|
2025-08-08 09:45:45 -05:00
|
|
|
<Text style={[styles.subtext, styles.address]}>{post.address}</Text>
|
2025-08-07 23:23:46 -05:00
|
|
|
<Text style={[styles.subtext]}>{new Date(post.date).toLocaleDateString()}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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' },
|
2025-08-08 09:45:45 -05:00
|
|
|
title: {
|
2025-08-07 23:23:46 -05:00
|
|
|
paddingVertical: 3,
|
|
|
|
|
borderRadius: 6,
|
|
|
|
|
color: '#ffffff',
|
2025-08-08 09:45:45 -05:00
|
|
|
fontSize: 16,
|
|
|
|
|
paddingRight: 10
|
|
|
|
|
},
|
|
|
|
|
address: {
|
|
|
|
|
paddingRight: 15
|
2025-08-07 23:23:46 -05:00
|
|
|
},
|
|
|
|
|
statusTag: { paddingVertical: 3, paddingHorizontal: 10, borderRadius: 6, fontSize: 16 },
|
2025-08-08 09:45:45 -05:00
|
|
|
open: { backgroundColor: '#0d6efd', color: '#ffffff' },
|
2025-08-07 23:23:46 -05:00
|
|
|
pending: { backgroundColor: '#ffc107', color: '#000000' },
|
|
|
|
|
denied: { backgroundColor: '#dc3545', color: '#ffffff' },
|
|
|
|
|
approved: { backgroundColor: '#198754', color: '#ffffff' }
|
|
|
|
|
})
|