Spaces:
Running
Running
File size: 3,716 Bytes
24f95f0 | 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 | import { useState } from 'react';
import Card from '@/components/common/Card';
interface SimulationFormProps {
onSubmit: (title: string, seedText: string, predictionGoal: string, caseId?: string) => void;
loading: boolean;
}
export default function SimulationForm({ onSubmit, loading }: SimulationFormProps) {
const [title, setTitle] = useState('');
const [seedText, setSeedText] = useState('');
const [predictionGoal, setPredictionGoal] = useState('');
const [caseId, setCaseId] = useState('');
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
onSubmit(title, seedText, predictionGoal, caseId || undefined);
};
return (
<Card>
<form onSubmit={handleSubmit} className="space-y-6">
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">
Simulation Title
</label>
<input
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
disabled={loading}
placeholder="e.g., Tesla Stock Price Prediction"
className="w-full bg-gray-950 border border-gray-700 rounded px-4 py-3 text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50"
required
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">
Seed Context
</label>
<textarea
value={seedText}
onChange={(e) => setSeedText(e.target.value)}
disabled={loading}
placeholder="Provide background context for the simulation... (e.g., 'Tesla reported Q1 earnings with 10% revenue decline. Competition from BYD is intensifying.')"
className="w-full min-h-[100px] bg-gray-950 border border-gray-700 rounded px-4 py-3 text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 resize-y"
required
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">
Prediction Goal
</label>
<textarea
value={predictionGoal}
onChange={(e) => setPredictionGoal(e.target.value)}
disabled={loading}
placeholder="What do you want to predict? (e.g., 'Predict Tesla stock price movement over the next 30 days')"
className="w-full min-h-[100px] bg-gray-950 border border-gray-700 rounded px-4 py-3 text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 resize-y"
required
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-300 mb-2">
Case ID <span className="text-gray-500">(Optional)</span>
</label>
<input
type="text"
value={caseId}
onChange={(e) => setCaseId(e.target.value)}
disabled={loading}
placeholder="Link to an existing analysis case"
className="w-full bg-gray-950 border border-gray-700 rounded px-4 py-3 text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500 disabled:opacity-50"
/>
</div>
<button
type="submit"
disabled={loading || !title.trim() || !seedText.trim() || !predictionGoal.trim()}
className="w-full px-6 py-3 bg-purple-600 hover:bg-purple-700 disabled:bg-gray-700 disabled:cursor-not-allowed text-white rounded font-medium transition-colors"
>
{loading ? 'Creating Simulation...' : 'Create Simulation'}
</button>
</form>
</Card>
);
}
|