'use client' import { Container, Grid, Card, CardContent, Typography, Box, TextField, Button, Paper, Avatar, Chip, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Fab, List, ListItem, ListItemAvatar, ListItemText, MenuItem, useTheme, } from '@mui/material' import { Favorite, Add, Close, Person, AccessTime, FavoriteBorder, Share, MoreVert, } from '@mui/icons-material' import { Navigation } from '@/components/layout/navigation' import { useState, useEffect } from 'react' interface PrayerRequest { id: string title: string description: string category: string author: string timestamp: Date prayerCount: number isPrayedFor: boolean } export default function PrayersPage() { const theme = useTheme() const [prayers, setPrayers] = useState([]) const [openDialog, setOpenDialog] = useState(false) const [newPrayer, setNewPrayer] = useState({ title: '', description: '', category: 'personal', }) const [loading, setLoading] = useState(true) const categories = [ { value: 'personal', label: 'Personal', color: 'primary' }, { value: 'family', label: 'Familie', color: 'secondary' }, { value: 'health', label: 'Sănătate', color: 'error' }, { value: 'work', label: 'Muncă', color: 'warning' }, { value: 'ministry', label: 'Serviciu', color: 'success' }, { value: 'world', label: 'Lume', color: 'info' }, ] // Sample data - in real app this would come from API useEffect(() => { // Simulate loading prayers setTimeout(() => { setPrayers([ { id: '1', title: 'Rugăciune pentru vindecare', description: 'Te rog să te rogi pentru tatăl meu care se află în spital. Are nevoie de vindecarea lui Dumnezeu.', category: 'health', author: 'Maria P.', timestamp: new Date(Date.now() - 2 * 60 * 60 * 1000), // 2 hours ago prayerCount: 23, isPrayedFor: false, }, { id: '2', title: 'Îndrumarea lui Dumnezeu în carieră', description: 'Caut direcția lui Dumnezeu pentru următorul pas în cariera mea. Te rog să te rogi pentru claritate și pace.', category: 'work', author: 'Alexandru M.', timestamp: new Date(Date.now() - 5 * 60 * 60 * 1000), // 5 hours ago prayerCount: 15, isPrayedFor: true, }, { id: '3', title: 'Unitatea în familia noastră', description: 'Rugați-vă pentru restaurarea relațiilor în familia noastră și pentru iertarea reciprocă.', category: 'family', author: 'Anonim', timestamp: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000), // 1 day ago prayerCount: 41, isPrayedFor: false, }, ]) setLoading(false) }, 1000) }, []) const handleSubmitPrayer = async () => { if (!newPrayer.title.trim() || !newPrayer.description.trim()) return const prayer: PrayerRequest = { id: Date.now().toString(), title: newPrayer.title, description: newPrayer.description, category: newPrayer.category, author: 'Tu', // In real app, get from auth timestamp: new Date(), prayerCount: 0, isPrayedFor: false, } setPrayers([prayer, ...prayers]) setNewPrayer({ title: '', description: '', category: 'personal' }) setOpenDialog(false) // In real app, send to API try { await fetch('/api/prayers', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(prayer), }) } catch (error) { console.error('Error submitting prayer:', error) } } const handlePrayFor = async (prayerId: string) => { setPrayers(prayers.map(prayer => prayer.id === prayerId ? { ...prayer, prayerCount: prayer.prayerCount + 1, isPrayedFor: true } : prayer )) // In real app, send to API try { await fetch(`/api/prayers/${prayerId}/pray`, { method: 'POST' }) } catch (error) { console.error('Error updating prayer count:', error) } } const getCategoryInfo = (category: string) => { return categories.find(cat => cat.value === category) || categories[0] } const formatTimestamp = (timestamp: Date) => { const now = new Date() const diff = now.getTime() - timestamp.getTime() const hours = Math.floor(diff / (1000 * 60 * 60)) const days = Math.floor(hours / 24) if (days > 0) return `${days} zile în urmă` if (hours > 0) return `${hours} ore în urmă` return 'Acum câteva minute' } return ( {/* Header */} Peretele de rugăciuni Partajează rugăciuni și roagă-te împreună cu comunitatea {/* Categories Filter */} Categorii {categories.map((category) => ( ))} Statistici • {prayers.length} cereri active
• {prayers.reduce((sum, p) => sum + p.prayerCount, 0)} rugăciuni totale
• {prayers.filter(p => p.isPrayedFor).length} cereri la care te-ai rugat
{/* Prayer Requests */} {loading ? ( Se încarcă rugăciunile... ) : ( {prayers.map((prayer) => { const categoryInfo = getCategoryInfo(prayer.category) return ( {prayer.title} {prayer.author} {formatTimestamp(prayer.timestamp)} {prayer.description} {prayer.prayerCount} {prayer.prayerCount === 1 ? 'rugăciune' : 'rugăciuni'} ) })} )}
{/* Add Prayer FAB */} setOpenDialog(true)} > {/* Add Prayer Dialog */} setOpenDialog(false)} maxWidth="sm" fullWidth > Adaugă o cerere de rugăciune setOpenDialog(false)} size="small"> setNewPrayer({ ...newPrayer, title: e.target.value })} sx={{ mb: 2, mt: 1 }} /> setNewPrayer({ ...newPrayer, category: e.target.value })} sx={{ mb: 2 }} > {categories.map((option) => ( {option.label} ))} setNewPrayer({ ...newPrayer, description: e.target.value })} placeholder="Descrie cererea ta de rugăciune..." />
) }