From 3747714888e7d142ae944871d2c05095d493aaf4 Mon Sep 17 00:00:00 2001 From: hwna00 Date: Fri, 6 Oct 2023 15:45:02 +0900 Subject: [PATCH] =?UTF-8?q?Hotfix(server):=20=EB=B3=91=EC=9B=90=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EB=A5=BC=20=EB=A6=AC=ED=84=B4=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - converHospital()을 통해 snake_case로 된 키의 이름을 caemlCase로 변경 --- .../apps/doctor/src/views/SignUp/SignUp.js | 11 +++-- packages/server/index.js | 40 ++++++++++--------- packages/server/utils/convertHospital.js | 9 +++++ 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 packages/server/utils/convertHospital.js diff --git a/packages/apps/doctor/src/views/SignUp/SignUp.js b/packages/apps/doctor/src/views/SignUp/SignUp.js index 70bb32c4..8c262b2f 100644 --- a/packages/apps/doctor/src/views/SignUp/SignUp.js +++ b/packages/apps/doctor/src/views/SignUp/SignUp.js @@ -76,13 +76,13 @@ const SignUp = function () { const onSearchFieldClick = useCallback(async () => { const hospitalName = getValues('hospital'); - if (!hospitalName) { + if (hospitalName !== '') { const { data } = await getHospitals(hospitalName); - if (data.length === 0) { - // TODO: webOS.notification 전송 + if (data.isSuccess) { + setHospitals(data.hospitals); } else { - setHospitals(data); + // TODO: webOS.notification 전송 } } }, [getValues]); @@ -165,10 +165,9 @@ const SignUp = function () { > {hospitals.map(hospital => { return ( - // TODO: key를 id에서 ykiho로 변경해야 함 convertHospital(row)); return res.json({ - Hospitals: rows, - isSucess: true, + hospitals, + isSuccess: true, code: 200, message: '병원 조회 성공', }); @@ -498,7 +500,7 @@ const readHospitals = async function (req, res) { } catch (err) { if (err.message === 'Hospital not found') { return res.json({ - isSucess: false, + isSuccess: false, code: 404, message: '병원을 찾을 수 없습니다.', }); @@ -513,7 +515,7 @@ const readHospitals = async function (req, res) { } } catch (err) { return res.json({ - isSucess: false, + isSuccess: false, code: 500, message: '데이터베이스 연결 실패', }); diff --git a/packages/server/utils/convertHospital.js b/packages/server/utils/convertHospital.js new file mode 100644 index 00000000..3d27c2f9 --- /dev/null +++ b/packages/server/utils/convertHospital.js @@ -0,0 +1,9 @@ +module.exports = hospitalFromDB => { + const { hospital_id, ...rest } = hospitalFromDB; + const hospital = { + hospitalId: hospital_id, + ...rest, + }; + + return hospital; +};