omninexus-ai / components /ToolExecutionView.tsx
aditya9708's picture
Auto-deploy from AI Studio
e4c7604 verified
Raw History Blame Contribute Delete
2.35 kB
import React, { useState } from 'react';
import { Tool } from '../types';
import ChatView from './ChatView';
import ImageView from './ImageView';
import VideoView from './VideoView';
import LiveView from './LiveView';
import MoltBotView from './MoltBotView';
interface ToolExecutionViewProps {
tool: Tool;
onRun: () => boolean;
}
const ToolExecutionView: React.FC<ToolExecutionViewProps> = ({ tool, onRun }) => {
const [hasPaid, setHasPaid] = useState(false);
const handleStart = () => {
if (onRun()) {
setHasPaid(true);
}
};
if (!hasPaid) {
return (
<div className="h-full flex flex-col items-center justify-center p-10">
<div className="max-w-md w-full bg-[#0a0f1e] border border-slate-800 rounded-[40px] p-12 text-center shadow-3xl">
<div className={`w-20 h-20 rounded-3xl bg-gradient-to-br ${tool.gradient} flex items-center justify-center mx-auto mb-8 shadow-2xl`}>
<svg className="w-10 h-10 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.5} d={tool.icon} /></svg>
</div>
<h2 className="text-3xl font-black text-white mb-4">Execute {tool.name}</h2>
<p className="text-slate-500 mb-10 text-lg leading-relaxed font-medium">
This tool requires 10 Credits per execution. The creator will earn ${tool.epc} from this run.
</p>
<button
onClick={handleStart}
className={`w-full py-6 rounded-2xl bg-gradient-to-r ${tool.gradient} text-white font-black uppercase tracking-widest shadow-2xl hover:scale-105 active:scale-95 transition-all`}
>
Confirm & Run
</button>
<p className="mt-6 text-[10px] text-slate-600 font-black uppercase tracking-[0.2em]">Verified Asset by {tool.author}</p>
</div>
</div>
);
}
return (
<div className="h-full flex flex-col animate-in fade-in duration-700">
<div className="flex-1">
{tool.category === 'Text' && <ChatView />}
{tool.category === 'Image' && <ImageView />}
{tool.category === 'Video' && <VideoView />}
{tool.category === 'Voice' && <LiveView />}
{tool.category === 'Agent' && <MoltBotView />}
</div>
</div>
);
};
export default ToolExecutionView;