2026-11-03 12:24:43 +05:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import QRCode from 'qrcode';
|
2026-11-05 10:26:19 +05:30
|
|
|
import {
|
|
|
|
|
Smartphone,
|
|
|
|
|
Copy,
|
|
|
|
|
Check,
|
|
|
|
|
ExternalLink,
|
2026-11-06 10:53:55 +05:30
|
|
|
ShieldCheck
|
2026-11-05 10:26:19 +05:30
|
|
|
} from 'lucide-react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import { AppItem, ToolItem, resolveLocalised } from '@/types';
|
2026-11-06 18:38:45 +05:30
|
|
|
import { KineticText } from '@/components/magicui/kinetic-text';
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
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>('');
|
2026-11-05 10:26:19 +05:30
|
|
|
const [copiedPromo, setCopiedPromo] = useState(false);
|
|
|
|
|
const [copiedLink, setCopiedLink] = useState(false);
|
|
|
|
|
const [origin, setOrigin] = useState<string>('');
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
|
setOrigin(window.location.origin);
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
if (!app) return null;
|
|
|
|
|
|
|
|
|
|
const bonusCode = app.welcomeBonus?.code || 'TRYWEB50';
|
2026-11-05 10:26:19 +05:30
|
|
|
const baseHost = origin || 'http://localhost:3000';
|
2026-11-03 12:24:43 +05:30
|
|
|
const targetUrl = tool
|
2026-11-05 10:26:19 +05:30
|
|
|
? `${baseHost}/go/${tool.slug}/${app.slug}?promo=${bonusCode}`
|
|
|
|
|
: `${baseHost}/apps/${app.slug}?promo=${bonusCode}`;
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (showQr) {
|
|
|
|
|
QRCode.toDataURL(targetUrl, {
|
2026-11-06 10:53:55 +05:30
|
|
|
width: 220,
|
2026-11-03 12:24:43 +05:30
|
|
|
margin: 1,
|
|
|
|
|
color: {
|
2026-11-06 10:53:55 +05:30
|
|
|
dark: '#141E28',
|
|
|
|
|
light: '#F8F9FA',
|
2026-11-03 12:24:43 +05:30
|
|
|
},
|
|
|
|
|
})
|
2026-11-06 10:53:55 +05:30
|
|
|
.then((url) => setQrDataUrl(url))
|
|
|
|
|
.catch(() => {});
|
2026-11-03 12:24:43 +05:30
|
|
|
}
|
2026-11-06 10:53:55 +05:30
|
|
|
}, [showQr, targetUrl]);
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
const copyPromo = () => {
|
|
|
|
|
navigator.clipboard.writeText(bonusCode);
|
2026-11-05 10:26:19 +05:30
|
|
|
setCopiedPromo(true);
|
|
|
|
|
setTimeout(() => setCopiedPromo(false), 2000);
|
2026-11-03 12:24:43 +05:30
|
|
|
};
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
const copyLink = () => {
|
2026-11-05 10:26:19 +05:30
|
|
|
navigator.clipboard.writeText(targetUrl);
|
|
|
|
|
setCopiedLink(true);
|
|
|
|
|
setTimeout(() => setCopiedLink(false), 2000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const appName = resolveLocalised(app.name, locale);
|
|
|
|
|
const appTagline = resolveLocalised(app.tagline, locale);
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
return (
|
2026-11-06 18:38:45 +05:30
|
|
|
<section id="app-handoff" className="py-16 sm:py-24 bg-paper border-b border-rule relative overflow-hidden">
|
|
|
|
|
{/* Studio Lighting Background Glow */}
|
|
|
|
|
<div
|
|
|
|
|
className="pointer-events-none absolute top-10 left-10 w-[500px] h-[350px] [background:radial-gradient(ellipse_at_center,color-mix(in_oklab,var(--color-accent)_12%,transparent)_0%,transparent_70%)]"
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-8 space-y-10 relative z-10">
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Section Header */}
|
|
|
|
|
<div className="max-w-2xl space-y-2 border-b border-rule pb-5">
|
|
|
|
|
<h2 className="text-3xl sm:text-4xl font-display font-bold text-ink tracking-tight">
|
2026-11-06 18:38:45 +05:30
|
|
|
<KineticText>Continue on mobile</KineticText>
|
2026-11-06 10:53:55 +05:30
|
|
|
</h2>
|
|
|
|
|
<p className="text-sm sm:text-base text-ink-2 font-body text-pretty">
|
|
|
|
|
Handoff this tool directly to your iOS or Android phone with 50 bonus credits.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-11-05 10:26:19 +05:30
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">
|
|
|
|
|
{/* Left Column: App Specifications & Store Buttons */}
|
2026-11-06 18:38:45 +05:30
|
|
|
<div className="lg:col-span-7 studio-sheet rounded-3xl p-6 sm:p-8 space-y-6">
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="border-b border-rule pb-5 space-y-2">
|
|
|
|
|
<span className="text-xs text-muted font-body">Dedicated companion client</span>
|
|
|
|
|
<h3 className="text-2xl font-display font-bold text-ink">
|
|
|
|
|
{appName}
|
|
|
|
|
</h3>
|
|
|
|
|
<p className="text-sm text-ink-2 font-body leading-relaxed">
|
|
|
|
|
{appTagline}
|
2026-11-05 10:26:19 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Promo Voucher */}
|
2026-11-03 12:24:43 +05:30
|
|
|
{showBonus && (
|
2026-11-06 18:38:45 +05:30
|
|
|
<div className="p-4 bg-paper-2 border border-rule rounded-2xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-0.5">
|
|
|
|
|
<span className="text-xs font-body font-semibold text-ink">
|
|
|
|
|
50 Free credits voucher code
|
|
|
|
|
</span>
|
|
|
|
|
<p className="text-xs text-muted font-body">
|
|
|
|
|
Enter during installation for complimentary batch runs.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-2">
|
2026-11-06 18:38:45 +05:30
|
|
|
<span className="font-body text-sm font-semibold text-accent px-3 py-1 bg-paper-hi border border-rule rounded-full">
|
2026-11-06 10:53:55 +05:30
|
|
|
{bonusCode}
|
|
|
|
|
</span>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={copyPromo}
|
2026-11-06 18:38:45 +05:30
|
|
|
className="btn-secondary text-xs px-3 py-1.5 rounded-full min-h-[36px]"
|
2026-11-06 10:53:55 +05:30
|
|
|
aria-label="Copy voucher code"
|
|
|
|
|
>
|
|
|
|
|
{copiedPromo ? <Check className="w-3.5 h-3.5 text-accent" aria-hidden="true" /> : <Copy className="w-3.5 h-3.5 text-muted" aria-hidden="true" />}
|
|
|
|
|
</button>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Official Store Buttons */}
|
|
|
|
|
<div className="pt-2 space-y-3">
|
|
|
|
|
<span className="text-xs text-muted font-body block">Direct store installation</span>
|
2026-11-06 18:38:45 +05:30
|
|
|
<div className="flex flex-col sm:flex-row flex-wrap gap-3">
|
2026-11-05 10:26:19 +05:30
|
|
|
<a
|
|
|
|
|
href={app.stores?.ios?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
2026-11-06 18:38:45 +05:30
|
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
2026-11-05 10:26:19 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<Smartphone className="w-4 h-4 text-accent" aria-hidden="true" />
|
|
|
|
|
<span>Apple App Store</span>
|
2026-11-06 18:38:45 +05:30
|
|
|
<ExternalLink className="w-3.5 h-3.5 text-muted ml-1" aria-hidden="true" />
|
2026-11-05 10:26:19 +05:30
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
href={app.stores?.android?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
2026-11-06 18:38:45 +05:30
|
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
2026-11-05 10:26:19 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<Smartphone className="w-4 h-4 text-accent" aria-hidden="true" />
|
|
|
|
|
<span>Google Play</span>
|
2026-11-06 18:38:45 +05:30
|
|
|
<ExternalLink className="w-3.5 h-3.5 text-muted ml-1" aria-hidden="true" />
|
2026-11-05 10:26:19 +05:30
|
|
|
</a>
|
2026-11-03 12:24:43 +05:30
|
|
|
|
2026-11-05 10:26:19 +05:30
|
|
|
<button
|
|
|
|
|
type="button"
|
2026-11-06 10:53:55 +05:30
|
|
|
onClick={copyLink}
|
2026-11-06 18:38:45 +05:30
|
|
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
2026-11-06 10:53:55 +05:30
|
|
|
aria-label="Copy direct deep link"
|
2026-11-05 10:26:19 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
{copiedLink ? <Check className="w-4 h-4 text-accent" aria-hidden="true" /> : <Copy className="w-4 h-4 text-muted" aria-hidden="true" />}
|
|
|
|
|
<span>{copiedLink ? 'Link copied' : 'Copy link'}</span>
|
2026-11-05 10:26:19 +05:30
|
|
|
</button>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-11-05 10:26:19 +05:30
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="pt-2 text-xs text-muted font-body">
|
|
|
|
|
{resolveLocalised(app.creditsNote, locale, 'Credits and in-app purchases are specific to this app.')}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Right Column: Clean QR Code Card */}
|
|
|
|
|
{showQr && qrDataUrl && (
|
2026-11-06 18:38:45 +05:30
|
|
|
<div className="lg:col-span-5 studio-sheet rounded-3xl p-6 sm:p-8 text-center flex flex-col items-center">
|
2026-11-06 10:53:55 +05:30
|
|
|
<span className="text-xs text-muted font-body mb-4">Scan with phone camera</span>
|
|
|
|
|
|
2026-11-06 18:38:45 +05:30
|
|
|
<div className="p-4 bg-paper-hi border border-rule rounded-2xl inline-block shadow-sm">
|
2026-11-06 10:53:55 +05:30
|
|
|
<img
|
|
|
|
|
src={qrDataUrl}
|
|
|
|
|
alt="Scan QR code to install app"
|
2026-11-06 18:38:45 +05:30
|
|
|
className="w-44 h-44 object-contain rounded-xl"
|
2026-11-06 10:53:55 +05:30
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="mt-4 space-y-1 text-xs font-body text-muted">
|
|
|
|
|
<p className="font-medium text-ink">Instant mobile handoff</p>
|
|
|
|
|
<p>Directs to App Store or Google Play with {bonusCode} applied automatically.</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|