Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apis/AccessRequestApi.js
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 주소로 수정하세용
},
},
};
33 changes: 13 additions & 20 deletions components/accessRequest/GuardianVerificationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');

Expand All @@ -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('');
}
};

Expand All @@ -45,8 +38,8 @@ const GuardianVerificationForm = ({ onVerifiedHandler }) => {
<View style={styles.inputWithButtonConatiner}>
<NormalInput
placeholder="환자 번호를 입력하세요."
value={patientNumber}
onChangeTextHandler={setPatientNumber}
value={patientCode}
onChangeTextHandler={setPatientCode}
isEditable={isVerified ? false : true}
inputWrpperWidth={{ width: '90%' }}
/>
Expand Down
6 changes: 1 addition & 5 deletions components/accessRequest/PatientVerficationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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,
Expand Down