'use client'; import React from 'react'; import { HandHeart, Sparkles, CheckCircle2, Target } from 'lucide-react'; interface Prayer { id: string; userId: string; date: string; text: string; prayFor?: string; answered?: boolean; answerDetails?: string; prayFrequency?: number; // 1-7 times per week lastPrayedFor?: string; // ISO date string prayedDates?: string[]; // Array of dates when prayed for } interface ThingsToPrayForProps { prayers: Prayer[]; onEdit: (prayer: Prayer) => void; onMarkPrayed: (prayerId: string) => void; } export default function ThingsToPrayFor({ prayers, onEdit, onMarkPrayed }: ThingsToPrayForProps) { // Filter for unanswered prayers const thingsToPrayFor = prayers.filter(p => !p.answered).sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime() ); // Group by prayer for (people/topics) const groupedByTopic: Record = {}; thingsToPrayFor.forEach(prayer => { const topic = prayer.prayFor || 'Other Concerns'; if (!groupedByTopic[topic]) { groupedByTopic[topic] = []; } groupedByTopic[topic].push(prayer); }); return (
{/* Animated Background */}
{/* Header */}
Haver icon

Things to Pray For

{thingsToPrayFor.length} active {thingsToPrayFor.length === 1 ? 'prayer request' : 'prayer requests'}

{thingsToPrayFor.length === 0 ? (

All Caught Up!

You've marked all your prayers as answered. Praise God for His faithfulness!

) : (
{Object.entries(groupedByTopic).map(([topic, prayersByTopic]) => (

{topic}

{prayersByTopic.map((prayer, idx) => { const daysAgo = Math.floor( (new Date().getTime() - new Date(prayer.date).getTime()) / (1000 * 60 * 60 * 24) ); const today = new Date().toISOString().split('T')[0]; const prayedToday = prayer.prayedDates?.includes(today) || prayer.lastPrayedFor === today; return (

{prayer.text}

{daysAgo === 0 ? 'Today' : daysAgo === 1 ? 'Yesterday' : `${daysAgo} days ago`}
); })}
))}
)}
); }