import { useTranslation } from 'react-i18next'; import { DEFAULT_PREHEAT_FILAMENT_TARGETS, PREHEAT_FILAMENT_ORDER, parsePreheatFilamentTargets, serializePreheatFilamentTargets, } from '../utils/preheatFilamentTargets'; import { MAX_CHAMBER_TEMP_C } from '../utils/printer'; interface Props { // JSON-encoded map; empty string means "use bundled defaults". value: string; onChange: (next: string) => void; disabled?: boolean; } // Per-filament chamber target editor for Settings → Workflow → Preheat card // (#1468). Renders one row per filament type with a numeric input clamped to // 0-MAX_CHAMBER_TEMP_C. Stripping back to the bundled defaults is handled by the parent // (Reset button next to the section title) — passing an empty string upward // is the canonical "use defaults" signal, which keeps the editor stateless // across resets. export function PreheatFilamentTargetsEditor({ value, onChange, disabled = false }: Props) { const { t } = useTranslation(); const map = parsePreheatFilamentTargets(value); const updateOne = (key: string, next: number) => { const clamped = Math.max(0, Math.min(MAX_CHAMBER_TEMP_C, Math.round(next))); const updated = { ...map, [key]: clamped }; onChange(serializePreheatFilamentTargets(updated)); }; return (