import { useState } from 'react';
import PropTypes from 'prop-types';
const SectionList = ({ sections, onSplit, onUpdate }) => {
const [editing, setEditing] = useState(null);
const [localSections, setLocalSections] = useState(sections);
const surfaceTypes = ['road', 'gravel', 'mixed', 'trail'];
const gearOptions = {
road: ['Standard (39x25)', 'Mid-compact (36x30)', 'Compact (34x28)'],
gravel: ['1x System', '2x Gravel', 'Adventure'],
trail: ['MTB Wide-range', 'Fat Bike']
};
const handleEdit = (sectionId) => {
setEditing(sectionId);
setLocalSections(sections);
};
const handleSave = () => {
onUpdate(localSections);
setEditing(null);
};
const handleChange = (sectionId, field, value) => {
setLocalSections(prev => prev.map(section =>
section.id === sectionId ? { ...section, [field]: value } : section
));
};
return (
Route Sections
{editing && (
)}
{localSections.map((section) => (
Section {section.id}
Distance: {section.distance} km
Elevation: {section.elevationGain} m
Max Grade: {section.maxGrade}%
Surface:
{editing === section.id ? (
) : (
{section.surfaceType}
)}
{editing === section.id && (
)}
))}
);
};
SectionList.propTypes = {
sections: PropTypes.arrayOf(PropTypes.object).isRequired,
onSplit: PropTypes.func.isRequired,
onUpdate: PropTypes.func.isRequired
};
export default SectionList;