File size: 2,354 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

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;