From c3450b8c5594413909030b1cac8bb0ecc09eaf70 Mon Sep 17 00:00:00 2001 From: Sanghyeon Sim <5338095@gmail.com> Date: Thu, 7 Sep 2023 16:43:40 +0900 Subject: [PATCH] feat: add menu on submit function --- source/component/ShopPost.js | 37 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/source/component/ShopPost.js b/source/component/ShopPost.js index ab314e5..f2a3d0d 100644 --- a/source/component/ShopPost.js +++ b/source/component/ShopPost.js @@ -192,24 +192,7 @@ const ShopPost = ({userId, category, setStoreName}) => { } if (inputStep == 4) { - if (key.tab) { - setFocus((focus + 1) % 2); - } - - if (key.return) { - if ( - lastKeyPress === 'return' || - name.length == 0 || - price == 0 - ) { - setInputStep(prevInputStep => prevInputStep + 1); - setLastKeyPress(null); // reset the last key press - return; - } else { - addMenu(); - return; - } - } + return; } // step 5는 입력 확인 @@ -424,13 +407,25 @@ const ShopPost = ({userId, category, setStoreName}) => { { + setFocus(1); + }} /> ", "menuPrice" : setPrice(parseInt(value) || 0)} - focus={focus == 1} + onChange={value => setPrice(value)} + onSubmit={() => { + if (price !== 0 && name.length !== 0) { + addMenu(); + } else { + setInputStep(prevInputStep => prevInputStep + 1); + setLastKeyPress(null); + return; + } + }} + focus={focus === 1} /> {'}'}