File size: 1,900 Bytes
2e9c97f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
*/
import React, { useState } from 'react';
import InitialInputForm from './InitialInputForm';
import AiCoPilotPanel from './AiCoPilotPanel';
import type { InitialInput, ActiveEditor } from '../lib/types';

interface ControlPanelProps {
  onGenerate: (formData: InitialInput) => void;
  onClear: () => void;
  activeEditor: ActiveEditor | null;
  onRefine: (instruction: string) => void;
  isGenerating: boolean;
  isRefining: boolean;
}

type Tab = 'setup' | 'copilot';

export default function ControlPanel({ 
    onGenerate, 
    onClear, 
    activeEditor,
    onRefine,
    isGenerating,
    isRefining
}: ControlPanelProps) {
  const [activeTab, setActiveTab] = useState<Tab>('setup');

  return (
    <div className="control-panel">
      <div className="control-panel-tabs">
        <button 
            className={`control-panel-tab ${activeTab === 'setup' ? 'active' : ''}`}
            onClick={() => setActiveTab('setup')}
        >
            <i className="ph-note-pencil"></i> Initial Setup
        </button>
        <button 
            className={`control-panel-tab ${activeTab === 'copilot' ? 'active' : ''}`}
            onClick={() => setActiveTab('copilot')}
            disabled={!activeEditor}
            aria-disabled={!activeEditor}
        >
           <i className="ph-magic-wand"></i> AI Co-pilot
        </button>
      </div>

      <div className="tab-content">
        {activeTab === 'setup' && (
          <InitialInputForm
            onSubmit={onGenerate}
            onClear={onClear}
            disabled={isGenerating}
            isLoading={isGenerating}
          />
        )}
        {activeTab === 'copilot' && (
          <AiCoPilotPanel
            activeEditor={activeEditor}
            onRefine={onRefine}
            isLoading={isRefining}
          />
        )}
      </div>
    </div>
  );
}