Spaces:
Sleeping
Sleeping
File size: 8,164 Bytes
e4c7604 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
import React, { useState } from 'react';
import { GeminiService } from '../geminiService';
import { Tool } from '../types';
interface CreateViewProps {
onCreateTool: (tool: Tool) => void;
}
const CreateView: React.FC<CreateViewProps> = ({ onCreateTool }) => {
const [name, setName] = useState('');
const [desc, setDesc] = useState('');
const [category, setCategory] = useState<'Text' | 'Image' | 'Video' | 'Voice'>('Text');
const [price, setPrice] = useState('15.00');
const [isBuilding, setIsBuilding] = useState(false);
const [isSuggesting, setIsSuggesting] = useState(false);
const handleBuild = async () => {
if (!name || !desc) return;
setIsBuilding(true);
// Create a proper Tool object
const newTool: Tool = {
id: `custom-${Date.now()}`,
name,
description: desc,
category,
icon: category === 'Text' ? 'M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z' : 'M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z',
gradient: category === 'Text' ? 'from-blue-500 to-indigo-500' : 'from-indigo-600 to-purple-600',
author: 'Merchant (Me)',
usageCount: 0,
epc: parseFloat(price),
isUserCreated: true,
status: 'new'
};
// Simulate node syncing
await new Promise(r => setTimeout(r, 2000));
setIsBuilding(false);
onCreateTool(newTool);
};
const handleSuggest = async () => {
setIsSuggesting(true);
try {
const { text } = await GeminiService.chat(
"Suggest a high-utility AI tool for the Indian market. Format: Name|Description|Category(Text, Image, Video, or Voice)"
);
const parts = text.split('|');
if (parts.length >= 3) {
setName(parts[0].trim());
setDesc(parts[1].trim());
const cat = parts[2].trim() as any;
if (['Text', 'Image', 'Video', 'Voice'].includes(cat)) setCategory(cat);
} else {
setName("Hindi Legal Bot");
setDesc("Instant simplified Hindi translations for complex English legal documents.");
setCategory("Text");
}
} catch (err) {
setName("Wedding Invite AI");
setDesc("Generates personalized Indian wedding cards from guest lists.");
setCategory("Image");
} finally {
setIsSuggesting(false);
}
};
const templates = [
{ name: 'Viral Reels AI', desc: 'Creates high-engagement Instagram reels from simple text scripts.', cat: 'Video' as const },
{ name: 'Cinematic Trailer', desc: 'Generates 4K cinematic movie trailers based on your story concept.', cat: 'Video' as const },
{ name: 'LegalEase Pro', desc: 'Simplifies complex legal documents into easy-to-understand summaries.', cat: 'Text' as const },
{ name: 'Logo Architect', desc: 'Generates professional vector-style logos for startups.', cat: 'Image' as const },
];
return (
<div className="max-w-4xl mx-auto px-6 py-12">
<div className="text-center mb-16">
<div className="inline-block px-4 py-1.5 rounded-full bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 text-[10px] font-black uppercase tracking-[0.2em] mb-6">
Architect Terminal v2.5
</div>
<h1 className="text-5xl font-black mb-6 tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-white to-slate-400">
Publish to Market.
</h1>
<p className="text-slate-500 text-lg max-w-2xl mx-auto">
Deploy specialized AI assets to the global exchange and receive instant settlements in ₹.
</p>
</div>
<div className="mb-10">
<label className="text-[10px] font-black text-slate-600 uppercase tracking-widest mb-4 block text-center">Quick Templates</label>
<div className="flex flex-wrap justify-center gap-3">
{templates.map((t, i) => (
<button
key={i}
onClick={() => { setName(t.name); setDesc(t.desc); setCategory(t.cat); }}
className="px-4 py-2 rounded-xl bg-white/5 border border-white/10 text-xs font-bold text-slate-300 hover:bg-white/10 hover:border-indigo-500/50 transition-all"
>
{t.name}
</button>
))}
</div>
</div>
<div className="bg-[#0a0f1e] border border-white/5 rounded-[40px] p-10 shadow-3xl">
<div className="space-y-8">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<label className="text-[10px] font-black text-slate-600 uppercase tracking-widest mb-3 block">Asset Name</label>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="e.g. LegalEase Pro"
className="w-full bg-[#020617] border border-slate-800 rounded-2xl px-6 py-4 text-white font-medium focus:ring-2 focus:ring-indigo-500 outline-none"
/>
</div>
<div>
<label className="text-[10px] font-black text-slate-600 uppercase tracking-widest mb-3 block">Asset Category</label>
<select
value={category}
onChange={(e) => setCategory(e.target.value as any)}
className="w-full bg-[#020617] border border-slate-800 rounded-2xl px-6 py-4 text-white font-medium focus:ring-2 focus:ring-indigo-500 outline-none appearance-none"
>
<option value="Text">Text (LLM)</option>
<option value="Image">Image (Gen)</option>
<option value="Video">Video (Cinematic)</option>
<option value="Voice">Voice (Live)</option>
</select>
</div>
</div>
<div>
<div className="flex items-center justify-between mb-3">
<label className="text-[10px] font-black text-slate-600 uppercase tracking-widest">Blueprint Description</label>
<button onClick={handleSuggest} className="text-[10px] font-black text-indigo-400 uppercase tracking-widest flex items-center gap-2 hover:text-indigo-300 transition-colors">
<svg className={`w-3.5 h-3.5 ${isSuggesting ? 'animate-spin' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
AI Idea Generator
</button>
</div>
<textarea
value={desc}
onChange={(e) => setDesc(e.target.value)}
placeholder="Explain what this tool does in 1 sentence..."
rows={3}
className="w-full bg-[#020617] border border-slate-800 rounded-3xl p-6 text-slate-200 focus:ring-2 focus:ring-indigo-500 outline-none resize-none"
/>
</div>
<div className="bg-[#020617] p-8 rounded-3xl border border-slate-800">
<label className="text-[10px] font-black text-slate-600 uppercase tracking-widest mb-4 block">Merchant Royalty (INR per Run)</label>
<div className="flex items-center gap-4">
<span className="text-3xl font-black text-white">₹</span>
<input
type="number"
step="1"
value={price}
onChange={(e) => setPrice(e.target.value)}
className="bg-transparent border-none text-4xl font-black text-emerald-400 w-full focus:ring-0"
/>
</div>
</div>
<button onClick={handleBuild} disabled={!name || !desc || isBuilding} className="w-full bg-white text-black py-8 rounded-[32px] font-black uppercase tracking-widest text-lg hover:scale-[1.02] active:scale-95 transition-all shadow-2xl disabled:opacity-50">
{isBuilding ? 'Syncing Asset with Global Node...' : 'Deploy Live Asset'}
</button>
</div>
</div>
</div>
);
};
export default CreateView;
|