feat: premium UI overhaul, AI suggestions, WAHA WhatsApp integration
PREMIUM UI: - All animations: fade-up, scale-in, stagger children, confetti celebration - Glass effects, gradient icons, premium card hover states - Custom CSS: shimmer, pulse-ring, bounce, counter-roll animations - Smooth progress bar with gradient AI-POWERED (GPT-4o-mini nano model): - Smart amount suggestions based on peer data (/api/ai/suggest) - Social proof: '42 people pledged · Average £85' - AI-generated nudge text for conversion - AI fuzzy matching for bank reconciliation - AI reminder message generation WAHA WHATSAPP INTEGRATION: - Auto-send pledge receipt with bank details via WhatsApp - 4-step reminder sequence: gentle → nudge → urgent → final - Chatbot: donors reply PAID, HELP, CANCEL, STATUS - Volunteer notification on new pledges - WhatsApp status in dashboard settings - Webhook endpoint for incoming messages DONOR FLOW (CRO): - Amount step: AI suggestions, Gift Aid preview, social proof, haptic feedback - Payment step: trust signals, fee comparison, benefit badges - Identity step: email/phone toggle, WhatsApp reminder indicator - Bank instructions: tap-to-copy each field, WhatsApp delivery confirmation - Confirmation: confetti, pulse animation, share CTA, WhatsApp receipt COMPOSE: - Added WAHA env vars + qc-comms network for WhatsApp access
This commit is contained in:
@@ -3,6 +3,7 @@ import prisma from "@/lib/prisma"
|
||||
import { createPledgeSchema } from "@/lib/validators"
|
||||
import { generateReference } from "@/lib/reference"
|
||||
import { calculateReminderSchedule } from "@/lib/reminders"
|
||||
import { sendPledgeReceipt } from "@/lib/whatsapp"
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
@@ -125,6 +126,37 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// Async: Send WhatsApp receipt to donor (non-blocking)
|
||||
if (donorPhone) {
|
||||
sendPledgeReceipt(donorPhone, {
|
||||
donorName: donorName || undefined,
|
||||
amountPounds: (amountPence / 100).toFixed(0),
|
||||
eventName: event.name,
|
||||
reference: pledge.reference,
|
||||
rail,
|
||||
bankDetails: rail === "bank" && org.bankSortCode ? {
|
||||
sortCode: org.bankSortCode,
|
||||
accountNo: org.bankAccountNo || "",
|
||||
accountName: org.bankAccountName || org.name,
|
||||
} : undefined,
|
||||
orgName: org.name,
|
||||
}).catch(err => console.error("[WAHA] Receipt send failed:", err))
|
||||
}
|
||||
|
||||
// Async: Notify volunteer if QR source has volunteer info
|
||||
if (qrSourceId) {
|
||||
prisma?.qrSource.findUnique({
|
||||
where: { id: qrSourceId },
|
||||
select: { volunteerName: true, label: true, pledges: { select: { amountPence: true } } },
|
||||
}).then(qr => {
|
||||
// In future: if volunteer has a phone number stored, send WhatsApp notification
|
||||
// For now, this is a no-op unless volunteer phone is added to schema
|
||||
if (qr) {
|
||||
console.log(`[PLEDGE] ${qr.volunteerName || qr.label}: +1 pledge (£${(amountPence / 100).toFixed(0)})`)
|
||||
}
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
return NextResponse.json(response, { status: 201 })
|
||||
} catch (error) {
|
||||
console.error("Pledge creation error:", error)
|
||||
|
||||
Reference in New Issue
Block a user