'use client' import { Container, Typography, Box, Button, Paper, useTheme, Divider, Card, CardContent, List, ListItem, ListItemText, TextField, Checkbox, FormControlLabel, ToggleButton, ToggleButtonGroup, CircularProgress, Alert, } from '@mui/material' import { MenuBook, Chat, Favorite, Search, Language, CloudOff, Security, AutoStories, Public, VolunteerActivism, CheckCircle, } from '@mui/icons-material' import { useRouter } from 'next/navigation' import { useLocale, useTranslations } from 'next-intl' import { useState } from 'react' import { DONATION_PRESETS } from '@/lib/stripe' export default function DonatePage() { const theme = useTheme() const router = useRouter() const locale = useLocale() const t = useTranslations('donate') const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const [success, setSuccess] = useState(false) // Form state const [selectedAmount, setSelectedAmount] = useState(25) const [customAmount, setCustomAmount] = useState('') const [email, setEmail] = useState('') const [name, setName] = useState('') const [message, setMessage] = useState('') const [isAnonymous, setIsAnonymous] = useState(false) const [isRecurring, setIsRecurring] = useState(false) const [recurringInterval, setRecurringInterval] = useState<'month' | 'year'>('month') const handleAmountSelect = (amount: number | null) => { setSelectedAmount(amount) setCustomAmount('') } const handleCustomAmountChange = (value: string) => { setCustomAmount(value) setSelectedAmount(null) } const getAmount = (): number | null => { if (customAmount) { const parsed = parseFloat(customAmount) return isNaN(parsed) ? null : parsed } return selectedAmount } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError(null) const amount = getAmount() // Validation if (!amount || amount < 1) { setError(t('form.errors.invalidAmount')) return } if (!email || !email.includes('@')) { setError(t('form.errors.invalidEmail')) return } setLoading(true) try { // Create checkout session const response = await fetch('/api/stripe/checkout', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ amount, email, name: isAnonymous ? 'Anonymous' : name, message, isAnonymous, isRecurring, recurringInterval, locale, }), }) const data = await response.json() if (!response.ok) { throw new Error(data.error || t('form.errors.checkoutFailed')) } // Redirect to Stripe Checkout if (data.url) { window.location.href = data.url } } catch (err) { console.error('Donation error:', err) setError(err instanceof Error ? err.message : t('form.errors.generic')) setLoading(false) } } const features = [ { icon: , title: t('features.globalLibrary.title'), description: t('features.globalLibrary.description'), }, { icon: , title: t('features.multilingual.title'), description: t('features.multilingual.description'), }, { icon: , title: t('features.prayerWall.title'), description: t('features.prayerWall.description'), }, { icon: , title: t('features.aiChat.title'), description: t('features.aiChat.description'), }, { icon: , title: t('features.privacy.title'), description: t('features.privacy.description'), }, { icon: , title: t('features.offline.title'), description: t('features.offline.description'), }, ] return ( {/* Hero Section */} {t('hero.title')} {t('hero.subtitle')} {/* Mission Section */} {t('mission.title')} {t('mission.description1')} {t('mission.different')} {t('mission.description2')} {t('mission.description3')} {/* Donation Pitch Section */} {t('pitch.title')} {t('pitch.description1')} {t('pitch.description2')} {t('pitch.verse.text')} {t('pitch.verse.reference')} {/* Features Section */} {t('features.title')} {t('features.subtitle')} {features.map((feature, index) => ( {feature.icon} {feature.title} {feature.description} ))} {/* Donation Form Section */} {/* Why It Matters Section */} {t('matters.title')} {t('matters.point1')} {t('matters.point2')} {t('matters.point3')} {t('matters.together')} {t('matters.conclusion')} {/* Join the Mission Section */} {t('join.title')} {t('join.description1')} {t('join.description2')} {t('join.callToAction')} {t('join.closing')} {/* Footer CTA */} Biblical-Guide.com {t('footer.tagline')} ) }