149 lines
6.3 KiB
TypeScript
149 lines
6.3 KiB
TypeScript
'use client';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import QRCode from 'qrcode';
|
|
import { Smartphone, QrCode, Copy, Check, Gift, ExternalLink } 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<string>('');
|
|
const [copied, setCopied] = useState(false);
|
|
|
|
if (!app) return null;
|
|
|
|
const bonusCode = app.welcomeBonus?.code || 'TRYWEB50';
|
|
const targetUrl = tool
|
|
? `http://localhost:3000/go/${tool.slug}/${app.slug}?promo=${bonusCode}`
|
|
: `http://localhost:3000/apps/${app.slug}?promo=${bonusCode}`;
|
|
|
|
useEffect(() => {
|
|
if (showQr) {
|
|
QRCode.toDataURL(targetUrl, {
|
|
width: 200,
|
|
margin: 1,
|
|
color: {
|
|
dark: '#0f172a',
|
|
light: '#ffffff',
|
|
},
|
|
})
|
|
.then(setQrDataUrl)
|
|
.catch(console.error);
|
|
}
|
|
}, [targetUrl, showQr]);
|
|
|
|
const copyPromo = () => {
|
|
navigator.clipboard.writeText(bonusCode);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 2000);
|
|
};
|
|
|
|
return (
|
|
<section className="py-20 sm:py-28 bg-[#FAF8F5] border-t border-slate-900/[0.08] relative overflow-hidden">
|
|
<div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
|
|
<div className="bg-white rounded-3xl p-8 sm:p-12 border border-slate-900/[0.08] shadow-cream-md flex flex-col md:flex-row items-center justify-between gap-8 sm:gap-12">
|
|
{/* Left Column: Copy & Store CTA */}
|
|
<div className="space-y-5 max-w-xl">
|
|
<div className="inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full bg-blue-50 border border-blue-200 text-xs font-mono font-semibold text-blue-700">
|
|
<Smartphone className="w-3.5 h-3.5 text-blue-600" />
|
|
<span>NATIVE IOS & ANDROID APPS</span>
|
|
</div>
|
|
|
|
<h3 className="text-2xl sm:text-3xl lg:text-4xl font-display font-black text-slate-900 tracking-tight">
|
|
{tool
|
|
? `Continue in ${resolveLocalised(app.name, locale)} with 4K Lossless Export`
|
|
: `Download ${resolveLocalised(app.name, locale)}`}
|
|
</h3>
|
|
|
|
<p className="text-xs sm:text-sm text-slate-600 leading-relaxed font-normal">
|
|
Experience zero-latency hardware-accelerated neural processing, batch photoshoot enhancement, and professional fine-tuning sliders on your phone.
|
|
</p>
|
|
|
|
{/* Welcome Bonus Promo Banner */}
|
|
{showBonus && (
|
|
<div className="p-4 sm:p-5 rounded-2xl bg-amber-50/70 border border-amber-200 flex items-center justify-between shadow-sm">
|
|
<div className="flex items-center gap-3.5">
|
|
<div className="w-11 h-11 rounded-xl bg-amber-100 border border-amber-300 flex items-center justify-center text-amber-700 shrink-0">
|
|
<Gift className="w-5 h-5" />
|
|
</div>
|
|
<div>
|
|
<p className="text-xs sm:text-sm font-display font-bold text-slate-900">
|
|
{app.welcomeBonus?.title || '50 Free HD Export Credits'}
|
|
</p>
|
|
<p className="text-[11px] font-mono text-slate-600">
|
|
Claim promo code on first mobile launch
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<button
|
|
onClick={copyPromo}
|
|
className="inline-flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-xs font-mono font-bold bg-white border border-amber-300 text-amber-900 hover:bg-amber-100 shadow-sm transition-all active:scale-95"
|
|
>
|
|
{copied ? <Check className="w-3.5 h-3.5 text-emerald-600" /> : <Copy className="w-3.5 h-3.5 text-amber-700" />}
|
|
<span>{bonusCode}</span>
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{/* Store Download Buttons */}
|
|
<div className="flex flex-wrap items-center gap-3 pt-2">
|
|
<a
|
|
href={app.stores.android?.url || '#'}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="px-6 py-3 rounded-full text-xs font-bold text-white bg-slate-900 hover:bg-slate-800 shadow-sm transition-all flex items-center gap-2 hover:scale-105 active:scale-95"
|
|
>
|
|
<span>Google Play</span>
|
|
<ExternalLink className="w-3.5 h-3.5 opacity-60" />
|
|
</a>
|
|
<a
|
|
href={app.stores.ios?.url || '#'}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="px-6 py-3 rounded-full text-xs font-bold text-slate-900 bg-slate-100 border border-slate-300 hover:bg-slate-200 shadow-sm transition-all flex items-center gap-2 hover:scale-105 active:scale-95"
|
|
>
|
|
<span>Apple App Store</span>
|
|
<ExternalLink className="w-3.5 h-3.5 opacity-60" />
|
|
</a>
|
|
</div>
|
|
|
|
{/* Disclaimer */}
|
|
<p className="text-[11px] font-mono text-slate-500 italic">
|
|
{resolveLocalised(app.creditsNote, locale, 'Credits and in-app purchases are specific to this app.')}
|
|
</p>
|
|
</div>
|
|
|
|
{/* Right Column: QR Code Handoff */}
|
|
{showQr && qrDataUrl && (
|
|
<div className="text-center p-6 sm:p-8 rounded-3xl bg-[#FAF8F5] border border-slate-200 shadow-inner shrink-0">
|
|
<div className="p-3 bg-white rounded-2xl shadow-md inline-block border border-slate-100">
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
<img src={qrDataUrl} alt="Scan QR code to install app" className="w-36 h-36 sm:w-40 sm:h-40" />
|
|
</div>
|
|
<div className="mt-4 flex items-center justify-center gap-2 text-xs font-mono font-bold text-slate-800">
|
|
<QrCode className="w-4 h-4 text-blue-600" />
|
|
<span>Scan with phone camera</span>
|
|
</div>
|
|
<p className="text-[10px] font-mono text-slate-500 mt-1">Instant redirect to store listing</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|