'use client' import { useState } from 'react' import { Container, Typography, Box, Button, TextField, Paper, CircularProgress, Alert, FormControlLabel, Checkbox, ToggleButton, ToggleButtonGroup, Divider, List, ListItem, ListItemIcon, ListItemText, } from '@mui/material' import { Favorite, CheckCircle, Public, Language, CloudOff, Security, } from '@mui/icons-material' import { useRouter } from 'next/navigation' import { useLocale } from 'next-intl' import { DONATION_PRESETS } from '@/lib/stripe' export default function DonatePage() { const router = useRouter() const locale = useLocale() 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('Please enter a valid amount (minimum $1)') return } if (!email || !email.includes('@')) { setError('Please enter a valid email address') 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 || 'Failed to create checkout session') } // 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 : 'An error occurred') setLoading(false) } } const features = [ { icon: , text: '1,200+ Bible versions in multiple languages', }, { icon: , text: 'Multilingual access for believers worldwide', }, { icon: , text: 'Offline access to Scripture anywhere', }, { icon: , text: 'Complete privacy - no ads or tracking', }, ] return ( {/* Hero Section */} Support Biblical Guide Your donation keeps Scripture free and accessible to everyone, everywhere. {/* Donation Form */} Make a Donation {error && ( {error} )} {success && ( Thank you for your donation! )}
{/* Recurring Donation Toggle */} setIsRecurring(e.target.checked)} /> } label="Make this a recurring donation" /> {isRecurring && ( value && setRecurringInterval(value)} sx={{ mt: 2, width: '100%' }} > Monthly Yearly )} {/* Amount Selection */} Select Amount (USD) {DONATION_PRESETS.map((preset) => ( ))} handleCustomAmountChange(e.target.value)} sx={{ mt: 2 }} InputProps={{ startAdornment: $, }} inputProps={{ min: 1, step: 0.01 }} /> {/* Contact Information */} Your Information setEmail(e.target.value)} sx={{ mb: 2 }} /> {!isAnonymous && ( setName(e.target.value)} sx={{ mb: 2 }} /> )} setIsAnonymous(e.target.checked)} /> } label="Make this donation anonymous" sx={{ mb: 2 }} /> setMessage(e.target.value)} placeholder="Share why you're supporting Biblical Guide..." sx={{ mb: 3 }} /> {/* Submit Button */} Secure payment powered by Stripe
{/* Impact Section */} Your Impact Every donation directly supports the servers, translations, and technology that make Biblical Guide possible. {features.map((feature, index) => ( ))} Why Donate? Biblical Guide is committed to keeping God's Word free and accessible to all. We don't have ads, paywalls, or sell your data. When you give, you're not paying for access — you're keeping access open for millions who cannot afford to pay. Freely you have received; freely give. — Matthew 10:8
) }