From c4ef8da4e6dab71990298be5c0634674945c6c1e Mon Sep 17 00:00:00 2001 From: zzzzzisu Date: Fri, 9 May 2025 17:25:31 +0900 Subject: [PATCH] =?UTF-8?q?KW-327/feat:=20=EC=B6=9C=EC=9E=85=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EC=8B=A0=EC=B2=AD=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=ED=99=98=EC=9E=90=20=EC=BD=94=EB=93=9C=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?API=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/AccessRequestApi.js | 16 +++++++++ app.config.js | 2 +- .../accessRequest/GuardianVerificationForm.js | 33 ++++++++----------- .../accessRequest/PatientVerficationForm.js | 6 +--- 4 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 apis/AccessRequestApi.js diff --git a/apis/AccessRequestApi.js b/apis/AccessRequestApi.js new file mode 100644 index 0000000..f470a6c --- /dev/null +++ b/apis/AccessRequestApi.js @@ -0,0 +1,16 @@ +import axios from './AxiosInstance'; + +// 환자 번호 검증 +export const verifyPatientCode = async (patientCode) => { + const response = await axios.post( + '/patients/code', + { patientCode }, + { + headers: { + 'X-Hospital-Id': '1', + }, + }, + ); + + return response.data; +}; diff --git a/app.config.js b/app.config.js index 64e96b5..37b8242 100644 --- a/app.config.js +++ b/app.config.js @@ -25,7 +25,7 @@ export default { favicon: './assets/images/logoIcon.png', }, extra: { - BASE_URL: 'http://192.168.0.111:8081', // 본인 pc IPv4 주소로 수정하세용 + BASE_URL: 'http://192.168.0.115:8081', // 본인 pc IPv4 주소로 수정하세용 }, }, }; diff --git a/components/accessRequest/GuardianVerificationForm.js b/components/accessRequest/GuardianVerificationForm.js index 8782e3c..28c658c 100644 --- a/components/accessRequest/GuardianVerificationForm.js +++ b/components/accessRequest/GuardianVerificationForm.js @@ -3,10 +3,10 @@ import { styles } from './styles/GuardianVerificationForm.styles'; import { useState } from 'react'; import NormalInput from '../textinputs/NormalInput'; import NormalAlert from '../alerts/NormalAlert'; -import AsyncStorage from '@react-native-async-storage/async-storage'; +import { verifyPatientCode } from '../../apis/AccessRequestApi'; const GuardianVerificationForm = ({ onVerifiedHandler }) => { - const [patientNumber, setPatientNumber] = useState(''); // 환자 번호 관리 + const [patientCode, setPatientCode] = useState(''); // 환자 번호 관리 const [isVerified, setIsVerified] = useState(false); const [alertMessage, setAlertMessage] = useState(''); @@ -15,27 +15,20 @@ const GuardianVerificationForm = ({ onVerifiedHandler }) => { // 환자 번호 검증 버튼 클릭 핸들러 const handleVerifyPatient = async () => { - // TODO: 환자 번호 검증 API 연결 - // 임시 검증 로직 try { - const isValid = patientNumber === '1234'; // 예시 조건 + await verifyPatientCode(patientCode); - if (isValid) { - // 유효한 환자 번호 - setIsVerified(true); - setAlertMessage(`환자 번호가 정상적으로 확인되었습니다.\n방문 날짜를 선택해 주세요.`); - onVerifiedHandler(patientNumber); // 부모에게 환자 정보 전달 - setShowVerifiedAlert(true); - } else { - // 유효하지 않은 환자 번호 - setIsVerified(false); - setAlertMessage(`일치하는 환자 정보가\n존재하지 않습니다.\n다시 입력해 주세요.`); - setShowVerifiedAlert(true); - setPatientNumber(''); - } + // 유효한 환자 번호 + setIsVerified(true); + setAlertMessage(`환자 번호가 정상적으로 확인되었습니다.\n방문 날짜를 선택해 주세요.`); + onVerifiedHandler(patientCode); // 부모에게 환자 정보 전달 + setShowVerifiedAlert(true); } catch (error) { + // 유효하지 않은 환자 번호 setIsVerified(false); + setAlertMessage(`일치하는 환자 정보가\n존재하지 않습니다.\n확인 후 다시 입력해 주세요.`); setShowVerifiedAlert(true); + setPatientCode(''); } }; @@ -45,8 +38,8 @@ const GuardianVerificationForm = ({ onVerifiedHandler }) => { diff --git a/components/accessRequest/PatientVerficationForm.js b/components/accessRequest/PatientVerficationForm.js index c879b03..207f08a 100644 --- a/components/accessRequest/PatientVerficationForm.js +++ b/components/accessRequest/PatientVerficationForm.js @@ -4,7 +4,6 @@ import NormalButton from '../buttons/NormalButton'; import { useState, useEffect } from 'react'; import NormalInput from '../textinputs/NormalInput'; import NormalAlert from '../alerts/NormalAlert'; -import AsyncStorage from '@react-native-async-storage/async-storage'; import { getMyInfo } from '../../apis/MyPageApi'; const PatientVerficationForm = ({ onVerifiedHandler }) => { @@ -19,10 +18,7 @@ const PatientVerficationForm = ({ onVerifiedHandler }) => { useEffect(() => { const loadInfo = async () => { try { - const token = await AsyncStorage.getItem('accessToken'); - if (!token) throw new Error('토큰이 존재하지 않습니다.'); - - const data = await getMyInfo(token); + const data = await getMyInfo(); setUserInfo({ name: data.name, birth: data.birthDate,