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:
@@ -44,7 +44,7 @@ import {
|
|||||||
Login,
|
Login,
|
||||||
} from '@mui/icons-material'
|
} from '@mui/icons-material'
|
||||||
import { useState, useEffect } from 'react'
|
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'
|
import { useAuth } from '@/hooks/use-auth'
|
||||||
|
|
||||||
interface PrayerRequest {
|
interface PrayerRequest {
|
||||||
@@ -64,7 +64,6 @@ export default function PrayersPage() {
|
|||||||
const t = useTranslations('pages.prayers')
|
const t = useTranslations('pages.prayers')
|
||||||
const tc = useTranslations('common')
|
const tc = useTranslations('common')
|
||||||
const f = useFormatter()
|
const f = useFormatter()
|
||||||
const now = useNow()
|
|
||||||
const { user } = useAuth()
|
const { user } = useAuth()
|
||||||
const [prayers, setPrayers] = useState<PrayerRequest[]>([])
|
const [prayers, setPrayers] = useState<PrayerRequest[]>([])
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string>('all')
|
const [selectedCategory, setSelectedCategory] = useState<string>('all')
|
||||||
@@ -251,15 +250,16 @@ export default function PrayersPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const formatTimestamp = (timestamp: Date) => {
|
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 minutes = Math.floor(diff / (1000 * 60))
|
||||||
const hours = Math.floor(minutes / 60)
|
const hours = Math.floor(minutes / 60)
|
||||||
const days = Math.floor(hours / 24)
|
const days = Math.floor(hours / 24)
|
||||||
|
|
||||||
if (days > 0) return f.relativeTime(-days, 'day', { now })
|
if (days > 0) return f.relativeTime(-days, 'day', { now: currentTime })
|
||||||
if (hours > 0) return f.relativeTime(-hours, 'hour', { now })
|
if (hours > 0) return f.relativeTime(-hours, 'hour', { now: currentTime })
|
||||||
if (minutes > 0) return f.relativeTime(-minutes, 'minute', { now })
|
if (minutes > 0) return f.relativeTime(-minutes, 'minute', { now: currentTime })
|
||||||
return f.relativeTime(0, 'second', { now })
|
return f.relativeTime(0, 'second', { now: currentTime })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -315,7 +315,7 @@ export default function PrayersPage() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||||
<Chip
|
<Chip
|
||||||
label={t('categories.all', { defaultValue: 'All' })}
|
label={t('categories.all')}
|
||||||
color="default"
|
color="default"
|
||||||
variant={selectedCategory === 'all' ? 'filled' : 'outlined'}
|
variant={selectedCategory === 'all' ? 'filled' : 'outlined'}
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
"prayFor": "Pray for this",
|
"prayFor": "Pray for this",
|
||||||
"categories": {
|
"categories": {
|
||||||
"title": "Categories",
|
"title": "Categories",
|
||||||
|
"all": "All",
|
||||||
"personal": "Personal",
|
"personal": "Personal",
|
||||||
"family": "Family",
|
"family": "Family",
|
||||||
"health": "Health",
|
"health": "Health",
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
"prayFor": "Mă rog pentru aceasta",
|
"prayFor": "Mă rog pentru aceasta",
|
||||||
"categories": {
|
"categories": {
|
||||||
"title": "Categorii",
|
"title": "Categorii",
|
||||||
|
"all": "Toate",
|
||||||
"personal": "Personal",
|
"personal": "Personal",
|
||||||
"family": "Familie",
|
"family": "Familie",
|
||||||
"health": "Sănătate",
|
"health": "Sănătate",
|
||||||
|
|||||||
Reference in New Issue
Block a user