Fix prayer page errors: add missing translations and fix time formatting

- Added missing 'categories.all' translation in both ro.json and en.json
- Fixed relativeTime formatting by using new Date() instead of useNow hook
- Removed unused useNow import

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
andupetcu
2025-09-21 23:18:48 +03:00
parent 5a3c6a6691
commit f71b6d44c7
3 changed files with 10 additions and 8 deletions

View File

@@ -44,7 +44,7 @@ import {
Login,
} from '@mui/icons-material'
import { useState, useEffect } from 'react'
import { useTranslations, useLocale, useFormatter, useNow } from 'next-intl'
import { useTranslations, useLocale, useFormatter } from 'next-intl'
import { useAuth } from '@/hooks/use-auth'
interface PrayerRequest {
@@ -64,7 +64,6 @@ export default function PrayersPage() {
const t = useTranslations('pages.prayers')
const tc = useTranslations('common')
const f = useFormatter()
const now = useNow()
const { user } = useAuth()
const [prayers, setPrayers] = useState<PrayerRequest[]>([])
const [selectedCategory, setSelectedCategory] = useState<string>('all')
@@ -251,15 +250,16 @@ export default function PrayersPage() {
}
const formatTimestamp = (timestamp: Date) => {
const diff = now.getTime() - timestamp.getTime()
const currentTime = new Date()
const diff = currentTime.getTime() - timestamp.getTime()
const minutes = Math.floor(diff / (1000 * 60))
const hours = Math.floor(minutes / 60)
const days = Math.floor(hours / 24)
if (days > 0) return f.relativeTime(-days, 'day', { now })
if (hours > 0) return f.relativeTime(-hours, 'hour', { now })
if (minutes > 0) return f.relativeTime(-minutes, 'minute', { now })
return f.relativeTime(0, 'second', { now })
if (days > 0) return f.relativeTime(-days, 'day', { now: currentTime })
if (hours > 0) return f.relativeTime(-hours, 'hour', { now: currentTime })
if (minutes > 0) return f.relativeTime(-minutes, 'minute', { now: currentTime })
return f.relativeTime(0, 'second', { now: currentTime })
}
return (
@@ -315,7 +315,7 @@ export default function PrayersPage() {
</Typography>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
<Chip
label={t('categories.all', { defaultValue: 'All' })}
label={t('categories.all')}
color="default"
variant={selectedCategory === 'all' ? 'filled' : 'outlined'}
size="small"

View File

@@ -148,6 +148,7 @@
"prayFor": "Pray for this",
"categories": {
"title": "Categories",
"all": "All",
"personal": "Personal",
"family": "Family",
"health": "Health",

View File

@@ -148,6 +148,7 @@
"prayFor": "Mă rog pentru aceasta",
"categories": {
"title": "Categorii",
"all": "Toate",
"personal": "Personal",
"family": "Familie",
"health": "Sănătate",