345 lines
16 KiB
TypeScript
345 lines
16 KiB
TypeScript
'use client';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import QRCode from 'qrcode';
|
|
import {
|
|
Smartphone,
|
|
Sparkles,
|
|
Copy,
|
|
Check,
|
|
ExternalLink,
|
|
ShieldCheck,
|
|
Zap,
|
|
Star,
|
|
Layers,
|
|
CheckCircle2,
|
|
ArrowRight
|
|
} from 'lucide-react';
|
|
import { ToolItem, AppItem, resolveLocalised } from '@/types';
|
|
|
|
interface PostResultAppHandoffProps {
|
|
tool: ToolItem;
|
|
app?: AppItem | null;
|
|
locale?: string;
|
|
hasDownloaded?: boolean;
|
|
variant?: 'post-result' | 'landing';
|
|
}
|
|
|
|
export function PostResultAppHandoff({
|
|
tool,
|
|
app,
|
|
locale = 'en',
|
|
hasDownloaded = false,
|
|
variant = 'post-result',
|
|
}: PostResultAppHandoffProps) {
|
|
const [qrDataUrl, setQrDataUrl] = useState<string>('');
|
|
const [copiedLink, setCopiedLink] = useState(false);
|
|
const [origin, setOrigin] = useState<string>('');
|
|
|
|
useEffect(() => {
|
|
if (typeof window !== 'undefined') {
|
|
setOrigin(window.location.origin);
|
|
}
|
|
}, []);
|
|
|
|
// Standard fallback app profile if none provided
|
|
const appData: AppItem = app || {
|
|
id: 'portrait-app',
|
|
slug: 'portrait-app',
|
|
status: 'published',
|
|
name: { en: 'Portrait Studio AI', hi: 'पोर्ट्रेट स्टूडियो एआई' },
|
|
tagline: { en: 'Natural professional portrait retouching in your pocket', hi: 'आपकी जेब में प्राकृतिक पेशेवर पोर्ट्रेट संपादन' },
|
|
description: { en: 'The all-in-one portrait perfection suite.', hi: 'सर्वश्रेष्ठ पोर्ट्रेट संपादन ऐप।' },
|
|
stores: {
|
|
android: {
|
|
packageId: 'com.creinnovations.portraitpro',
|
|
url: 'https://play.google.com/store/apps/details?id=com.creinnovations.portraitpro',
|
|
},
|
|
ios: {
|
|
appId: '1672384910',
|
|
url: 'https://apps.apple.com/app/id1672384910',
|
|
},
|
|
},
|
|
tools: [tool.id],
|
|
rating: {
|
|
value: 4.8,
|
|
count: 28400,
|
|
source: 'App Store & Google Play',
|
|
},
|
|
features: [
|
|
'Unlimited 4K batch processing for full galleries',
|
|
'Lossless RAW & Ultra-HD PNG export without compression',
|
|
'Instant offline on-device GPU inference',
|
|
'Exclusive pro retouching & neural enhancement styles',
|
|
],
|
|
};
|
|
|
|
const appName = resolveLocalised(appData.name, locale);
|
|
const toolName = tool.name ? resolveLocalised(tool.name, locale) : 'Photo Tools';
|
|
|
|
const baseHost = origin || 'http://localhost:3000';
|
|
const targetUrl = `${baseHost}/go/${tool.slug}/${appData.slug}?src=${variant}`;
|
|
const iosUrl = appData.stores?.ios?.url || `/go/${tool.slug}/${appData.slug}?src=ios`;
|
|
const androidUrl = appData.stores?.android?.url || `/go/${tool.slug}/${appData.slug}?src=android`;
|
|
|
|
// Generate dynamic QR Code for instant phone handoff
|
|
useEffect(() => {
|
|
QRCode.toDataURL(targetUrl, {
|
|
width: 240,
|
|
margin: 1,
|
|
color: {
|
|
dark: '#0f172a',
|
|
light: '#ffffff',
|
|
},
|
|
})
|
|
.then((url) => setQrDataUrl(url))
|
|
.catch((err) => console.error('Failed to generate QR code:', err));
|
|
}, [targetUrl]);
|
|
|
|
const handleCopyLink = (e: React.MouseEvent) => {
|
|
e.stopPropagation();
|
|
navigator.clipboard.writeText(targetUrl);
|
|
setCopiedLink(true);
|
|
setTimeout(() => setCopiedLink(false), 2200);
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={`w-full rounded-3xl border border-rule overflow-hidden transition-all shadow-sheet ${
|
|
variant === 'post-result'
|
|
? 'bg-gradient-to-b from-paper-hi via-paper-hi to-slate-50/60 p-6 sm:p-8 mt-8'
|
|
: 'bg-paper-hi p-6 sm:p-10'
|
|
}`}
|
|
>
|
|
{/* Post-Download Celebratory Toast (if user clicked download) */}
|
|
{hasDownloaded && (
|
|
<div className="mb-6 p-4 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-800 text-xs sm:text-sm font-sans flex items-center justify-between gap-3 animate-in fade-in slide-in-from-top-2 duration-300">
|
|
<div className="flex items-center gap-2.5">
|
|
<CheckCircle2 className="w-5 h-5 text-emerald-600 shrink-0" />
|
|
<span>
|
|
<strong>HD result saved!</strong> Need to edit more photos? Get <strong>{appName}</strong> for unlimited 4K batch processing.
|
|
</span>
|
|
</div>
|
|
<span className="hidden sm:inline-block px-2.5 py-1 rounded-full bg-emerald-600 text-white font-sans text-xs font-semibold shrink-0">
|
|
4K UNLIMITED READY
|
|
</span>
|
|
</div>
|
|
)}
|
|
|
|
{/* Primary Conversion Header */}
|
|
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-4 pb-6 border-b border-rule">
|
|
<div className="space-y-2">
|
|
{/* Rating & App Badge Pill */}
|
|
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-accent/10 border border-accent/20 text-accent font-sans text-xs font-semibold">
|
|
<div className="flex items-center gap-0.5 text-amber-500">
|
|
<Star className="w-3.5 h-3.5 fill-amber-400 text-amber-400" />
|
|
<span className="font-bold text-slate-800">{appData.rating?.value || 4.8}</span>
|
|
</div>
|
|
<span className="text-slate-300">|</span>
|
|
<span className="text-slate-700">Official Mobile App</span>
|
|
<span className="text-slate-300">|</span>
|
|
<span className="text-accent font-bold tracking-tight">Lossless 4K Mobile Studio</span>
|
|
</div>
|
|
|
|
<h3 className="text-xl sm:text-2xl font-display font-bold text-slate-900 tracking-tight">
|
|
{variant === 'post-result'
|
|
? `Love this result? Take it further in ${appName}`
|
|
: `Experience ${toolName} in ${appName}`}
|
|
</h3>
|
|
<p className="text-xs sm:text-sm text-slate-600 font-sans max-w-2xl leading-relaxed">
|
|
The web studio is limited to 5 single-photo tries daily. Install our native mobile app to process full photo galleries in <strong>4K lossless resolution</strong> with zero wait times.
|
|
</p>
|
|
</div>
|
|
|
|
{/* Mobile Platform Badge */}
|
|
<div className="shrink-0 p-3.5 rounded-2xl bg-paper-2 border border-rule flex items-center justify-between lg:justify-start gap-4">
|
|
<div className="space-y-0.5">
|
|
<div className="flex items-center gap-1.5 text-[11px] font-sans font-semibold text-slate-500 uppercase tracking-wider">
|
|
<Smartphone className="w-3.5 h-3.5 text-accent" />
|
|
<span>Platform Compatibility</span>
|
|
</div>
|
|
<span className="font-sans font-semibold text-xs text-slate-900 tracking-tight block">
|
|
iOS 15+ • Android 9+
|
|
</span>
|
|
</div>
|
|
<a
|
|
href={targetUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="inline-flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-xs font-sans font-semibold bg-accent text-white hover:bg-accent/90 shadow-2xs transition-all cursor-pointer shrink-0"
|
|
>
|
|
<span>Get App</span>
|
|
<ArrowRight className="w-3.5 h-3.5" />
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Main Grid: Features vs Installation Options */}
|
|
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 pt-6 items-center">
|
|
|
|
{/* Left Column: Why Upgrade to App (Perks List) */}
|
|
<div className="lg:col-span-7 space-y-4">
|
|
<span className="text-xs font-sans font-bold text-slate-900 uppercase tracking-wider block">
|
|
Why creators use the mobile app:
|
|
</span>
|
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
|
|
|
<div className="p-3.5 rounded-2xl bg-paper-2/70 border border-rule space-y-1">
|
|
<div className="flex items-center gap-2">
|
|
<div className="w-6 h-6 rounded-lg bg-accent/15 flex items-center justify-center shrink-0">
|
|
<Zap className="w-3.5 h-3.5 text-accent" />
|
|
</div>
|
|
<h5 className="text-xs font-sans font-bold text-slate-900">
|
|
Unlimited 4K Batch Runs
|
|
</h5>
|
|
</div>
|
|
<p className="text-[11px] text-slate-500 font-sans leading-relaxed pl-8">
|
|
Edit 50+ photos at once with zero web limits or queues.
|
|
</p>
|
|
</div>
|
|
|
|
<div className="p-3.5 rounded-2xl bg-paper-2/70 border border-rule space-y-1">
|
|
<div className="flex items-center gap-2">
|
|
<div className="w-6 h-6 rounded-lg bg-emerald-500/15 flex items-center justify-center shrink-0">
|
|
<Sparkles className="w-3.5 h-3.5 text-emerald-600" />
|
|
</div>
|
|
<h5 className="text-xs font-sans font-bold text-slate-900">
|
|
Lossless RAW Quality
|
|
</h5>
|
|
</div>
|
|
<p className="text-[11px] text-slate-500 font-sans leading-relaxed pl-8">
|
|
Retain original camera sensor megapixels and skin textures.
|
|
</p>
|
|
</div>
|
|
|
|
<div className="p-3.5 rounded-2xl bg-paper-2/70 border border-rule space-y-1">
|
|
<div className="flex items-center gap-2">
|
|
<div className="w-6 h-6 rounded-lg bg-indigo-500/15 flex items-center justify-center shrink-0">
|
|
<Layers className="w-3.5 h-3.5 text-indigo-600" />
|
|
</div>
|
|
<h5 className="text-xs font-sans font-bold text-slate-900">
|
|
Instant On-Device GPU
|
|
</h5>
|
|
</div>
|
|
<p className="text-[11px] text-slate-500 font-sans leading-relaxed pl-8">
|
|
Hardware neural acceleration for sub-second offline edits.
|
|
</p>
|
|
</div>
|
|
|
|
<div className="p-3.5 rounded-2xl bg-paper-2/70 border border-rule space-y-1">
|
|
<div className="flex items-center gap-2">
|
|
<div className="w-6 h-6 rounded-lg bg-amber-500/15 flex items-center justify-center shrink-0">
|
|
<ShieldCheck className="w-3.5 h-3.5 text-amber-600" />
|
|
</div>
|
|
<h5 className="text-xs font-sans font-bold text-slate-900">
|
|
100% Private & Ad-Free
|
|
</h5>
|
|
</div>
|
|
<p className="text-[11px] text-slate-500 font-sans leading-relaxed pl-8">
|
|
No telemetry, no watermarks, and zero cloud photo storage.
|
|
</p>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* Direct Store Download Action Buttons */}
|
|
<div className="pt-2 space-y-2">
|
|
<span className="text-[11px] font-sans text-slate-500">
|
|
Direct store download links:
|
|
</span>
|
|
|
|
<div className="flex flex-wrap items-center gap-3">
|
|
{/* Apple App Store Official Badge Button */}
|
|
<a
|
|
href={iosUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="inline-flex items-center gap-3 px-5 py-3 rounded-2xl bg-slate-900 hover:bg-slate-800 text-white shadow-md hover:scale-[1.02] active:scale-98 transition-all cursor-pointer"
|
|
>
|
|
<svg className="w-5 h-5 fill-current shrink-0" viewBox="0 0 24 24" aria-hidden="true">
|
|
<path d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M15.97 6.37c.62-.75 1.04-1.8 0.92-2.85-.9.04-2 .6-2.65 1.35-.58.67-1.09 1.74-.95 2.77.99.08 2.06-.52 2.68-1.27z"/>
|
|
</svg>
|
|
<div className="text-left font-sans leading-none">
|
|
<span className="text-[10px] text-slate-300 block uppercase tracking-wider">Download on the</span>
|
|
<span className="text-sm font-bold tracking-tight">App Store</span>
|
|
</div>
|
|
<ExternalLink className="w-3.5 h-3.5 text-slate-400 ml-1" />
|
|
</a>
|
|
|
|
{/* Google Play Official Badge Button */}
|
|
<a
|
|
href={androidUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="inline-flex items-center gap-3 px-5 py-3 rounded-2xl bg-slate-900 hover:bg-slate-800 text-white shadow-md hover:scale-[1.02] active:scale-98 transition-all cursor-pointer"
|
|
>
|
|
<svg className="w-5 h-5 shrink-0" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
<path d="M3.6 1.4A1.6 1.6 0 0 0 3 2.8v18.4a1.6 1.6 0 0 0 .6 1.4l10.3-10.5L3.6 1.4z" fill="#00C3FF" />
|
|
<path d="M17.4 8.7l-3.5 3.4 3.5 3.5 4-2.3a1.7 1.7 0 0 0 0-2.3l-4-2.3z" fill="#FFC800" />
|
|
<path d="M3.6 22.6l10.3-10.5 3.5 3.5-12.2 7a1.6 1.6 0 0 1-1.6 0z" fill="#FF3A44" />
|
|
<path d="M3.6 1.4L15.8 8.4l-3.5 3.7L3.6 1.4z" fill="#00E676" />
|
|
</svg>
|
|
<div className="text-left font-sans leading-none">
|
|
<span className="text-[10px] text-slate-300 block uppercase tracking-wider">GET IT ON</span>
|
|
<span className="text-sm font-bold tracking-tight">Google Play</span>
|
|
</div>
|
|
<ExternalLink className="w-3.5 h-3.5 text-slate-400 ml-1" />
|
|
</a>
|
|
|
|
{/* Copy Direct Link */}
|
|
<button
|
|
type="button"
|
|
onClick={handleCopyLink}
|
|
className="inline-flex items-center gap-2 px-4 py-3 rounded-2xl bg-paper-2 hover:bg-paper text-slate-700 text-xs font-sans font-semibold border border-rule transition-colors cursor-pointer"
|
|
>
|
|
{copiedLink ? <Check className="w-3.5 h-3.5 text-emerald-600" /> : <Copy className="w-3.5 h-3.5 text-slate-500" />}
|
|
<span>{copiedLink ? 'Link Copied!' : 'Copy App Link'}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Right Column: Scan with Camera QR Code Card */}
|
|
<div className="lg:col-span-5 flex flex-col items-center justify-center">
|
|
<div className="w-full max-w-xs p-5 rounded-3xl bg-white border border-slate-200/90 shadow-lg text-center space-y-3.5">
|
|
|
|
<div className="flex items-center justify-center gap-2 text-xs font-sans font-semibold text-slate-800">
|
|
<Smartphone className="w-4 h-4 text-accent" />
|
|
<span>Scan with Phone Camera</span>
|
|
</div>
|
|
|
|
{/* QR Code Canvas/Image */}
|
|
<div className="p-3 bg-slate-50 rounded-2xl border border-slate-100 flex items-center justify-center">
|
|
{qrDataUrl ? (
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
<img
|
|
src={qrDataUrl}
|
|
alt={`Scan QR code to install ${appName}`}
|
|
className="w-40 h-40 object-contain rounded-xl select-none"
|
|
/>
|
|
) : (
|
|
<div className="w-40 h-40 flex items-center justify-center text-xs text-slate-400">
|
|
Generating QR...
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
<div className="space-y-1">
|
|
<p className="text-[11px] text-slate-600 font-sans leading-tight">
|
|
Instantly opens App Store or Google Play directly on your phone.
|
|
</p>
|
|
<span className="inline-block text-[10px] text-slate-400 font-sans">
|
|
Works on iOS 15+ and Android 9+
|
|
</span>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
);
|
|
}
|