All files / components/profile ContactButtons.tsx

100% Statements 81/81
100% Branches 15/15
100% Functions 5/5
100% Lines 81/81

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 1231x                                 1x 30x 30x 30x 30x 30x 30x 30x 30x 30x 1x 1x   30x 1x 1x   30x 1x 1x   30x 1x 1x   30x   30x 30x   30x 30x 7x 7x 7x 7x 7x 7x   7x 7x 7x 7x   7x   7x 7x     30x 4x 4x 4x 4x 4x 4x   4x 4x   4x 4x   30x     30x 12x 12x 5x 5x 5x 5x 5x     12x 3x 3x 3x 3x 3x     12x 3x 3x 3x 3x 3x     12x 4x 4x 4x 4x 4x   12x   30x   30x  
'use client';
 
import { MessageCircle, Mail, Linkedin, Globe, Twitter, Github } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { formatWhatsAppUrl } from '@/lib/utils';
import { trackEvent } from '@/lib/analytics/track';
 
interface ContactButtonsProps {
  whatsapp?: string | null;
  email?: string | null;
  linkedin?: string | null;
  website?: string | null;
  twitter?: string | null;
  github?: string | null;
  profileId: string;
}
 
export function ContactButtons({
  whatsapp,
  email,
  linkedin,
  website,
  twitter,
  github,
  profileId,
}: ContactButtonsProps) {
  const handleWhatsAppClick = () => {
    trackEvent(profileId, 'whatsapp_click');
  };
 
  const handleEmailClick = () => {
    trackEvent(profileId, 'email_click');
  };
 
  const handleLinkedInClick = () => {
    trackEvent(profileId, 'linkedin_click');
  };
 
  const handleWebsiteClick = () => {
    trackEvent(profileId, 'website_click');
  };
 
  const hasAnySocial = linkedin || website || twitter || github;
 
  return (
    <div className="space-y-4">
      {/* Primary CTAs */}
      <div className="flex flex-wrap gap-3">
        {whatsapp && (
          <Button
            variant="whatsapp"
            size="lg"
            className="flex-1 sm:flex-none"
            asChild
            onClick={handleWhatsAppClick}
          >
            <a
              href={formatWhatsAppUrl(whatsapp, 'Hi! I found you on ProofID.')}
              target="_blank"
              rel="noopener noreferrer"
            >
              <MessageCircle className="mr-2 h-5 w-5" />
              WhatsApp
            </a>
          </Button>
        )}
 
        {email && (
          <Button
            variant="outline"
            size="lg"
            className="flex-1 sm:flex-none"
            asChild
            onClick={handleEmailClick}
          >
            <a href={`mailto:${email}`}>
              <Mail className="mr-2 h-5 w-5" />
              Email
            </a>
          </Button>
        )}
      </div>
 
      {/* Social Links */}
      {hasAnySocial && (
        <div className="flex flex-wrap gap-2">
          {linkedin && (
            <Button variant="ghost" size="icon" asChild onClick={handleLinkedInClick}>
              <a href={linkedin} target="_blank" rel="noopener noreferrer" title="LinkedIn">
                <Linkedin className="h-5 w-5" />
              </a>
            </Button>
          )}
 
          {github && (
            <Button variant="ghost" size="icon" asChild>
              <a href={github} target="_blank" rel="noopener noreferrer" title="GitHub">
                <Github className="h-5 w-5" />
              </a>
            </Button>
          )}
 
          {twitter && (
            <Button variant="ghost" size="icon" asChild>
              <a href={twitter} target="_blank" rel="noopener noreferrer" title="Twitter">
                <Twitter className="h-5 w-5" />
              </a>
            </Button>
          )}
 
          {website && (
            <Button variant="ghost" size="icon" asChild onClick={handleWebsiteClick}>
              <a href={website} target="_blank" rel="noopener noreferrer" title="Website">
                <Globe className="h-5 w-5" />
              </a>
            </Button>
          )}
        </div>
      )}
    </div>
  );
}