import * as React from "react"; import { ChevronLeft, ChevronRight, CreditCard, KeyRound, ShieldCheck, } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; // ─── Types ──────────────────────────────────────────────────────────────────── export type ConnectBankApplicant = { name: string; email?: string; isMain?: boolean; }; export type BankTile = { id: string; name: string; /** Optional logo URL. Falls back to abbreviated name. */ logoUrl?: string; }; /** * Default AU banks shown in the connect grid (matches Figma design). * logoUrl values are relative paths served from the Storybook public directory. * In production, override `banks` prop with CDN-hosted URLs. */ export const DEFAULT_BANKS: BankTile[] = [ { id: "commonwealth", name: "CommBank", logoUrl: "/banks/commbank.png" }, { id: "nab", name: "NAB", logoUrl: "/banks/nab.png" }, { id: "anz", name: "ANZ", logoUrl: "/banks/anz.png" }, { id: "bank-australia", name: "Bank Australia", logoUrl: "/banks/bank-australia.png", }, { id: "regional-australia-bank", name: "Regional Australia Bank", logoUrl: "/banks/regional-australia-bank.png", }, ]; export type SecurityItem = { text: string; icon?: React.ReactNode; }; export const DEFAULT_SECURITY_ITEMS: SecurityItem[] = [ { text: "Bank grade 256-bit SSL encryption", icon: , }, { text: "We never save your bank login credentials in the app", icon: , }, { text: "We cannot make transactions on your behalf", icon: , }, ]; export type ConnectBankStepProps = { applicant: ConnectBankApplicant; /** Whether the current user has been granted banking access for this applicant. */ allowToAccessBanking?: boolean; /** Featured banks to show as individual tiles. Defaults to 5 AU banks. A * "Connect Your Bank +" tile is always appended as the 6th cell. */ banks?: BankTile[]; /** Called when a specific bank tile OR the generic "Connect Your Bank +" is clicked. */ onConnect?: (bank?: BankTile) => void; onManualAdd?: () => void; onSendRequest?: () => void; onPrev?: () => void; hideManualAdd?: boolean; hideNavigation?: boolean; hideCdrBanner?: boolean; /** Security/trust items shown below the CDR banner. Defaults to 3 standard AU Open Banking items. */ securityItems?: SecurityItem[]; /** URL for the Consumer Data Right logo. Falls back to an inline SVG placeholder. */ cdrLogoUrl?: string; /** URL for the Australian Government crest. Falls back to an inline SVG placeholder. */ govLogoUrl?: string; className?: string; }; // ─── Component ──────────────────────────────────────────────────────────────── /** * ConnectBankStep — prompts the applicant to connect their bank accounts * via Open Banking (Basiq). * * States: * - `allowToAccessBanking=true` — shows CDR section + featured bank grid * + "Connect Your Bank +" + "Or Add manually" * - `allowToAccessBanking=false` — shows "Send join invitation" CTA only * (used for co-applicants who haven't yet granted access) * * Mirrors `ConnectBankStep` + `ConnectBankSection` + `BankConnectBanner` * from the frontend app. * * Figma: WealthX-Backoffice---Mobile-App — node 19308:52803 */ export function ConnectBankStep({ applicant, allowToAccessBanking = false, banks = DEFAULT_BANKS, onConnect, onManualAdd, onSendRequest, onPrev, hideManualAdd = false, hideNavigation = false, hideCdrBanner = false, securityItems = DEFAULT_SECURITY_ITEMS, cdrLogoUrl, govLogoUrl, className, }: ConnectBankStepProps) { const name = applicant.name || "applicant"; return (
{/* Heading — h1, dynamic applicant name */}

Connect {name}'s Bank Accounts

Connect bank accounts & speed up your application by 20 mins.

{/* CDR trust section */} {!hideCdrBanner && (

We are powered by Open Banking, the safest and most secure way to share your information with trusted advisers. Learn more at{" "} https://www.cdr.gov.au/

{/* Security items */} {securityItems.length > 0 && (
{securityItems.map((item, i) => (
{item.text} {item.icon && ( {item.icon} )}
))}
)}
)} {allowToAccessBanking ? ( <> {/* Bank connect section */}

Connect Bank Account

{/* Bank grid: featured banks + generic "Connect Your Bank +" */}
{banks.map((bank) => ( ))} {/* Generic "Connect Your Bank +" tile — 14px bold per Figma */}
{/* Divider */}
{!hideManualAdd && (

Or Add manually

)} ) : ( /* Co-applicant — no access yet */ )} {/* Navigation */} {!hideNavigation && (
)}
); } // ─── CDR / Gov logos ────────────────────────────────────────────────────────── /** Consumer Data Right logo — uses real image when `logoUrl` is provided, falls back to SVG placeholder */ function CdrLogo({ logoUrl }: { logoUrl?: string }) { if (logoUrl) { return ( Consumer Data Right ); } return (
Consumer Data Right
); } /** Australian Government crest — uses real image when `logoUrl` is provided, falls back to SVG placeholder */ function AustralianGovLogo({ logoUrl }: { logoUrl?: string }) { if (logoUrl) { return ( Australian Government ); } return (
{/* Simplified coat of arms silhouette */} Australian Government
); }