'use client'; import React, { useState, useRef } from 'react'; import Link from 'next/link'; import { QRCodeSVG } from 'qrcode.react'; import { Users, Download, Check, Sparkles, Video, MessageCircle } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import { cn } from '@/lib/utils'; // Brand Colors - Microsoft Teams Purple const BRAND = { paleGrey: '#F3F2F1', primary: '#6264A7', primaryDark: '#464775', }; // QR Color Options const QR_COLORS = [ { name: 'Teams Purple', value: '#6264A7' }, { name: 'Teams Dark', value: '#464775' }, { name: 'Classic Black', value: '#000000' }, { name: 'Indigo', value: '#4F46E5' }, { name: 'Violet', value: '#7C3AED' }, { name: 'Emerald', value: '#10B981' }, { name: 'Rose', value: '#F43F5E' }, ]; // Frame Options const FRAME_OPTIONS = [ { id: 'none', label: 'No Frame' }, { id: 'scanme', label: 'Scan Me' }, { id: 'join', label: 'Join Meeting' }, { id: 'teams', label: 'Teams' }, ]; // Link Type Options const LINK_TYPES = [ { id: 'meeting', label: 'Meeting Link', icon: Video }, { id: 'chat', label: 'Chat with User', icon: MessageCircle }, ]; export default function TeamsGenerator() { const [linkType, setLinkType] = useState('meeting'); const [meetingUrl, setMeetingUrl] = useState(''); const [userEmail, setUserEmail] = useState(''); const [qrColor, setQrColor] = useState(BRAND.primary); const [frameType, setFrameType] = useState('none'); const qrRef = useRef(null); // Generate Teams link const generateTeamsLink = () => { if (linkType === 'meeting') { // If user pastes full Teams meeting URL, use it directly if (meetingUrl.trim().includes('teams.microsoft.com') || meetingUrl.trim().includes('teams.live.com')) { return meetingUrl.trim(); } // Otherwise return placeholder return meetingUrl.trim() || 'https://teams.microsoft.com'; } else { // Chat link with email if (!userEmail.trim()) return 'https://teams.microsoft.com'; return `https://teams.microsoft.com/l/chat/0/0?users=${encodeURIComponent(userEmail.trim())}`; } }; const handleDownload = async (format: 'png' | 'svg') => { if (!qrRef.current) return; try { if (format === 'png') { const { toPng } = await import('html-to-image'); const dataUrl = await toPng(qrRef.current, { cacheBust: true, pixelRatio: 3 }); const link = document.createElement('a'); link.download = `teams-qr-code.png`; link.href = dataUrl; link.click(); } else { const svgData = qrRef.current.querySelector('svg')?.outerHTML; if (svgData) { const blob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = `teams-qr-code.svg`; link.click(); } } } catch (err) { console.error('Download failed', err); } }; const getFrameLabel = () => { const frame = FRAME_OPTIONS.find(f => f.id === frameType); return frame?.id !== 'none' ? frame?.label : null; }; return (
{/* Main Generator Card */}
{/* LEFT: Input Section */}
{/* Teams Details */}

Microsoft Teams

{/* Link Type Toggle */}
{LINK_TYPES.map((type) => ( ))}
{linkType === 'meeting' ? (
setMeetingUrl(e.target.value)} className="h-12 text-base rounded-xl border-slate-200 focus:border-[#6264A7] focus:ring-[#6264A7]" />

Copy the meeting link from your Teams calendar invite.

) : (
setUserEmail(e.target.value)} className="h-12 text-base rounded-xl border-slate-200 focus:border-[#6264A7] focus:ring-[#6264A7]" />

The person's work email to start a Teams chat.

)}
{/* Design Options */}

Design Options

{/* Color Picker */}
{QR_COLORS.map((c) => ( ))}
{/* Frame Selector */}
{FRAME_OPTIONS.map((frame) => ( ))}
{/* RIGHT: Preview Section */}
{/* QR Card with Frame */}
{/* Frame Label */} {getFrameLabel() && (
{getFrameLabel()}
)} {/* QR Code */}
{/* Teams Info */}

{linkType === 'meeting' ? (

{linkType === 'meeting' ? 'Join Meeting' : 'Start Chat'}

{/* Download Buttons */}

Works with Microsoft Teams desktop and mobile apps.

{/* Upsell Banner */}

Need to update meeting links?

Dynamic QR Codes let you change the destination without reprinting.

); }