feat: remove FPX, add UK charity persona features

- Remove FPX payment rail entirely (Malaysian, not UK)
- Add volunteer portal (/v/[code]) with live pledge tracking
- Add public event page (/e/[slug]) with progress bar + social proof
- Add fundraiser leaderboard (/dashboard/events/[id]/leaderboard)
- Add WhatsApp share buttons on confirmation, bank instructions, volunteer view
- Enhanced Gift Aid UX with +25% bonus display and HMRC declaration text
- Gift Aid report export (HMRC-ready CSV filter)
- Volunteer view link + WhatsApp share on QR code cards
- Updated home page: 4 personas, 3 UK payment rails, 8 features
- Public event API endpoint with privacy-safe donor name truncation
- Volunteer API with stats, conversion rate, auto-refresh
This commit is contained in:
2026-03-03 03:47:18 +08:00
parent 1389c848b2
commit 0236867c88
32 changed files with 2293 additions and 494 deletions

View File

@@ -8,10 +8,9 @@ import { IdentityStep } from "./steps/identity-step"
import { ConfirmationStep } from "./steps/confirmation-step"
import { BankInstructionsStep } from "./steps/bank-instructions-step"
import { CardPaymentStep } from "./steps/card-payment-step"
import { FpxPaymentStep } from "./steps/fpx-payment-step"
import { DirectDebitStep } from "./steps/direct-debit-step"
export type Rail = "bank" | "gocardless" | "card" | "fpx"
export type Rail = "bank" | "gocardless" | "card"
export interface PledgeData {
amountPence: number
@@ -30,18 +29,15 @@ interface EventInfo {
qrSourceLabel: string | null
}
// Step indices:
// 0 = Amount selection
// 1 = Payment method selection
// Steps:
// 0 = Amount
// 1 = Payment method
// 2 = Identity (for bank transfer)
// 3 = Bank instructions
// 4 = Confirmation (generic — card, DD, FPX)
// 4 = Confirmation (card, DD)
// 5 = Card payment step
// 6 = FPX payment step
// 7 = Direct Debit step
const STEP_TO_RAIL: Record<number, number> = { 5: 1, 6: 1, 7: 1 } // maps back to payment selection
export default function PledgePage() {
const params = useParams()
const token = params.token as string
@@ -80,7 +76,6 @@ export default function PledgePage() {
setError("Unable to load pledge page")
setLoading(false)
})
// Track pledge_start
fetch("/api/analytics", {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -96,10 +91,9 @@ export default function PledgePage() {
const handleRailSelected = (rail: Rail) => {
setPledgeData((d) => ({ ...d, rail }))
const railStepMap: Record<Rail, number> = {
bank: 2, // → identity step → bank instructions
card: 5, // → card payment step (combined identity + card)
fpx: 6, // → FPX step (bank selection + identity + redirect)
gocardless: 7, // → direct debit step (bank details + mandate)
bank: 2,
card: 5,
gocardless: 7,
}
setStep(railStepMap[rail])
}
@@ -119,12 +113,8 @@ export default function PledgePage() {
}),
})
const result = await res.json()
if (result.error) {
setError(result.error)
return
}
if (result.error) { setError(result.error); return }
setPledgeResult(result)
// Bank rail shows bank instructions; everything else shows generic confirmation
setStep(finalData.rail === "bank" ? 3 : 4)
} catch {
setError("Something went wrong. Please try again.")
@@ -151,50 +141,38 @@ export default function PledgePage() {
)
}
const shareUrl = eventInfo?.qrSourceId ? `${typeof window !== "undefined" ? window.location.origin : ""}/p/${token}` : undefined
const steps: Record<number, React.ReactNode> = {
0: <AmountStep onSelect={handleAmountSelected} eventName={eventInfo?.name || ""} />,
1: <PaymentStep onSelect={handleRailSelected} amount={pledgeData.amountPence} />,
2: <IdentityStep onSubmit={submitPledge} />,
2: <IdentityStep onSubmit={submitPledge} amount={pledgeData.amountPence} />,
3: pledgeResult && <BankInstructionsStep pledge={pledgeResult} amount={pledgeData.amountPence} eventName={eventInfo?.name || ""} />,
4: pledgeResult && <ConfirmationStep pledge={pledgeResult} amount={pledgeData.amountPence} rail={pledgeData.rail} eventName={eventInfo?.name || ""} />,
4: pledgeResult && <ConfirmationStep pledge={pledgeResult} amount={pledgeData.amountPence} rail={pledgeData.rail} eventName={eventInfo?.name || ""} shareUrl={shareUrl} />,
5: <CardPaymentStep amount={pledgeData.amountPence} eventName={eventInfo?.name || ""} eventId={eventInfo?.id || ""} qrSourceId={eventInfo?.qrSourceId || null} onComplete={submitPledge} />,
6: <FpxPaymentStep amount={pledgeData.amountPence} eventName={eventInfo?.name || ""} onComplete={submitPledge} />,
7: <DirectDebitStep amount={pledgeData.amountPence} eventName={eventInfo?.name || ""} organizationName={eventInfo?.organizationName || ""} eventId={eventInfo?.id || ""} qrSourceId={eventInfo?.qrSourceId || null} onComplete={submitPledge} />,
}
// Determine which steps allow back navigation
const backableSteps = new Set([1, 2, 5, 6, 7])
const getBackStep = (current: number): number => {
if (current in STEP_TO_RAIL) return STEP_TO_RAIL[current] // rail-specific steps → payment selection
return current - 1
const backableSteps = new Set([1, 2, 5, 7])
const getBackStep = (s: number): number => {
if (s === 5 || s === 7) return 1
return s - 1
}
// Progress calculation: steps 0-2 map linearly, 3+ means done
const progressSteps = step >= 3 ? 3 : Math.min(step, 2) + 1
const progressPercent = step >= 5 ? 66 : (progressSteps / 3) * 100 // rail steps show 2/3 progress
const progressPercent = step >= 3 ? 100 : step >= 2 ? 66 : step >= 1 ? 33 : 10
return (
<div className="min-h-screen bg-gradient-to-br from-trust-blue/5 via-white to-warm-amber/5">
{/* Progress bar */}
<div className="fixed top-0 left-0 right-0 h-1 bg-gray-100 z-50">
<div
className="h-full bg-trust-blue transition-all duration-500 ease-out"
style={{ width: `${progressPercent}%` }}
/>
<div className="h-full bg-trust-blue transition-all duration-500 ease-out" style={{ width: `${progressPercent}%` }} />
</div>
{/* Header */}
<div className="pt-6 pb-2 px-4 text-center">
<p className="text-sm text-muted-foreground">{eventInfo?.organizationName}</p>
<p className="text-xs text-muted-foreground/60">{eventInfo?.qrSourceLabel || ""}</p>
</div>
{/* Step content */}
<div className="px-4 pb-8">
{steps[step]}
</div>
<div className="px-4 pb-8">{steps[step]}</div>
{/* Back button */}
{backableSteps.has(step) && (
<div className="fixed bottom-6 left-4">
<button

View File

@@ -3,7 +3,7 @@
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Card, CardContent } from "@/components/ui/card"
import { Check, Copy, ExternalLink } from "lucide-react"
import { Check, Copy, ExternalLink, MessageCircle, Share2 } from "lucide-react"
interface Props {
pledge: {
@@ -70,6 +70,35 @@ export function BankInstructionsStep({ pledge, amount, eventName }: Props) {
</div>
</CardContent>
</Card>
{/* Share CTA */}
<div className="rounded-2xl bg-warm-amber/5 border border-warm-amber/20 p-4 space-y-3 text-center">
<p className="text-sm font-semibold text-gray-900">🤲 Know someone who&apos;d donate too?</p>
<div className="flex gap-2">
<Button
onClick={() => {
const text = `I just pledged £${(amount / 100).toFixed(0)} to ${eventName}! 🤲\nPledge here: ${window.location.origin}`
window.open(`https://wa.me/?text=${encodeURIComponent(text)}`, "_blank")
}}
className="flex-1 bg-[#25D366] hover:bg-[#20BD5A] text-white"
size="sm"
>
<MessageCircle className="h-4 w-4 mr-1" /> WhatsApp
</Button>
<Button
onClick={async () => {
if (navigator.share) {
await navigator.share({ title: eventName, text: `Pledge to ${eventName}`, url: window.location.origin })
}
}}
variant="outline"
size="sm"
className="flex-1"
>
<Share2 className="h-4 w-4 mr-1" /> Share
</Button>
</div>
</div>
<p className="text-xs text-muted-foreground">
Need help? Contact the charity directly.
</p>

View File

@@ -1,30 +1,42 @@
"use client"
import { Check } from "lucide-react"
import { Check, Share2, MessageCircle } from "lucide-react"
import { Card, CardContent } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
interface Props {
pledge: { id: string; reference: string }
amount: number
rail: string
eventName: string
shareUrl?: string
}
export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
export function ConfirmationStep({ pledge, amount, rail, eventName, shareUrl }: Props) {
const railLabels: Record<string, string> = {
bank: "Bank Transfer",
gocardless: "Direct Debit",
card: "Card Payment",
fpx: "FPX Online Banking",
}
const currencySymbol = rail === "fpx" ? "RM" : "£"
const nextStepMessages: Record<string, string> = {
bank: "We've sent you payment instructions. Transfer at your convenience — we'll confirm once received.",
gocardless: "Your Direct Debit mandate has been set up. The payment of " + currencySymbol + (amount / 100).toFixed(2) + " will be collected automatically in 3-5 working days. You'll receive email confirmation from GoCardless.",
card: "Your card payment is being processed. You'll receive a confirmation email shortly.",
fpx: "Your FPX payment has been received and is being verified. You'll receive a confirmation email once the payment is confirmed by your bank.",
gocardless: "Your Direct Debit mandate has been set up. The payment of £" + (amount / 100).toFixed(2) + " will be collected automatically in 3-5 working days. You'll receive email confirmation from GoCardless. Protected by the Direct Debit Guarantee.",
card: "Your card payment has been processed. You'll receive a confirmation email shortly.",
}
const handleWhatsAppShare = () => {
const text = `I just pledged £${(amount / 100).toFixed(0)} to ${eventName}! 🤲\n\nYou can pledge too: ${shareUrl || window.location.origin}`
window.open(`https://wa.me/?text=${encodeURIComponent(text)}`, "_blank")
}
const handleShare = async () => {
const text = `I just pledged £${(amount / 100).toFixed(0)} to ${eventName}!`
if (navigator.share) {
await navigator.share({ title: eventName, text, url: shareUrl || window.location.origin })
} else {
handleWhatsAppShare()
}
}
return (
@@ -35,10 +47,10 @@ export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
<div className="space-y-2">
<h1 className="text-2xl font-extrabold text-gray-900">
{rail === "fpx" ? "Payment Successful!" : rail === "gocardless" ? "Mandate Set Up!" : "Pledge Received!"}
{rail === "gocardless" ? "Mandate Set Up!" : rail === "card" ? "Payment Complete!" : "Pledge Received!"}
</h1>
<p className="text-muted-foreground">
Thank you for your generous {rail === "fpx" ? "donation" : "pledge"} to{" "}
Thank you for your generous {rail === "card" ? "donation" : "pledge"} to{" "}
<span className="font-semibold text-foreground">{eventName}</span>
</p>
</div>
@@ -47,7 +59,7 @@ export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
<CardContent className="pt-6 space-y-3 text-sm">
<div className="flex justify-between">
<span className="text-muted-foreground">Amount</span>
<span className="font-bold">{currencySymbol}{(amount / 100).toFixed(2)}</span>
<span className="font-bold">£{(amount / 100).toFixed(2)}</span>
</div>
<div className="flex justify-between">
<span className="text-muted-foreground">Payment Method</span>
@@ -63,7 +75,7 @@ export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
<span className="text-sm">3-5 working days</span>
</div>
)}
{rail === "fpx" && (
{rail === "card" && (
<div className="flex justify-between">
<span className="text-muted-foreground">Status</span>
<span className="text-success-green font-semibold">Paid </span>
@@ -72,6 +84,7 @@ export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
</CardContent>
</Card>
{/* What happens next */}
<div className="rounded-2xl bg-trust-blue/5 border border-trust-blue/20 p-4 space-y-2">
<p className="text-sm font-medium text-trust-blue">What happens next?</p>
<p className="text-sm text-muted-foreground">
@@ -79,6 +92,33 @@ export function ConfirmationStep({ pledge, amount, rail, eventName }: Props) {
</p>
</div>
{/* Share / encourage others */}
<div className="rounded-2xl bg-warm-amber/5 border border-warm-amber/20 p-5 space-y-3">
<p className="text-sm font-semibold text-gray-900">
🤲 Spread the word every pledge counts!
</p>
<p className="text-xs text-muted-foreground">
Share with friends and family so they can pledge too.
</p>
<div className="flex gap-2">
<Button
onClick={handleWhatsAppShare}
className="flex-1 bg-[#25D366] hover:bg-[#20BD5A] text-white"
>
<MessageCircle className="h-4 w-4 mr-2" />
WhatsApp
</Button>
<Button
onClick={handleShare}
variant="outline"
className="flex-1"
>
<Share2 className="h-4 w-4 mr-2" />
Share
</Button>
</div>
</div>
<p className="text-xs text-muted-foreground">
Need help? Contact the charity directly. Ref: {pledge.reference}
</p>

View File

@@ -1,329 +0,0 @@
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Lock, Search, CheckCircle2 } from "lucide-react"
interface Props {
amount: number
eventName: string
onComplete: (identity: {
donorName: string
donorEmail: string
donorPhone: string
giftAid: boolean
}) => void
}
interface Bank {
code: string
name: string
shortName: string
online: boolean
}
const FPX_BANKS: Bank[] = [
{ code: "MBB", name: "Maybank2u", shortName: "Maybank", online: true },
{ code: "CIMB", name: "CIMB Clicks", shortName: "CIMB", online: true },
{ code: "PBB", name: "PBe Bank", shortName: "Public Bank", online: true },
{ code: "RHB", name: "RHB Now", shortName: "RHB", online: true },
{ code: "HLB", name: "Hong Leong Connect", shortName: "Hong Leong", online: true },
{ code: "AMBB", name: "AmOnline", shortName: "AmBank", online: true },
{ code: "BIMB", name: "Bank Islam GO", shortName: "Bank Islam", online: true },
{ code: "BKRM", name: "i-Rakyat", shortName: "Bank Rakyat", online: true },
{ code: "BSN", name: "myBSN", shortName: "BSN", online: true },
{ code: "OCBC", name: "OCBC Online", shortName: "OCBC", online: true },
{ code: "UOB", name: "UOB Personal", shortName: "UOB", online: true },
{ code: "ABB", name: "Affin Online", shortName: "Affin Bank", online: true },
{ code: "ABMB", name: "Alliance Online", shortName: "Alliance Bank", online: true },
{ code: "BMMB", name: "Bank Muamalat", shortName: "Muamalat", online: true },
{ code: "SCB", name: "SC Online", shortName: "Standard Chartered", online: true },
{ code: "HSBC", name: "HSBC Online", shortName: "HSBC", online: true },
{ code: "AGR", name: "AGRONet", shortName: "Agrobank", online: true },
{ code: "KFH", name: "KFH Online", shortName: "KFH", online: true },
]
const BANK_COLORS: Record<string, string> = {
MBB: "bg-yellow-500",
CIMB: "bg-red-600",
PBB: "bg-pink-700",
RHB: "bg-blue-800",
HLB: "bg-blue-600",
AMBB: "bg-green-700",
BIMB: "bg-emerald-700",
BKRM: "bg-blue-900",
BSN: "bg-orange-600",
OCBC: "bg-red-700",
UOB: "bg-blue-700",
ABB: "bg-amber-700",
ABMB: "bg-teal-700",
BMMB: "bg-green-800",
SCB: "bg-green-600",
HSBC: "bg-red-500",
AGR: "bg-green-900",
KFH: "bg-yellow-700",
}
type Phase = "select" | "identity" | "redirecting" | "processing"
export function FpxPaymentStep({ amount, eventName, onComplete }: Props) {
const [phase, setPhase] = useState<Phase>("select")
const [selectedBank, setSelectedBank] = useState<Bank | null>(null)
const [search, setSearch] = useState("")
const [name, setName] = useState("")
const [email, setEmail] = useState("")
const [phone, setPhone] = useState("")
const [errors, setErrors] = useState<Record<string, string>>({})
const ringgit = (amount / 100).toFixed(2)
const filteredBanks = search
? FPX_BANKS.filter(
(b) =>
b.name.toLowerCase().includes(search.toLowerCase()) ||
b.shortName.toLowerCase().includes(search.toLowerCase()) ||
b.code.toLowerCase().includes(search.toLowerCase())
)
: FPX_BANKS
const handleBankSelect = (bank: Bank) => {
setSelectedBank(bank)
}
const handleContinueToIdentity = () => {
if (!selectedBank) return
setPhase("identity")
}
const handleSubmit = async () => {
const errs: Record<string, string> = {}
if (!email.includes("@")) errs.email = "Valid email required"
setErrors(errs)
if (Object.keys(errs).length > 0) return
setPhase("redirecting")
// Simulate FPX redirect flow
await new Promise((r) => setTimeout(r, 2000))
setPhase("processing")
await new Promise((r) => setTimeout(r, 1500))
onComplete({
donorName: name,
donorEmail: email,
donorPhone: phone,
giftAid: false, // Gift Aid not applicable for MYR
})
}
// Redirecting phase
if (phase === "redirecting") {
return (
<div className="max-w-md mx-auto pt-16 text-center space-y-6">
<div className="inline-flex items-center justify-center w-20 h-20 rounded-full bg-trust-blue/10">
<div className="h-10 w-10 border-4 border-trust-blue border-t-transparent rounded-full animate-spin" />
</div>
<div className="space-y-2">
<h1 className="text-2xl font-extrabold text-gray-900">
Redirecting to {selectedBank?.name}
</h1>
<p className="text-muted-foreground">
You&apos;ll be taken to your bank&apos;s secure login page to authorize the payment of <span className="font-bold text-foreground">RM{ringgit}</span>
</p>
</div>
<div className="rounded-2xl bg-gray-50 border p-4">
<div className="flex items-center justify-center gap-3">
<div className={`w-10 h-10 rounded-lg ${BANK_COLORS[selectedBank?.code || ""] || "bg-gray-500"} flex items-center justify-center`}>
<span className="text-white font-bold text-xs">{selectedBank?.code}</span>
</div>
<span className="font-semibold">{selectedBank?.name}</span>
</div>
</div>
<p className="text-xs text-muted-foreground">
Do not close this window. You will be redirected back automatically.
</p>
</div>
)
}
// Processing phase
if (phase === "processing") {
return (
<div className="max-w-md mx-auto pt-16 text-center space-y-6">
<div className="inline-flex items-center justify-center w-20 h-20 rounded-full bg-success-green/10">
<div className="h-10 w-10 border-4 border-success-green border-t-transparent rounded-full animate-spin" />
</div>
<div className="space-y-2">
<h1 className="text-2xl font-extrabold text-gray-900">
Processing Payment
</h1>
<p className="text-muted-foreground">
Verifying your payment with {selectedBank?.shortName}...
</p>
</div>
</div>
)
}
// Identity phase
if (phase === "identity") {
return (
<div className="max-w-md mx-auto pt-4 space-y-6">
<div className="text-center space-y-2">
<h1 className="text-2xl font-extrabold text-gray-900">Your Details</h1>
<p className="text-muted-foreground">
Before we redirect you to <span className="font-semibold text-foreground">{selectedBank?.name}</span>
</p>
</div>
{/* Selected bank indicator */}
<div className="rounded-2xl border-2 border-trust-blue/20 bg-trust-blue/5 p-4">
<div className="flex items-center justify-between">
<div className="flex items-center gap-3">
<div className={`w-10 h-10 rounded-lg ${BANK_COLORS[selectedBank?.code || ""] || "bg-gray-500"} flex items-center justify-center`}>
<span className="text-white font-bold text-xs">{selectedBank?.code}</span>
</div>
<div>
<p className="font-semibold text-sm">{selectedBank?.name}</p>
<p className="text-xs text-muted-foreground">FPX Online Banking</p>
</div>
</div>
<div className="text-right">
<p className="font-bold text-lg">RM{ringgit}</p>
<p className="text-xs text-muted-foreground">{eventName}</p>
</div>
</div>
</div>
<div className="rounded-2xl border-2 border-gray-200 bg-white p-5 space-y-4">
<div className="space-y-2">
<Label htmlFor="fpx-name">Full Name <span className="text-muted-foreground font-normal">(optional)</span></Label>
<Input
id="fpx-name"
placeholder="Your full name"
value={name}
onChange={(e) => setName(e.target.value)}
autoComplete="name"
/>
</div>
<div className="space-y-2">
<Label htmlFor="fpx-email">Email</Label>
<Input
id="fpx-email"
type="email"
placeholder="your@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
autoComplete="email"
inputMode="email"
className={errors.email ? "border-red-500" : ""}
/>
{errors.email && <p className="text-xs text-red-500">{errors.email}</p>}
<p className="text-xs text-muted-foreground">We&apos;ll send your receipt here</p>
</div>
<div className="space-y-2">
<Label htmlFor="fpx-phone">Phone <span className="text-muted-foreground font-normal">(optional)</span></Label>
<Input
id="fpx-phone"
type="tel"
placeholder="+60 12-345 6789"
value={phone}
onChange={(e) => setPhone(e.target.value)}
autoComplete="tel"
inputMode="tel"
/>
</div>
</div>
<Button size="xl" className="w-full" onClick={handleSubmit}>
<Lock className="h-5 w-5 mr-2" />
Pay RM{ringgit} via {selectedBank?.shortName}
</Button>
<div className="flex items-center justify-center gap-2 text-xs text-muted-foreground">
<Lock className="h-3 w-3" />
<span>Secured by FPX Bank Negara Malaysia</span>
</div>
</div>
)
}
// Bank selection phase (default)
return (
<div className="max-w-md mx-auto pt-4 space-y-5">
<div className="text-center space-y-2">
<h1 className="text-2xl font-extrabold text-gray-900">
FPX Online Banking
</h1>
<p className="text-lg text-muted-foreground">
Pay <span className="font-bold text-foreground">RM{ringgit}</span>{" "}
for <span className="font-semibold text-foreground">{eventName}</span>
</p>
</div>
{/* Search */}
<div className="relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
<Input
placeholder="Search your bank..."
value={search}
onChange={(e) => setSearch(e.target.value)}
className="pl-10"
/>
</div>
{/* Bank list */}
<div className="grid grid-cols-2 gap-2 max-h-[400px] overflow-y-auto pr-1">
{filteredBanks.map((bank) => (
<button
key={bank.code}
onClick={() => handleBankSelect(bank)}
className={`
text-left rounded-xl border-2 p-3 transition-all active:scale-[0.98]
${selectedBank?.code === bank.code
? "border-trust-blue bg-trust-blue/5 shadow-md shadow-trust-blue/10"
: "border-gray-200 bg-white hover:border-gray-300"
}
`}
>
<div className="flex items-center gap-2.5">
<div className={`w-9 h-9 rounded-lg ${BANK_COLORS[bank.code] || "bg-gray-500"} flex items-center justify-center flex-shrink-0`}>
<span className="text-white font-bold text-[10px] leading-none">{bank.code}</span>
</div>
<div className="min-w-0 flex-1">
<p className="font-semibold text-xs text-gray-900 truncate">{bank.shortName}</p>
<p className="text-[10px] text-muted-foreground truncate">{bank.name}</p>
</div>
{selectedBank?.code === bank.code && (
<CheckCircle2 className="h-4 w-4 text-trust-blue flex-shrink-0" />
)}
</div>
</button>
))}
</div>
{filteredBanks.length === 0 && (
<p className="text-center text-sm text-muted-foreground py-4">No banks found matching &quot;{search}&quot;</p>
)}
{/* Continue */}
<Button
size="xl"
className="w-full"
disabled={!selectedBank}
onClick={handleContinueToIdentity}
>
Continue with {selectedBank?.shortName || "selected bank"}
</Button>
<div className="flex items-center justify-center gap-2 text-xs text-muted-foreground">
<Lock className="h-3 w-3" />
<span>Powered by FPX regulated by Bank Negara Malaysia</span>
</div>
</div>
)
}

View File

@@ -4,6 +4,7 @@ import { useState } from "react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Gift, Shield } from "lucide-react"
interface Props {
onSubmit: (data: {
@@ -12,9 +13,10 @@ interface Props {
donorPhone: string
giftAid: boolean
}) => void
amount: number
}
export function IdentityStep({ onSubmit }: Props) {
export function IdentityStep({ onSubmit, amount }: Props) {
const [name, setName] = useState("")
const [email, setEmail] = useState("")
const [phone, setPhone] = useState("")
@@ -23,6 +25,7 @@ export function IdentityStep({ onSubmit }: Props) {
const hasContact = email.includes("@") || phone.length >= 10
const isValid = hasContact
const giftAidBonus = Math.round(amount * 0.25)
const handleSubmit = async () => {
if (!isValid) return
@@ -47,10 +50,10 @@ export function IdentityStep({ onSubmit }: Props) {
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="name">Name <span className="text-muted-foreground font-normal">(optional)</span></Label>
<Label htmlFor="name">Full Name <span className="text-muted-foreground font-normal">(for Gift Aid)</span></Label>
<Input
id="name"
placeholder="Your name"
placeholder="Your full name"
value={name}
onChange={(e) => setName(e.target.value)}
autoComplete="name"
@@ -68,6 +71,9 @@ export function IdentityStep({ onSubmit }: Props) {
autoComplete="email"
inputMode="email"
/>
<p className="text-xs text-muted-foreground">
We&apos;ll send your payment instructions and receipt here
</p>
</div>
<div className="relative flex items-center">
@@ -77,7 +83,7 @@ export function IdentityStep({ onSubmit }: Props) {
</div>
<div className="space-y-2">
<Label htmlFor="phone">Phone</Label>
<Label htmlFor="phone">Mobile Number</Label>
<Input
id="phone"
type="tel"
@@ -87,23 +93,54 @@ export function IdentityStep({ onSubmit }: Props) {
autoComplete="tel"
inputMode="tel"
/>
<p className="text-xs text-muted-foreground">
We can send reminders via SMS if you prefer
</p>
</div>
{/* Gift Aid */}
<label className="flex items-start gap-3 rounded-2xl border-2 border-gray-200 bg-white p-4 cursor-pointer hover:border-trust-blue/50 transition-colors">
<input
type="checkbox"
checked={giftAid}
onChange={(e) => setGiftAid(e.target.checked)}
className="mt-1 h-5 w-5 rounded border-gray-300 text-trust-blue focus:ring-trust-blue"
/>
<div>
<span className="font-semibold text-gray-900">Add Gift Aid</span>
<p className="text-sm text-muted-foreground mt-0.5">
Boost your donation by 25% at no extra cost to you. You must be a UK taxpayer.
</p>
{/* Gift Aid — prominent UK-specific */}
<div
onClick={() => setGiftAid(!giftAid)}
className={`rounded-2xl border-2 p-5 cursor-pointer transition-all ${
giftAid
? "border-success-green bg-success-green/5 shadow-md shadow-success-green/10"
: "border-gray-200 bg-white hover:border-success-green/50"
}`}
>
<div className="flex items-start gap-4">
<div className={`rounded-xl p-2.5 ${giftAid ? "bg-success-green/10" : "bg-gray-100"}`}>
<Gift className={`h-6 w-6 ${giftAid ? "text-success-green" : "text-gray-400"}`} />
</div>
<div className="flex-1">
<div className="flex items-center gap-2">
<input
type="checkbox"
checked={giftAid}
onChange={() => {}}
className="h-5 w-5 rounded border-gray-300 text-success-green focus:ring-success-green"
/>
<span className="font-bold text-gray-900">Add Gift Aid</span>
{giftAid && (
<span className="text-xs font-bold px-2 py-0.5 rounded-full bg-success-green text-white">
+£{(giftAidBonus / 100).toFixed(0)} free
</span>
)}
</div>
<p className="text-sm text-muted-foreground mt-1">
Boost your £{(amount / 100).toFixed(0)} pledge to{" "}
<span className="font-bold text-success-green">£{((amount + giftAidBonus) / 100).toFixed(0)}</span> at no extra cost.
HMRC adds 25% the charity claims it back.
</p>
{giftAid && (
<p className="text-xs text-muted-foreground mt-2 italic">
I confirm I am a UK taxpayer and understand that if I pay less Income Tax and/or
Capital Gains Tax than the amount of Gift Aid claimed on all my donations in that
tax year it is my responsibility to pay any difference.
</p>
)}
</div>
</div>
</label>
</div>
</div>
<Button
@@ -115,9 +152,10 @@ export function IdentityStep({ onSubmit }: Props) {
{submitting ? "Submitting..." : "Complete Pledge ✓"}
</Button>
<p className="text-center text-xs text-muted-foreground">
We&apos;ll only use this to send payment details and confirm receipt.
</p>
<div className="flex items-center justify-center gap-2 text-xs text-muted-foreground">
<Shield className="h-3 w-3" />
<span>Your data is kept secure and only used for this pledge</span>
</div>
</div>
)
}

View File

@@ -1,9 +1,9 @@
"use client"
import { Building2, CreditCard, Landmark, Globe } from "lucide-react"
import { Building2, CreditCard, Landmark } from "lucide-react"
interface Props {
onSelect: (rail: "bank" | "gocardless" | "card" | "fpx") => void
onSelect: (rail: "bank" | "gocardless" | "card") => void
amount: number
}
@@ -18,34 +18,31 @@ export function PaymentStep({ onSelect, amount }: Props) {
subtitle: "Zero fees — 100% goes to charity",
tag: "Recommended",
tagColor: "bg-success-green text-white",
detail: "Use your banking app to transfer directly",
detail: "Use your banking app to transfer directly. We'll give you the details.",
fee: "No fees",
feeColor: "text-success-green",
},
{
id: "gocardless" as const,
icon: Landmark,
title: "Direct Debit",
subtitle: "Automatic collection — set and forget",
tag: "Low fees",
tag: "Set up once",
tagColor: "bg-trust-blue/10 text-trust-blue",
detail: "We'll collect via GoCardless",
detail: "We'll collect via GoCardless. Protected by the Direct Debit Guarantee.",
fee: "1% + 20p",
feeColor: "text-muted-foreground",
},
{
id: "card" as const,
icon: CreditCard,
title: "Card Payment via Stripe",
subtitle: "Pay now by Visa, Mastercard, Amex",
tag: "Stripe",
title: "Debit or Credit Card",
subtitle: "Pay instantly by Visa, Mastercard, or Amex",
tag: "Instant",
tagColor: "bg-purple-100 text-purple-700",
detail: "Secure payment powered by Stripe",
},
{
id: "fpx" as const,
icon: Globe,
title: "FPX Online Banking",
subtitle: "Pay via Malaysian bank account",
tag: "Malaysia",
tagColor: "bg-amber-500/10 text-amber-700",
detail: "Instant payment from 18 Malaysian banks",
detail: "Secure payment powered by Stripe. Receipt emailed immediately.",
fee: "1.4% + 20p",
feeColor: "text-muted-foreground",
},
]
@@ -56,7 +53,7 @@ export function PaymentStep({ onSelect, amount }: Props) {
How would you like to pay?
</h1>
<p className="text-lg text-muted-foreground">
Pledge: <span className="font-bold text-foreground">£{pounds}</span>
Your pledge: <span className="font-bold text-foreground">£{pounds}</span>
</p>
</div>
@@ -72,16 +69,17 @@ export function PaymentStep({ onSelect, amount }: Props) {
<opt.icon className="h-6 w-6 text-trust-blue" />
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<div className="flex items-center gap-2 flex-wrap">
<span className="font-bold text-gray-900">{opt.title}</span>
{opt.tag && (
<span className={`text-xs font-semibold px-2 py-0.5 rounded-full ${opt.tagColor}`}>
{opt.tag}
</span>
)}
<span className={`text-xs font-semibold px-2 py-0.5 rounded-full ${opt.tagColor}`}>
{opt.tag}
</span>
</div>
<p className="text-sm text-muted-foreground mt-0.5">{opt.subtitle}</p>
<p className="text-xs text-muted-foreground/70 mt-1">{opt.detail}</p>
<p className={`text-xs font-medium mt-1 ${opt.feeColor}`}>
Fee: {opt.fee}
</p>
</div>
<div className="text-muted-foreground/40 group-hover:text-trust-blue transition-colors text-xl">
@@ -90,6 +88,10 @@ export function PaymentStep({ onSelect, amount }: Props) {
</button>
))}
</div>
<p className="text-center text-xs text-muted-foreground">
All payments are secure. Bank transfers mean 100% reaches the charity.
</p>
</div>
)
}