import { type ReactElement } from "react"; import { cn } from "@/lib/utils"; import { Badge } from "./badge"; import { Button } from "./button"; import { Input } from "./input"; import { Separator } from "./separator"; import { Check, Copy, ExternalLink, Link2, Mail, Settings } from "lucide-react"; // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- export type EmailProvider = "gmail" | "outlook"; export interface GmailConnection { connected: boolean; email?: string; /** ISO date string — "2026-03-15" */ connectedAt?: string; } export interface AppointmentGmailConnectProps { /** * Email provider that is connected. Determines displayed labels. * Defaults to "gmail". */ provider?: EmailProvider; /** Email connection state sourced from Settings > Integrations */ connection: GmailConnection; /** Booking link to display when connected */ calendarLink?: string; /** Highlights the card with a primary-colored border — used when this provider matches the default meeting platform. */ highlighted?: boolean; /** Called when user clicks the copy button next to the calendar link */ onCopyLink?: () => void; /** Called when user clicks "Go to Integrations" */ onGoToIntegrations?: () => void; } // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- function GmailIcon({ className }: { className?: string }) { return ( ); } function OutlookIcon({ className }: { className?: string }) { return ( ); } type IconComponent = (props: { className?: string }) => ReactElement; const PROVIDER_META: Record< EmailProvider, { label: string; iconBg: string; Icon: IconComponent } > = { gmail: { label: "Gmail", iconBg: "bg-[#EA4335]/10", Icon: GmailIcon }, outlook: { label: "Outlook", iconBg: "bg-[#0078D4]/10", Icon: OutlookIcon }, }; const PERMISSIONS = [ "Read your calendar availability", "Send appointment confirmation emails", "Create calendar events on your behalf", ]; // --------------------------------------------------------------------------- // Component // --------------------------------------------------------------------------- export function AppointmentGmailConnect({ provider = "gmail", connection, calendarLink, highlighted = false, onCopyLink, onGoToIntegrations, }: AppointmentGmailConnectProps) { const { label, iconBg, Icon } = PROVIDER_META[provider]; if (connection.connected) { return (
{label} Connected
{connection.email}
Connected since {connection.connectedAt}
)}Permissions granted
{PERMISSIONS.map((perm) => (Calendar Appointment Link
Share with clients so they can self-book.
{label} not connected
Connect your {label} account in Integrations to enable calendar booking and appointment confirmations.
Once connected, WealthX will be able to:
{PERMISSIONS.map((perm) => (