import React, { useState, useEffect } from 'react';
import { Upload, Type, Palette, Search, Menu, X, ArrowLeft, Heart, Star, ArrowRight, Wand2, Loader, MessageCircle, Mail, Phone, MapPin, Send, Info, Truck, AlertTriangle, Gift, Sparkles } from 'lucide-react';
// --- SEO HELPER FUNCTION ---
const updateSEO = (title, description, structuredData) => {
// Update Document Title
document.title = title;
// Update Meta Description
let metaDesc = document.querySelector('meta[name="description"]');
if (!metaDesc) {
metaDesc = document.createElement('meta');
metaDesc.name = "description";
document.head.appendChild(metaDesc);
}
metaDesc.content = description;
// Add Google Structured Data (Schema.org JSON-LD)
let scriptTag = document.getElementById('seo-structured-data');
if (!scriptTag) {
scriptTag = document.createElement('script');
scriptTag.id = 'seo-structured-data';
scriptTag.type = 'application/ld+json';
document.head.appendChild(scriptTag);
}
if (structuredData) {
scriptTag.textContent = JSON.stringify(structuredData);
}
};
// --- MOCK DATA ---
const categories = [
"Mugs Collection", "Keychains", "Photo Gifts", "Drinkware", "Office & Desk", "T-Shirt Printing", "Accessories"
];
// Home page par dikhane ke liye category representatives
const homeCategoryCards = [
{ id: 'cat1', name: "Mugs Collection", desc: "Magic, Red, Metallic & More", price: 179, categoryName: "Mugs Collection", image: "https://placehold.co/400x500/2563eb/ffffff?text=Mugs", bgGradient: "from-blue-400 to-blue-600" },
{ id: 'cat2', name: "Keychains", desc: "Acrylic Heart & Square", price: 89, categoryName: "Keychains", image: "https://placehold.co/400x500/db2777/ffffff?text=Keychains", bgGradient: "from-pink-400 to-pink-600" },
{ id: 'cat3', name: "T-Shirt Printing", desc: "Dryfit & Collar T-Shirts", price: 299, categoryName: "T-Shirt Printing", image: "https://placehold.co/400x500/16a34a/ffffff?text=T-Shirts", bgGradient: "from-green-400 to-green-600" },
{ id: 'cat4', name: "Photo Gifts", desc: "Frames & Magic Mirrors", price: 249, categoryName: "Photo Gifts", image: "https://placehold.co/400x500/eab308/ffffff?text=Photo+Gifts", bgGradient: "from-yellow-400 to-orange-500" },
{ id: 'cat5', name: "Office & Desk", desc: "Pen Stands & Mousepads", price: 149, categoryName: "Office & Desk", image: "https://placehold.co/400x500/ea580c/ffffff?text=Desk+Items", bgGradient: "from-purple-400 to-indigo-600" }
];
// Sabhi products ka detail data
const allProducts = [
// Mugs
{ id: 1, name: "Magic Mug", price: 199, category: "Mugs Collection", image: "https://placehold.co/400x400/2563eb/ffffff?text=Magic+Mug" },
{ id: 2, name: "Classic Red Colour Mug 11oz", price: 179, category: "Mugs Collection", image: "https://placehold.co/400x400/dc2626/ffffff?text=Red+Mug" },
{ id: 3, name: "Dual Color Magic Mug", price: 249, category: "Mugs Collection", image: "https://placehold.co/400x400/8b5cf6/ffffff?text=Dual+Color" },
{ id: 4, name: "Metallic Mug 11oz", price: 299, category: "Mugs Collection", image: "https://placehold.co/400x400/fbbf24/ffffff?text=Metallic+Mug" },
// Keychains
{ id: 5, name: "Acrylic Heart Keychain", price: 99, category: "Keychains", image: "https://placehold.co/400x400/db2777/ffffff?text=Heart+Keychain" },
{ id: 6, name: "Acrylic Square Keychain", price: 89, category: "Keychains", image: "https://placehold.co/400x400/9d174d/ffffff?text=Square+Keychain" },
// T-Shirts
{ id: 7, name: "Dryfit Round T-Shirt", price: 299, category: "T-Shirt Printing", image: "https://placehold.co/400x400/16a34a/ffffff?text=Round+T-Shirt" },
{ id: 8, name: "Collar Dryfit T-Shirt", price: 349, category: "T-Shirt Printing", image: "https://placehold.co/400x400/15803d/ffffff?text=Collar+T-Shirt" },
// Photo Gifts
{ id: 9, name: "Photo Frame with Light", price: 399, category: "Photo Gifts", image: "https://placehold.co/400x400/eab308/ffffff?text=Photo+Frame" },
{ id: 10, name: "Round Magic Mirror White", price: 249, category: "Photo Gifts", image: "https://placehold.co/400x400/0ea5e9/ffffff?text=Magic+Mirror" },
// Office & Desk
{ id: 11, name: "Ceramic Pen Stand", price: 199, category: "Office & Desk", image: "https://placehold.co/400x400/ea580c/ffffff?text=Pen+Stand" },
{ id: 12, name: "Custom Mousepad", price: 149, category: "Office & Desk", image: "https://placehold.co/400x400/4f46e5/ffffff?text=Mousepad" },
];
const testimonials = [
{ id: 1, name: "Aarav Patel", review: "The print quality on the Magic Mug is absolutely stunning! Ordered it for my sister's birthday and she loved the surprise when the photo appeared.", rating: 5 },
{ id: 2, name: "Priya Sharma", review: "Very fast delivery and the custom T-shirt fabric is incredibly soft. The live preview feature really helped me design exactly what I wanted.", rating: 5 },
{ id: 3, name: "Vikram Singh", review: "Bought the glowing photo frame. It looks premium and the lighting adds such a beautiful touch to my desk. Highly recommended!", rating: 4 }
];
export default function App() {
const [currentView, setCurrentView] = useState('home'); // 'home' | 'category' | 'product' | 'contact' | 'about' | 'shipping' | 'returns'
const [selectedCategory, setSelectedCategory] = useState(null);
const [selectedProduct, setSelectedProduct] = useState(null);
const [prefilledQuote, setPrefilledQuote] = useState(''); // Store AI quote to pass to product page
// Navigation Handlers
const goToCategory = (categoryName) => {
setSelectedCategory(categoryName);
setCurrentView('category');
window.scrollTo(0, 0);
};
const goToProduct = (product, quote = '') => {
setSelectedProduct(product);
setPrefilledQuote(quote);
setCurrentView('product');
window.scrollTo(0, 0);
};
const goHome = () => {
setCurrentView('home');
setSelectedCategory(null);
setSelectedProduct(null);
setPrefilledQuote('');
window.scrollTo(0, 0);
};
return (
{/* Header - Added Glassmorphism effect */}
{/* Main Content Area */}
{currentView === 'home' && }
{currentView === 'category' && (
)}
{currentView === 'product' && (
setCurrentView('category')}
/>
)}
{currentView === 'contact' && (
)}
{currentView === 'about' && (
)}
{currentView === 'shipping' && (
)}
{currentView === 'returns' && (
)}
{/* Footer */}
Printra.in
Your destination for premium customized gifts and merchandise.
{
setCurrentView('about');
window.scrollTo(0, 0);
}}
>
About Us
{
setCurrentView('contact');
window.scrollTo(0, 0);
}}
>
Contact
{
setCurrentView('shipping');
window.scrollTo(0, 0);
}}
>
Shipping Policy
{
setCurrentView('returns');
window.scrollTo(0, 0);
}}
>
Returns
{/* Floating WhatsApp Quick Support Button */}
{/* Tooltip on Hover */}
Quick Support
);
}
// ==========================================
// HOME VIEW COMPONENT (Category Grid & AI Feature)
// ==========================================
function HomeView({ onCategoryClick, onProductClick }) {
const [showAdvisor, setShowAdvisor] = useState(false);
const [adviseQuery, setAdviseQuery] = useState('');
const [adviseResults, setAdviseResults] = useState([]);
const [isAdvising, setIsAdvising] = useState(false);
// SEO for Home Page
useEffect(() => {
updateSEO(
"Printra.in - Custom Mugs, T-Shirts & Personalized Gifts Online",
"Buy premium custom printed mugs, t-shirts, keychains, and photo gifts at Printra.in. Easy customization and fast delivery in India.",
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "Printra.in",
"url": "https://www.printra.in",
"potentialAction": {
"@type": "SearchAction",
"target": "https://www.printra.in/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
);
}, []);
const handleAiAdvice = async () => {
if (!adviseQuery.trim()) return;
setIsAdvising(true);
setAdviseResults([]);
// Prepare a simplified product catalog for the AI to understand available options
const availableProductsForAI = allProducts.map(p => ({ id: p.id, name: p.name, category: p.category }));
const apiKey = ""; // Will be injected by runtime environment
try {
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-09-2025:generateContent?key=${apiKey}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contents: [{
parts: [{
text: `Gift Occasion/Recipient: ${adviseQuery}\n\nAvailable Products Catalog:\n${JSON.stringify(availableProductsForAI)}`
}]
}],
systemInstruction: { parts: [{
text: `You are an expert AI Gift Advisor for an Indian customized gifting store named Printra.in.
Analyze the user's occasion/recipient and choose exactly 2 appropriate products from the 'Available Products Catalog' provided.
For each product, write a catchy, short, and sweet custom quote (max 6 words, Hinglish or English) that can be printed on it.
Also provide a short 1-line reason why this product is perfect.
IMPORTANT: Return ONLY a valid JSON array of objects. Do not wrap in markdown tags like \`\`\`json.
Format: [{"productId": 1, "quote": "Happy Birthday Bro!", "reason": "A magic mug adds a surprise element."}]`
}]},
generationConfig: { responseMimeType: "application/json" }
})
});
if (!response.ok) throw new Error("API request failed");
const data = await response.json();
const text = data.candidates?.[0]?.content?.parts?.[0]?.text;
if (text) {
let parsed = JSON.parse(text);
setAdviseResults(parsed);
}
} catch (error) {
console.error("AI Error:", error);
alert("Oops! AI network busy hai, thodi der baad try karein.");
} finally {
setIsAdvising(false);
}
};
return (
{/* Hero Banner - Upgraded with Modern Gradient and Abstract Shapes */}
{/* Abstract Background Elements */}
✨ India's #1 Custom Gifting Store
Make It Yours. Customize Anything!
Mugs, T-shirts, Keychains & more. Add your photos and text in seconds to create the perfect personalized gift.
{/* ✨ Updated Button for AI Gift Advisor */}
setShowAdvisor(true)}
className="bg-white text-indigo-600 font-extrabold py-4 px-10 rounded-full shadow-[0_0_20px_rgba(255,255,255,0.4)] hover:shadow-[0_0_30px_rgba(255,255,255,0.6)] hover:scale-105 active:scale-95 transition-all duration-300 text-lg flex items-center gap-3 mx-auto"
>
Start Customizing with AI
{/* --- AI GIFT ADVISOR MODAL --- */}
{showAdvisor && (
setShowAdvisor(false)}
>
{/* Modal Header */}
AI Gift Advisor
Let AI find the perfect product & quote for your loved ones.
setShowAdvisor(false)}
className="p-2 bg-white/10 hover:bg-white/20 rounded-full transition-colors"
>
{/* Modal Body */}
{!adviseResults.length ? (
// Input Phase
Who is the gift for & what's the occasion?
{isAdvising ? (
<> Analyzing Catalog...>
) : (
<> Suggest Best Gifts>
)}
) : (
// Results Phase
AI Suggested Matches:
{ setAdviseResults([]); setAdviseQuery(''); }}
className="text-sm text-indigo-600 font-semibold hover:underline"
>
Try another search
{adviseResults.map((result, idx) => {
const matchedProduct = allProducts.find(p => p.id === result.productId);
if (!matchedProduct) return null;
return (
{matchedProduct.name}
₹{matchedProduct.price}
"{result.quote}"
✨ {result.reason}
{
setShowAdvisor(false);
onProductClick(matchedProduct, result.quote);
}}
className="bg-gray-900 hover:bg-indigo-600 text-white font-bold py-2.5 px-5 rounded-xl transition-colors text-sm flex items-center justify-center gap-2 w-full sm:w-auto"
>
Customize This
);
})}
)}
)}
{/* --- END MODAL --- */}
{/* Shop By Category Section - ULTIMATE REDESIGN */}
Our Collections
Shop By Category
Discover our exclusive range of high-quality customizable products designed to make your memories last forever.
{/* CATEGORY GRID - Premium Portrait Cards */}
{homeCategoryCards.map((cat, idx) => (
onCategoryClick(cat.categoryName)}
>
{/* Animated glowing backdrop */}
{/* Actual Card */}
{/* Top Image Section */}
{/* Trending Badge */}
{idx === 0 && (
🔥 Trending
)}
{/* Content Section */}
{cat.name}
{cat.desc}
{/* Modern Diagonal Arrow Button */}
))}
{/* Testimonials Section */}
Loved by 10,000+ Customers
See what our happy customers have to say about our premium custom prints and fast delivery.
{testimonials.map((testimonial) => (
{/* Quote Mark Decoration */}
"
{[...Array(5)].map((_, i) => (
))}
"{testimonial.review}"
{testimonial.name.charAt(0)}
{testimonial.name}
✓ Verified Buyer
))}
);
}
// ==========================================
// CATEGORY VIEW COMPONENT (Product List by Category)
// ==========================================
function CategoryView({ categoryName, onProductClick, onBack }) {
const categoryProducts = allProducts.filter(p => p.category === categoryName);
// SEO for Category Page
useEffect(() => {
updateSEO(
`Buy Customized ${categoryName} Online | Printra.in`,
`Explore our wide range of personalized ${categoryName}. Add your photos, text, and custom designs online at Printra.in. Best prices guaranteed!`,
{
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": categoryName,
"description": `Customized ${categoryName} available at Printra.in`,
"url": `https://www.printra.in/category/${categoryName.toLowerCase().replace(/ /g, '-')}`
}
);
}, [categoryName]);
return (
Back to Home
{categoryName}
Choose a product from this category to customize.
{/* PRODUCT GRID - Enhanced Cards */}
{categoryProducts.map((product) => (
{product.category}
{product.name}
Starting From
₹{product.price}
onProductClick(product)}
className="w-full bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-bold py-3 rounded-xl shadow-md hover:shadow-lg hover:shadow-blue-500/30 transition-all duration-300 flex justify-center items-center gap-2 active:scale-95"
>
Customize Now
))}
{categoryProducts.length === 0 && (
No products found in this category right now.
)}
);
}
// ==========================================
// PRODUCT PAGE COMPONENT (Live Preview UI)
// ==========================================
function ProductPageView({ product, initialQuote, onBack }) {
const [quantity, setQuantity] = useState(1);
const [customText, setCustomText] = useState(initialQuote || '');
const [textColor, setTextColor] = useState('#ffffff');
const [uploadedImage, setUploadedImage] = useState(null);
// --- Naye AI Feature ke States ---
const [showAiBox, setShowAiBox] = useState(false);
const [aiPrompt, setAiPrompt] = useState('');
const [isGenerating, setIsGenerating] = useState(false);
const [aiQuotes, setAiQuotes] = useState([]);
// Set custom text if AI initial quote changes
useEffect(() => {
if (initialQuote) {
setCustomText(initialQuote);
}
}, [initialQuote]);
// SEO for Individual Product Page
useEffect(() => {
updateSEO(
`Customize ${product.name} Online - Printra.in`,
`Buy personalized ${product.name} starting at just ₹${product.price}. Upload your photos, add text with our live preview tool. Fast shipping!`,
{
"@context": "https://schema.org/",
"@type": "Product",
"name": product.name,
"image": product.image,
"description": `Premium customized ${product.name} printed with your own design.`,
"brand": {
"@type": "Brand",
"name": "Printra"
},
"offers": {
"@type": "Offer",
"url": `https://www.printra.in/product/${product.id}`,
"priceCurrency": "INR",
"price": product.price,
"availability": "https://schema.org/InStock"
}
}
);
}, [product]);
const apiKey = ""; // Gemini API Key automatically inject ho jayegi
const handleGenerateQuotes = async () => {
if (!aiPrompt.trim()) return;
setIsGenerating(true);
setAiQuotes([]);
try {
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-09-2025:generateContent?key=${apiKey}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
contents: [{ parts: [{ text: `Occasion or Vibe: ${aiPrompt}` }] }],
systemInstruction: { parts: [{ text: "You are a creative gift assistant for an Indian store. Generate 3 short, catchy quotes (max 4-6 words each) in English or Hinglish to print on a custom gift based on the user's occasion/vibe. Return ONLY a valid JSON array of 3 strings. Example: [\"Best Bro Ever\", \"Coffee First, Always\", \"Happy Bday Yaar!\"]" }]},
generationConfig: { responseMimeType: "application/json" }
})
});
if (!response.ok) throw new Error("API call failed");
const data = await response.json();
const text = data.candidates?.[0]?.content?.parts?.[0]?.text;
if (text) {
setAiQuotes(JSON.parse(text));
}
} catch (error) {
console.error("Error generating quotes:", error);
alert("Kuch galat ho gaya. Kripya thodi der baad try karein.");
} finally {
setIsGenerating(false);
}
};
// Handle local image upload for Live Preview
const handleImageUpload = (e) => {
const file = e.target.files[0];
if (file) {
const imageUrl = URL.createObjectURL(file);
setUploadedImage(imageUrl);
}
};
return (
Back to Products
{/* LEFT: Live Preview Area - Upgraded border and background */}
{/* Background decorative blob */}
{/* LIVE PREVIEW OVERLAYS */}
{uploadedImage && (
)}
{customText && (
{customText}
)}
🔴 Live Preview
{/* RIGHT: Product Details & Customization Options */}
{product.name}
₹{product.price}
{/* Option 1: Upload Photo */}
{/* Option 2: Add Text & Color */}
Add Name / Text
{/* ✨ AI Feature Button */}
setShowAiBox(!showAiBox)}
className="text-xs font-bold text-purple-700 bg-purple-100 hover:bg-purple-200 px-3 py-1.5 rounded-full flex items-center gap-1.5 transition-colors shadow-sm"
>
AI Quote Ideas ✨
{/* AI Prompt Box */}
{showAiBox && (
Kis baare mein quote chahiye? (e.g. Papa's Birthday, Gym Motivation)
setAiPrompt(e.target.value)}
placeholder="Occasion ya vibe likhein..."
className="flex-1 px-3 py-2 text-sm border border-purple-200 rounded-lg focus:outline-none focus:border-purple-400"
/>
{isGenerating ? : "Generate"}
{/* AI Generated Quotes Results */}
{aiQuotes.length > 0 && (
Apna favorite quote select karein:
{aiQuotes.map((quote, idx) => (
{
setCustomText(quote);
setShowAiBox(false);
}}
className="text-sm bg-white border border-purple-200 hover:border-purple-500 hover:bg-purple-50 text-purple-800 px-3 py-2.5 rounded-lg transition-colors text-left shadow-sm font-medium"
>
"{quote}"
))}
)}
)}
setCustomText(e.target.value)}
placeholder="Enter text to print..."
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:border-blue-500 mb-4"
/>
Text Color:
setTextColor(e.target.value)}
className="w-8 h-8 rounded cursor-pointer border-0 p-0"
/>
{/* Quantity */}
Quantity:
setQuantity(Math.max(1, quantity - 1))}
className="px-4 py-2 bg-gray-50 hover:bg-gray-100 text-gray-600 transition-colors"
>
-
{quantity}
setQuantity(quantity + 1)}
className="px-4 py-2 bg-gray-50 hover:bg-gray-100 text-gray-600 transition-colors"
>
+
{/* Action Buttons */}
{
alert("Aapka design submit ho gaya hai! Hum order confirm karne ke liye jaldi contact karenge.");
}}
className="flex-1 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white font-black py-4 rounded-xl shadow-xl hover:shadow-2xl hover:shadow-blue-500/40 transition-all duration-300 flex justify-center items-center gap-2 text-lg active:scale-95 border border-blue-500/50"
>
Complete Order Now
);
}
// ==========================================
// CONTACT US COMPONENT
// ==========================================
function ContactView({ onBack }) {
const [formData, setFormData] = useState({ name: '', email: '', subject: '', message: '' });
const [isSubmitted, setIsSubmitted] = useState(false);
const handleSubmit = (e) => {
e.preventDefault();
if (!formData.name || !formData.email || !formData.message) {
alert("Please fill all required fields.");
return;
}
// Simulate sending data
setTimeout(() => {
setIsSubmitted(true);
}, 500);
};
return (
Back to Home
{/* LEFT: Contact Information */}
Get in Touch
Have a question about a custom bulk order, need help with designing, or facing issues with tracking? We are here to help!
Email Us
kc1264055@gmail.com
Office Address
Mahavir Colony, Near Mahavir Dharamshala, Panipat, Haryana
Operating Hours: Monday - Saturday, 10:00 AM to 7:00 PM
{/* RIGHT: Contact Form */}
{isSubmitted ? (
Message Sent Successfully!
Thank you for reaching out to Printra.in. Our team will get back to you within 24 hours.
Return to Shopping
) : (
)}
);
}
// ==========================================
// ABOUT US COMPONENT
// ==========================================
function AboutView({ onBack }) {
useEffect(() => {
updateSEO("About Us - Printra.in", "Learn more about Printra.in and our passion for creating premium customized gifts.");
}, []);
return (
Back to Home
Welcome to Printra.in! My journey started with a simple passion: to help people express their love, memories, and creativity through high-quality personalized products.
I realized that finding the perfect gift is often difficult, and nothing feels more special than a product customized just for you or your loved ones. Whether it's a magic mug that reveals a hidden photo, a comfortable custom printed t-shirt, or an elegant glowing photo frame, I personally ensure that every single item that leaves our facility meets the highest standards of quality.
At Printra.in, we don't just print on merchandise; we print your memories. As a small business owner, I value every single order and work hard to make sure you get the best vibrant colors, durable materials, and a smooth shopping experience.
Thank you for trusting Printra.in. Let's create something beautiful together!
);
}
// ==========================================
// SHIPPING POLICY COMPONENT
// ==========================================
function ShippingView({ onBack }) {
useEffect(() => {
updateSEO("Shipping Policy - Printra.in", "Read our shipping policy. Fast and secure delivery across India for all personalized gifts.");
}, []);
return (
Back to Home
Order Processing Time
Because every product at Printra.in is uniquely customized for you, our standard processing and printing time is 1 to 2 business days after your order is confirmed and the design is approved.
Delivery Timeframes
Once dispatched, standard delivery generally takes 3 to 7 working days across anywhere in India, depending on your pin code. Remote areas might take a slightly longer time.
Order Tracking
As soon as your package is shipped out, you will receive a tracking link via email or WhatsApp so you can monitor your shipment's journey in real-time.
);
}
// ==========================================
// RETURNS POLICY COMPONENT
// ==========================================
function ReturnsView({ onBack }) {
useEffect(() => {
updateSEO("Returns Policy - Printra.in", "Check our strictly monitored return policy for damaged or defective customized products.");
}, []);
return (
Back to Home
Return & Replacement Policy
At Printra.in, we deal exclusively in customized products that are specially printed with your personal photos and text. Because these items cannot be resold, we do NOT offer any general returns, refunds, or exchanges if you change your mind.
When is a Return/Replacement Accepted?
A replacement will ONLY be provided under the following strict conditions:
The product received is physically broken or damaged during transit.
A completely wrong product or heavily defected item was delivered to you.
MANDATORY UNBOXING VIDEO
To claim a replacement for a broken or defective item, an unboxing video is strictly required.
You must record a continuous, uncut video from the moment you open the completely sealed package.
The video must clearly show the shipping label and the damage to the product.
Without this valid unboxing video, no return or replacement request will be entertained.
Please send your unboxing video and order details to kc1264055@gmail.com or via WhatsApp within 24 hours of delivery.
);
}