diff --git a/app/[locale]/prayers/page.tsx b/app/[locale]/prayers/page.tsx index a8c50bf..212dc29 100644 --- a/app/[locale]/prayers/page.tsx +++ b/app/[locale]/prayers/page.tsx @@ -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([]) const [selectedCategory, setSelectedCategory] = useState('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() {