diff --git a/src/app/page.tsx b/src/app/page.tsx index 32afac6..57c52ac 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -227,6 +227,7 @@ export default function Home() { todayCount={prayers.filter(p => p.date === new Date().toISOString().split('T')[0]).length} onStartPraying={() => setActiveTab('compose')} onSelectPrayer={handleSelectPrayer} + userName={user.displayName || user.email || undefined} /> )} diff --git a/src/components/HomePage.tsx b/src/components/HomePage.tsx index 5c1a817..aa35a63 100644 --- a/src/components/HomePage.tsx +++ b/src/components/HomePage.tsx @@ -20,9 +20,10 @@ interface HomePageProps { todayCount: number; onStartPraying: () => void; onSelectPrayer: (prayer: Prayer) => void; + userName?: string; } -export default function HomePage({ prayers, todayCount, onStartPraying, onSelectPrayer }: HomePageProps) { +export default function HomePage({ prayers, todayCount, onStartPraying, onSelectPrayer, userName }: HomePageProps) { const today = new Date().toISOString().split('T')[0]; const todayPrayers = prayers.filter(p => p.date === today); const recentPrayers = prayers.slice(0, 5); @@ -30,6 +31,28 @@ export default function HomePage({ prayers, todayCount, onStartPraying, onSelect const uniqueDays = new Set(prayers.map(p => p.date)).size; const answeredPrayers = prayers.filter(p => p.answered).length; + // Get greeting based on time of day + const getGreeting = () => { + const hour = new Date().getHours(); + if (hour < 12) return 'Good morning'; + if (hour < 18) return 'Good afternoon'; + return 'Good evening'; + }; + + // Get first name from display name or email + const getFirstName = () => { + if (!userName) return 'friend'; + // If it's an email, get the part before @ + if (userName.includes('@')) { + return userName.split('@')[0]; + } + // If it's a full name, get first name + return userName.split(' ')[0]; + }; + + // Count active prayer requests (not answered) + const activePrayerCount = prayers.filter(p => !p.answered).length; + // Calculate actual streak - consecutive days with prayers const calculateStreak = () => { if (prayers.length === 0) return 0; @@ -102,12 +125,21 @@ export default function HomePage({ prayers, todayCount, onStartPraying, onSelect - {/* Header */} + {/* Header with Personalized Greeting */}
-

- Haver +

+ {getGreeting()}, {getFirstName()}!

-

+ {activePrayerCount > 0 ? ( +

+ You have {activePrayerCount} {activePrayerCount === 1 ? 'thing' : 'things'} that need prayer today. +

+ ) : ( +

+ All caught up! Start a new prayer to keep your journey going. +

+ )} +

{new Date().toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric' })}