/** * @license * SPDX-License-Identifier: Apache-2.0 */ import React, { useState, useMemo } from 'react'; import { motion } from 'motion/react'; import { Megaphone, Share2, Copy, Check, Download, MessageSquare, Sparkles, ChevronRight, FileImage, Tag, Percent, Search } from 'lucide-react'; import { TireProduct, SystemSettings } from '../types'; interface SocialPromoterProps { products: TireProduct[]; settings: SystemSettings; } export default function SocialPromoter({ products, settings }: SocialPromoterProps) { const [selectedProdId, setSelectedProdId] = useState(products[0]?.id || ''); const [marketingTopic, setMarketingTopic] = useState<'DISCOUNT' | 'SAFETY' | 'WINTER' | 'PERFORMANCE'>('DISCOUNT'); const [promoCode, setPromoCode] = useState('HAIDER_TREATS_26'); const [customDiscountPercent, setCustomDiscountPercent] = useState(10); const [copied, setCopied] = useState(false); const [promSearch, setPromSearch] = useState(''); const selectedProduct = useMemo(() => { return products.find(p => p.id === selectedProdId) || products[0] || null; }, [products, selectedProdId]); // Dynamic search list const filteredProducts = useMemo(() => { return products.filter(p => p.brand.toLowerCase().includes(promSearch.toLowerCase()) || p.model.toLowerCase().includes(promSearch.toLowerCase()) || p.size.toLowerCase().includes(promSearch.toLowerCase()) ); }, [products, promSearch]); // Math calculated prices const promoPrice = useMemo(() => { if (!selectedProduct) return 0; const computed = selectedProduct.price * (1 - (customDiscountPercent / 100)); return Math.round(computed); }, [selectedProduct, customDiscountPercent]); // High conversion copy algorithms based on topic const promoCopyText = useMemo(() => { if (!selectedProduct) return ''; const brand = selectedProduct.brand.toUpperCase(); const model = selectedProduct.model; const size = selectedProduct.size; const oldPriceStr = `${settings.currencySymbol}${selectedProduct.price.toLocaleString()}`; const newPriceStr = `${settings.currencySymbol}${promoPrice.toLocaleString()}`; switch(marketingTopic) { case 'DISCOUNT': return `šŸ”„ *MEGA TIRE DEAL AT HAIDER BROTHER TRADERS* šŸ”„\n\nUpgrade your ride with premium *${brand} ${model}* tires today! Under our limited-time warehouse clearance festival, enjoy unprecedented markdowns!\n\nšŸ›ž *Profile Specs:* ${size}\nšŸ’° *Regular MSRP:* ~${oldPriceStr}~\nšŸ“‰ *Promotional rate:* *${newPriceStr}* (SAVE ${customDiscountPercent}%!)\nšŸŽŸļø *Use checkout token:* \`${promoCode}\` for free nitrogen fill!\n\nšŸ¢ *Branch Address:* ${settings.shopAddress}\nšŸ“ž *Order Line Call/WhatsApp:* ${settings.shopPhone}\n\n_Drive safe, drive on certified treads! #HaiderBrotherTraders #PremiumTyreClearance #SafeJourneys_`; case 'SAFETY': return `šŸŒ§ļø *MONSOON ROAD SAFETY INITIATIVE — HAIDER BROTHERS* šŸŒ§ļø\n\nDid you inspect your tire tread lines recently? Worn tire grooves are highly dangerous under wet road conditions!\n\nEquip your vehicle with fresh high-traction *${brand} ${model}* SUV/Passenger radial tires today. Maximum hydroplaning resistance:\n\nšŸ›ž *Specs Size:* ${size}\n⚔ *Active Grips Price:* *${newPriceStr}* per piece (includes balancing check!)\nšŸŽ–ļø *Features:* Steel Belted, Deep wet-road grip grooves.\n\nšŸ¢ *Stop By:* ${settings.shopAddress}\n✨ *Hotline:* ${settings.shopPhone}\n\n_Protect your family. Invest in solid road friction! #TyreSafetyCheck #HaiderTradersQuetta_`; case 'WINTER': return `ā„ļø *AGGRESSIVE TERRAIN GRIP SPECIALISTS* ā„ļø\n\nConquer unpredictable paths and mountain highways with rugged All-Terrain *${brand} ${model}* treads!\n\nEngineered to withstand extreme temperature ranges and gravel trails:\n\nšŸ›ž *Tire profile size:* ${size}\nšŸ’° *Promo cost:* *${newPriceStr}* (Original MSRP: ~${oldPriceStr}~)\n🚜 *Ideal for:* SUV Crossovers, Light Freight rigs, and heavy loading.\n\nšŸ¢ *Stop by our Auto Vault:* ${settings.shopAddress}\nšŸ“ž *Call for booking advice:* ${settings.shopPhone}\n\n_No territory is too hard. Travel fearlessly! #TerrainMastery #SailunTerramax #BridgestonePak #HaiderBrothers_`; case 'PERFORMANCE': return `šŸŽļø *ELITE RACING COMPOUND HANDLINGS — HIGH PERFORMANCE* šŸŽļø\n\nUnleash extreme tarmac performance and responsive steering control with premium racing radial *${brand} ${model}*!\n\nEngineered by Yokohama/Bridgestone for high cornering friction matrices:\n\nšŸ›ž *Dimension size:* ${size}\nšŸ *Precision Rate:* *${newPriceStr}* (Limited retail sets available!)\nšŸ› ļø *Complimentary layout:* Balancing, high-durability valves and nitrogen check done on spot.\n\nšŸ“ž *Reserve yours now:* ${settings.shopPhone}\nšŸ¢ *Haider Brother Traders* — Quetta's No. 1 premium hub.\n\n_Upgrade handling, transform high-speed braking thresholds! #AdvanComfort #YokohamaDB #PremiumRadials_`; } }, [selectedProduct, marketingTopic, promoPrice, customDiscountPercent, promoCode, settings]); const handleCopyClipboard = () => { navigator.clipboard.writeText(promoCopyText); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const shareWhatsApp = () => { const encoded = encodeURIComponent(promoCopyText); window.open(`https://api.whatsapp.com/send?text=${encoded}`, '_blank'); }; const shareFacebook = () => { const link = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent("https://haidertraders.com"); window.open(link, '_blank'); }; // Compile a highly polished self-contained single-flyer visual page HTML and download it! const downloadFlyerHTML = () => { if (!selectedProduct) return; // Theme colors predicated on campaign topic let gradient = "linear-gradient(135deg, #1e3a8a, #0f172a)"; // blue if (marketingTopic === 'SAFETY') gradient = "linear-gradient(135deg, #0f766e, #0f172a)"; // teal if (marketingTopic === 'WINTER') gradient = "linear-gradient(135deg, #4338ca, #111827)"; // dark indigo if (marketingTopic === 'PERFORMANCE') gradient = "linear-gradient(135deg, #b91c1c, #0f172a)"; // red const flyerHTML = ` Marketing Poster - ${selectedProduct.brand}
${marketingTopic} SPECIAL
${selectedProduct.brand}
${selectedProduct.model}
Haider Brother Traders Premium Radial
${selectedProduct.size}

${selectedProduct.description || "Incomparably robust tread design built for extreme wear and wet grip."}

MSRP: ${settings.currencySymbol}${selectedProduct.price.toLocaleString()}
PROMO DEAL
${settings.currencySymbol}${promoPrice.toLocaleString()}
`; const blob = new Blob([flyerHTML], { type: 'text/html' }); const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = `Promo flyer_${selectedProduct.brand}_${selectedProduct.model}.html`; link.click(); }; return (
{/* Mega header explaining direct shares */}
šŸš€ SOCIAL PROMOTION MULTIPLIER

Social Marketing Campaign Wizard

Generate high-converting ads and social outreach posts directly from live stock indices to WhatsApp, FB, and downloadable digital pamphlets.

{/* LEFT COLUMN: Setup flyer parameters */}
Campaign Parameters
{/* Search match */}
setPromSearch(e.target.value)} className="w-full text-xs border border-slate-200 p-2 pl-8 rounded-lg outline-none focus:border-slate-800 bg-white transition" />
{/* Marketing Theme Selection */}
{/* Pricing configurations & promo codes */}
setCustomDiscountPercent(Math.min(90, Math.max(0, parseInt(e.target.value) || 0)))} className="w-full text-xs font-mono border border-slate-200 bg-white px-3 py-2 rounded-lg outline-none focus:border-slate-800 transition" />
setPromoCode(e.target.value.toUpperCase())} className="w-full text-xs font-mono font-bold border border-slate-200 bg-white px-3 py-2 rounded-lg outline-none text-slate-900 focus:border-slate-800 transition" />
{/* MIDDLE COLUMN: Text marketing output copy block */}
Social Outgoing Copy (Refined)