import React, { useState, useEffect } from 'react'; import axios from 'axios'; import { Upload, Trash2, Save, Image as ImageIcon, Store, Link as LinkIcon, Lock } from 'lucide-react'; interface BrandKitProps { } export default function BrandKit({ }: BrandKitProps) { const [logoPreview, setLogoPreview] = useState(null); const [loading, setLoading] = useState(false); const [uploading, setUploading] = useState(false); // Shop Settings State const [shopName, setShopName] = useState(""); const [shopLink, setShopLink] = useState(""); const [apiKey, setApiKey] = useState(""); const [savingDetails, setSavingDetails] = useState(false); useEffect(() => { fetchBrandData(); }, []); const fetchBrandData = async () => { setLoading(true); try { // 1. Fetch Logo Status const logoRes = await axios.get('/api/brand/logo'); if (logoRes.data.exists) { setLogoPreview(logoRes.data.logo); } // 2. Fetch User Settings (Shop Name, Link, API Key) const userRes = await axios.get('/api/auth/me'); if (userRes.data) { setShopName(userRes.data.etsyShopName || ""); setShopLink(userRes.data.etsyShopLink || ""); setApiKey(userRes.data.apiKey || ""); } } catch (err) { console.error("Failed to fetch brand data", err); } finally { setLoading(false); } }; const handleFileUpload = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (!file) return; setUploading(true); const formData = new FormData(); formData.append('logo', file); try { const res = await axios.post('/api/brand/logo', formData, { headers: { 'Content-Type': 'multipart/form-data' } }); // Refresh preview fetchBrandData(); } catch (err: any) { alert('Failed to upload logo: ' + (err.response?.data?.error || err.message)); } finally { setUploading(false); } }; const handleSaveDetails = async () => { setSavingDetails(true); try { await axios.put('/api/auth/me', { etsyShopName: shopName, etsyShopLink: shopLink, apiKey: apiKey // Allow updating API Key here too if needed }); alert("Brand settings saved successfully!"); } catch (err: any) { alert("Failed to save settings: " + (err.response?.data?.error || err.message)); } finally { setSavingDetails(false); } }; return (

Brand Kit & Shop Settings

Manage your shop identity. Your logo will be used for mockups, and shop details for SEO & Branding.

{/* 1. Logo Section */}
Store Logo
{loading ? (
) : logoPreview ? ( <> Brand Logo
) : ( )}
{uploading && Uploading...}

Supports transparent PNG. Max 5MB. Used for watermarks on mockups.

{/* 2. Shop Details Section */}
{/* Shop Name */}
setShopName(e.target.value)} placeholder="e.g. MyArtPrintStudio" className="w-full px-3 py-2 bg-stone-50 border border-stone-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-purple-500/20 focus:border-purple-500 transition-all" />
{/* Shop Link */}
setShopLink(e.target.value)} placeholder="https://etsy.com/shop/..." className="w-full px-3 py-2 bg-stone-50 border border-stone-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-purple-500/20 focus:border-purple-500 transition-all" />
{/* API Key (Optional Display) */}
setApiKey(e.target.value)} placeholder="Enter specific key for this project..." className="w-full px-3 py-2 bg-stone-50 border border-stone-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-purple-500/20 focus:border-purple-500 transition-all font-mono" />

Leave blank to use system default.

{/* Branding Info Box */}

How this data is used

  • Shop Name: Used in SEO Titles and Descriptions generated by AI.
  • Shop URL: Included in 'Printing Guide' PDFs for customer reference.
  • Logo: Applied as a watermark to generated mockups (never on masters).
); }