import React, { useState } from 'react';
import PublicNavbar from '../components/PublicNavbar';
import PublicFooter from '../components/PublicFooter';
import { Button } from '../components/ui/button';
import { Card } from '../components/ui/card';
import { Input } from '../components/ui/input';
import { Label } from '../components/ui/label';
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '../components/ui/dialog';
import { CreditCard, Mail, Heart, Loader2 } from 'lucide-react';
import api from '../utils/api';
import { toast } from 'sonner';
const Donate = () => {
const loafHearts = `${process.env.PUBLIC_URL}/loaf-hearts.png`;
const zelleLogo = `${process.env.PUBLIC_URL}/zelle-logo.png`;
const [customAmountDialogOpen, setCustomAmountDialogOpen] = useState(false);
const [customAmount, setCustomAmount] = useState('');
const [processingAmount, setProcessingAmount] = useState(null);
const handleDonateAmount = async (amountCents) => {
setProcessingAmount(amountCents);
try {
const response = await api.post('/donations/checkout', {
amount_cents: amountCents
});
// Redirect to Stripe Checkout
window.location.href = response.data.checkout_url;
} catch (error) {
console.error('Failed to process donation:', error);
toast.error(error.response?.data?.detail || 'Failed to process donation. Please try again.');
setProcessingAmount(null);
}
};
const handleCustomDonate = () => {
const amount = parseFloat(customAmount);
if (!customAmount || isNaN(amount) || amount < 1) {
toast.error('Please enter a valid amount (minimum $1.00)');
return;
}
const amountCents = Math.round(amount * 100);
setCustomAmountDialogOpen(false);
handleDonateAmount(amountCents);
};
return (
{/* Hero Section */}

e.target.style.display = 'none'} />
Donate
We really appreciate your donations. You can make your donation online
or send a check by mail.
{/* Columns */}
{/* Donation Amount Buttons */}
Select Your Donation Amount
{/* Donation Buttons Grid */}
{[25, 50, 100, 250].map(amount => (
))}
{/* Custom Amount Button */}
Secure donation processing powered by Stripe
{/* Alternative Payment Methods */}
{/* Mail Check */}
Mail a Check
Our mailing address for checks:
LOAF
P.O. Box 7207
Houston, Texas 77248-7207
{/* Zelle */}

e.target.style.display = 'none'} />
{/* Columns end */}
{/* Custom Amount Dialog */}
);
};
export default Donate;