Localize /[locale]/prayers page: use locale-aware labels, sample data, and timestamps; ensure /en/prayers renders in English.

This commit is contained in:
andupetcu
2025-09-20 18:04:07 +03:00
parent 88b251c100
commit ddfc2b673f

View File

@@ -37,6 +37,7 @@ import {
MoreVert, MoreVert,
} from '@mui/icons-material' } from '@mui/icons-material'
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { useLocale } from 'next-intl'
interface PrayerRequest { interface PrayerRequest {
id: string id: string
@@ -51,6 +52,7 @@ interface PrayerRequest {
export default function PrayersPage() { export default function PrayersPage() {
const theme = useTheme() const theme = useTheme()
const locale = useLocale()
const [prayers, setPrayers] = useState<PrayerRequest[]>([]) const [prayers, setPrayers] = useState<PrayerRequest[]>([])
const [openDialog, setOpenDialog] = useState(false) const [openDialog, setOpenDialog] = useState(false)
const [newPrayer, setNewPrayer] = useState({ const [newPrayer, setNewPrayer] = useState({
@@ -60,54 +62,104 @@ export default function PrayersPage() {
}) })
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const categories = [ const categories = locale === 'en'
{ value: 'personal', label: 'Personal', color: 'primary' }, ? [
{ value: 'family', label: 'Familie', color: 'secondary' }, { value: 'personal', label: 'Personal', color: 'primary' },
{ value: 'health', label: 'Sănătate', color: 'error' }, { value: 'family', label: 'Family', color: 'secondary' },
{ value: 'work', label: 'Muncă', color: 'warning' }, { value: 'health', label: 'Health', color: 'error' },
{ value: 'ministry', label: 'Serviciu', color: 'success' }, { value: 'work', label: 'Work', color: 'warning' },
{ value: 'world', label: 'Lume', color: 'info' }, { value: 'ministry', label: 'Ministry', color: 'success' },
] { value: 'world', label: 'World', color: 'info' },
]
: [
{ 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 // Sample data - in real app this would come from API
useEffect(() => { useEffect(() => {
// Simulate loading prayers // Simulate loading prayers
setTimeout(() => { setTimeout(() => {
setPrayers([ setPrayers(
{ locale === 'en'
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.', id: '1',
category: 'health', title: 'Prayer for healing',
author: 'Maria P.', description:
timestamp: new Date(Date.now() - 2 * 60 * 60 * 1000), // 2 hours ago 'Please pray for my father who is in the hospital. He needs God\'s healing.',
prayerCount: 23, category: 'health',
isPrayedFor: false, author: 'Maria P.',
}, timestamp: new Date(Date.now() - 2 * 60 * 60 * 1000),
{ prayerCount: 23,
id: '2', isPrayedFor: false,
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', id: '2',
author: 'Alexandru M.', title: 'God\'s guidance in career',
timestamp: new Date(Date.now() - 5 * 60 * 60 * 1000), // 5 hours ago description:
prayerCount: 15, 'Seeking God\'s direction for the next step in my career. Please pray for clarity and peace.',
isPrayedFor: true, category: 'work',
}, author: 'Alex M.',
{ timestamp: new Date(Date.now() - 5 * 60 * 60 * 1000),
id: '3', prayerCount: 15,
title: 'Unitatea în familia noastră', isPrayedFor: true,
description: 'Rugați-vă pentru restaurarea relațiilor în familia noastră și pentru iertarea reciprocă.', },
category: 'family', {
author: 'Anonim', id: '3',
timestamp: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000), // 1 day ago title: 'Unity in our family',
prayerCount: 41, description:
isPrayedFor: false, 'Please pray for restoration of relationships in our family and for mutual forgiveness.',
}, category: 'family',
]) author: 'Anonymous',
timestamp: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000),
prayerCount: 41,
isPrayedFor: false,
},
]
: [
{
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),
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),
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),
prayerCount: 41,
isPrayedFor: false,
},
]
)
setLoading(false) setLoading(false)
}, 1000) }, 1000)
}, []) }, [locale])
const handleSubmitPrayer = async () => { const handleSubmitPrayer = async () => {
if (!newPrayer.title.trim() || !newPrayer.description.trim()) return if (!newPrayer.title.trim() || !newPrayer.description.trim()) return
@@ -117,7 +169,7 @@ export default function PrayersPage() {
title: newPrayer.title, title: newPrayer.title,
description: newPrayer.description, description: newPrayer.description,
category: newPrayer.category, category: newPrayer.category,
author: 'Tu', // In real app, get from auth author: locale === 'en' ? 'You' : 'Tu', // In real app, get from auth
timestamp: new Date(), timestamp: new Date(),
prayerCount: 0, prayerCount: 0,
isPrayedFor: false, isPrayedFor: false,
@@ -164,6 +216,11 @@ export default function PrayersPage() {
const hours = Math.floor(diff / (1000 * 60 * 60)) const hours = Math.floor(diff / (1000 * 60 * 60))
const days = Math.floor(hours / 24) const days = Math.floor(hours / 24)
if (locale === 'en') {
if (days > 0) return `${days} day${days === 1 ? '' : 's'} ago`
if (hours > 0) return `${hours} hour${hours === 1 ? '' : 's'} ago`
return 'A few minutes ago'
}
if (days > 0) return `${days} zile în urmă` if (days > 0) return `${days} zile în urmă`
if (hours > 0) return `${hours} ore în urmă` if (hours > 0) return `${hours} ore în urmă`
return 'Acum câteva minute' return 'Acum câteva minute'
@@ -177,10 +234,12 @@ export default function PrayersPage() {
<Box sx={{ mb: 4, textAlign: 'center' }}> <Box sx={{ mb: 4, textAlign: 'center' }}>
<Typography variant="h3" component="h1" gutterBottom> <Typography variant="h3" component="h1" gutterBottom>
<Favorite sx={{ fontSize: 40, mr: 2, verticalAlign: 'middle', color: 'error.main' }} /> <Favorite sx={{ fontSize: 40, mr: 2, verticalAlign: 'middle', color: 'error.main' }} />
Peretele de rugăciuni {locale === 'en' ? 'Prayer Wall' : 'Peretele de rugăciuni'}
</Typography> </Typography>
<Typography variant="body1" color="text.secondary"> <Typography variant="body1" color="text.secondary">
Partajează rugăciuni și roagă-te împreună cu comunitatea {locale === 'en'
? 'Share prayers and pray together with the community'
: 'Partajează rugăciuni și roagă-te împreună cu comunitatea'}
</Typography> </Typography>
</Box> </Box>
@@ -190,7 +249,7 @@ export default function PrayersPage() {
<Card> <Card>
<CardContent> <CardContent>
<Typography variant="h6" gutterBottom> <Typography variant="h6" gutterBottom>
Categorii {locale === 'en' ? 'Categories' : 'Categorii'}
</Typography> </Typography>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}> <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
{categories.map((category) => ( {categories.map((category) => (
@@ -206,12 +265,22 @@ export default function PrayersPage() {
</Box> </Box>
<Typography variant="h6" sx={{ mt: 3, mb: 1 }}> <Typography variant="h6" sx={{ mt: 3, mb: 1 }}>
Statistici {locale === 'en' ? 'Statistics' : 'Statistici'}
</Typography> </Typography>
<Typography variant="body2" color="text.secondary"> <Typography variant="body2" color="text.secondary">
{prayers.length} cereri active<br /> {locale === 'en' ? (
{prayers.reduce((sum, p) => sum + p.prayerCount, 0)} rugăciuni totale<br /> <>
{prayers.filter(p => p.isPrayedFor).length} cereri la care te-ai rugat {prayers.length} active requests<br />
{prayers.reduce((sum, p) => sum + p.prayerCount, 0)} total prayers<br />
{prayers.filter(p => p.isPrayedFor).length} requests you prayed for
</>
) : (
<>
{prayers.length} cereri active<br />
{prayers.reduce((sum, p) => sum + p.prayerCount, 0)} rugăciuni totale<br />
{prayers.filter(p => p.isPrayedFor).length} cereri la care te-ai rugat
</>
)}
</Typography> </Typography>
</CardContent> </CardContent>
</Card> </Card>
@@ -308,19 +377,23 @@ export default function PrayersPage() {
onClick={() => handlePrayFor(prayer.id)} onClick={() => handlePrayFor(prayer.id)}
disabled={prayer.isPrayedFor} disabled={prayer.isPrayedFor}
> >
{prayer.isPrayedFor ? 'M-am rugat' : 'Mă rog'} {prayer.isPrayedFor
? locale === 'en' ? 'Prayed' : 'M-am rugat'
: locale === 'en' ? 'Pray' : 'Mă rog'}
</Button> </Button>
<Button <Button
variant="outlined" variant="outlined"
size="small" size="small"
startIcon={<Share />} startIcon={<Share />}
> >
Partajează {locale === 'en' ? 'Share' : 'Partajează'}
</Button> </Button>
</Box> </Box>
<Typography variant="body2" color="text.secondary"> <Typography variant="body2" color="text.secondary">
{prayer.prayerCount} {prayer.prayerCount === 1 ? 'rugăciune' : 'rugăciuni'} {locale === 'en'
? `${prayer.prayerCount} ${prayer.prayerCount === 1 ? 'prayer' : 'prayers'}`
: `${prayer.prayerCount} ${prayer.prayerCount === 1 ? 'rugăciune' : 'rugăciuni'}`}
</Typography> </Typography>
</Box> </Box>
</CardContent> </CardContent>
@@ -351,7 +424,7 @@ export default function PrayersPage() {
> >
<DialogTitle> <DialogTitle>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
Adaugă o cerere de rugăciune {locale === 'en' ? 'Add a prayer request' : 'Adaugă o cerere de rugăciune'}
<IconButton onClick={() => setOpenDialog(false)} size="small"> <IconButton onClick={() => setOpenDialog(false)} size="small">
<Close /> <Close />
</IconButton> </IconButton>
@@ -360,7 +433,7 @@ export default function PrayersPage() {
<DialogContent> <DialogContent>
<TextField <TextField
fullWidth fullWidth
label="Titlu" label={locale === 'en' ? 'Title' : 'Titlu'}
value={newPrayer.title} value={newPrayer.title}
onChange={(e) => setNewPrayer({ ...newPrayer, title: e.target.value })} onChange={(e) => setNewPrayer({ ...newPrayer, title: e.target.value })}
sx={{ mb: 2, mt: 1 }} sx={{ mb: 2, mt: 1 }}
@@ -368,7 +441,7 @@ export default function PrayersPage() {
<TextField <TextField
fullWidth fullWidth
label="Categoria" label={locale === 'en' ? 'Category' : 'Categoria'}
select select
value={newPrayer.category} value={newPrayer.category}
onChange={(e) => setNewPrayer({ ...newPrayer, category: e.target.value })} onChange={(e) => setNewPrayer({ ...newPrayer, category: e.target.value })}
@@ -383,28 +456,28 @@ export default function PrayersPage() {
<TextField <TextField
fullWidth fullWidth
label="Descriere" label={locale === 'en' ? 'Description' : 'Descriere'}
multiline multiline
rows={4} rows={4}
value={newPrayer.description} value={newPrayer.description}
onChange={(e) => setNewPrayer({ ...newPrayer, description: e.target.value })} onChange={(e) => setNewPrayer({ ...newPrayer, description: e.target.value })}
placeholder="Descrie cererea ta de rugăciune..." placeholder={locale === 'en' ? 'Describe your prayer request...' : 'Descrie cererea ta de rugăciune...'}
/> />
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={() => setOpenDialog(false)}> <Button onClick={() => setOpenDialog(false)}>
Anulează {locale === 'en' ? 'Cancel' : 'Anulează'}
</Button> </Button>
<Button <Button
onClick={handleSubmitPrayer} onClick={handleSubmitPrayer}
variant="contained" variant="contained"
disabled={!newPrayer.title.trim() || !newPrayer.description.trim()} disabled={!newPrayer.title.trim() || !newPrayer.description.trim()}
> >
Adaugă rugăciunea {locale === 'en' ? 'Add prayer' : 'Adaugă rugăciunea'}
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
</Container> </Container>
</Box> </Box>
) )
} }