'use client'; import React, { useState, useEffect } from 'react'; import QRCode from 'qrcode'; import { Smartphone, QrCode, Copy, Check, Gift, ExternalLink, Sparkles, Zap, ShieldCheck, Star } from 'lucide-react'; import { AppItem, ToolItem, resolveLocalised } from '@/types'; interface AppHandoffSectionProps { app?: AppItem; tool?: ToolItem | null; locale?: string; showBonus?: boolean; showQr?: boolean; } export function AppHandoffSection({ app, tool, locale = 'en', showBonus = true, showQr = true, }: AppHandoffSectionProps) { const [qrDataUrl, setQrDataUrl] = useState(''); const [copiedPromo, setCopiedPromo] = useState(false); const [copiedLink, setCopiedLink] = useState(false); const [origin, setOrigin] = useState(''); useEffect(() => { if (typeof window !== 'undefined') { setOrigin(window.location.origin); } }, []); if (!app) return null; const bonusCode = app.welcomeBonus?.code || 'TRYWEB50'; const baseHost = origin || 'http://localhost:3000'; const targetUrl = tool ? `${baseHost}/go/${tool.slug}/${app.slug}?promo=${bonusCode}` : `${baseHost}/apps/${app.slug}?promo=${bonusCode}`; useEffect(() => { if (showQr) { QRCode.toDataURL(targetUrl, { width: 240, margin: 1, color: { dark: '#020617', light: '#ffffff', }, }) .then(setQrDataUrl) .catch(console.error); } }, [targetUrl, showQr]); const copyPromo = () => { navigator.clipboard.writeText(bonusCode); setCopiedPromo(true); setTimeout(() => setCopiedPromo(false), 2000); }; const copyTargetUrl = () => { navigator.clipboard.writeText(targetUrl); setCopiedLink(true); setTimeout(() => setCopiedLink(false), 2000); }; const appName = resolveLocalised(app.name, locale); const appTagline = resolveLocalised(app.tagline, locale); return (
{/* Ambient background glow */}
{/* Left Column: Copy, Bonus & Clickable Store Buttons */}
{/* Header Badge */}
NATIVE IOS & ANDROID APP {app.rating && ( {app.rating.value} ({(app.rating.count / 1000).toFixed(0)}k+ creators) )}
{/* Main Headline */}

{tool ? `Continue in ${appName} with 4K Lossless Export` : `Download ${appName}`}

Experience zero-latency hardware-accelerated neural processing, batch photoshoot enhancement, fine-tuning sliders, and uncompressed 4K export directly on your phone.

{/* Key Feature Perks List */}
4K Lossless Uncompressed Export
On-Device Neural Engine Acceleration
Batch Multi-Photo Enhancement
Offline Private Mode (100% Private)
{/* Welcome Bonus Promo Banner */} {showBonus && (

{app.welcomeBonus?.title || '50 Free 4K HD Export Credits'}

Claim promo code on first mobile launch

)} {/* Official Clickable App Store & Google Play Buttons */}

Available now for instant install:

{/* Apple App Store Official Badge Button */}
Download on the Apple App Store
{/* Google Play Store Official Badge Button */}
GET IT ON Google Play
{/* Disclaimer */}

{resolveLocalised(app.creditsNote, locale, 'Credits and in-app purchases are specific to this app.')}

{/* Right Column: High-Tech Futuristic QR Code Scanner Card */} {showQr && qrDataUrl && (
{/* Ambient Glow */}
{/* Animated Futuristic Laser Reticle Corners */} {/* QR Code Presentation Canvas */}
{/* eslint-disable-next-line @next/next/no-img-element */} Scan QR code to install app
{/* Status Beacon & Camera Target */}
Point Camera to Scan

Opens app store listing instantly with promo code pre-applied

{/* Quick Copy Link Action */}
)}
); }