import PropTypes from 'prop-types';
import { SIMULATION_SCENARIOS } from '../../utils/constants';
import Button from '../ui/Button';
const categoryColors = {
transport: 'border-emerald-500/40 bg-emerald-500/8',
energy: 'border-blue-500/40 bg-blue-500/8',
food: 'border-pink-500/40 bg-pink-500/8',
shopping: 'border-orange-500/40 bg-orange-500/8',
};
/**
* ScenarioSelector — renders categorised simulation scenarios as
* selectable cards with an aria-pressed toggle pattern.
* @param {Object} props
* @param {Object|null} props.selectedScenario - Currently selected scenario or null
* @param {Function} props.onSelect - Callback when a scenario is clicked
* @param {Function} props.onRun - Callback to run the selected simulation
* @param {boolean} props.loading - Whether a simulation is currently running
* @returns {JSX.Element}
*/
export default function ScenarioSelector({ selectedScenario, onSelect, onRun, loading }) {
const categories = [...new Set(SIMULATION_SCENARIOS.map((s) => s.category))];
return (
{categories.map((category) => (
{category}
{SIMULATION_SCENARIOS.filter((s) => s.category === category).map((scenario) => {
const isSelected = selectedScenario?.id === scenario.id;
return (
);
})}
))}
{selectedScenario && (
)}
);
}
ScenarioSelector.propTypes = {
selectedScenario: PropTypes.shape({
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
name: PropTypes.string,
description: PropTypes.string,
icon: PropTypes.string,
category: PropTypes.string,
params: PropTypes.object,
}),
onSelect: PropTypes.func.isRequired,
onRun: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
};