diff --git a/src/components/production-line/settings-modal.tsx b/src/components/production-line/settings-modal.tsx index 4957dc48..9f578e97 100644 --- a/src/components/production-line/settings-modal.tsx +++ b/src/components/production-line/settings-modal.tsx @@ -132,6 +132,13 @@ export const SettingsModal = ({ } }; + const handleSave = () => { + const hasErrors = Object.values(errors).some((error) => error !== ""); + if (!hasErrors) { + onSave(); + } + }; + const handleKeyDown = (e: React.KeyboardEvent, index: number) => { if (e.key === "Enter") { e.preventDefault(); @@ -139,10 +146,7 @@ export const SettingsModal = ({ if (nextInput) { nextInput.focus(); } else { - const hasErrors = Object.values(errors).some((error) => error !== ""); - if (!hasErrors) { - onSave(); - } + handleSave(); } } else if (e.key === "ArrowUp") { e.preventDefault(); @@ -237,15 +241,7 @@ export const SettingsModal = ({ Cancel - { - const hasErrors = Object.values(errors).some( - (error) => error !== "" - ); - if (!hasErrors) onSave(); - }} - > + Save settings