Newer
Older
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
/**
* Scenario selector component - dropdown to load predefined scenarios.
*/
import { useSimulationStore } from '../../store/simulationStore';
export default function ScenarioSelector() {
const {
scenarios,
selectedScenarioId,
loadScenario,
isLoading,
isRunning,
} = useSimulationStore();
const handleScenarioChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const scenarioId = e.target.value;
if (scenarioId && scenarioId !== 'custom') {
loadScenario(scenarioId);
}
};
const currentScenario = scenarios.find((s) => s.id === selectedScenarioId);
return (
<div className="space-y-3">
<div>
<label
htmlFor="scenario-select"
className="block text-sm font-medium text-gray-700 mb-2"
>
Scénario prédéfini
</label>
<select
id="scenario-select"
value={selectedScenarioId || 'custom'}
onChange={handleScenarioChange}
disabled={isLoading || isRunning}
className="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-sm disabled:bg-gray-100 disabled:cursor-not-allowed"
>
<option value="custom">Configuration personnalisée</option>
{scenarios.map((scenario) => (
<option key={scenario.id} value={scenario.id}>
{scenario.name}
</option>
))}
</select>
</div>
{/* Scenario description */}
{currentScenario && (
<div className="bg-blue-50 border border-blue-200 rounded-md p-3">
<h4 className="text-sm font-medium text-blue-900 mb-1">
{currentScenario.name}
</h4>
<p className="text-xs text-blue-700">{currentScenario.description}</p>
</div>
)}
{/* Custom configuration indicator */}
{!selectedScenarioId && (
<div className="bg-gray-50 border border-gray-200 rounded-md p-3">
<p className="text-xs text-gray-600">
Configuration personnalisée - Modifiez les paramètres ci-dessous
</p>
</div>
)}
</div>
);
}