박권수

feat. complete web

......@@ -100,13 +100,13 @@ exports.doctorRegister = async ctx => {
}
const existDoctorInfo = await DoctorInfo.findByDoctorId(userId);
if(existDoctorInfo.useYn === 'W') {
if(existDoctorInfo && existDoctorInfo.useYn === 'W') {
ctx.status = 401;
ctx.body = {
error : '가입 승인 대기중인 회원입니다.',
};
return;
} else if(existDoctorInfo.useYn === 'N') {
} else if(existDoctorInfo && existDoctorInfo.useYn === 'N') {
ctx.status = 401;
ctx.body = {
error : '가입이 거절된 회원입니다.',
......
......@@ -30,4 +30,11 @@ export default {
},
});
},
validateDoctorLicense : (token : RecoilState<any>, Data : any) => {
return client.post('/manage/doctor/validate', Data, {
headers : {
Authorization : token,
},
});
},
};
\ No newline at end of file
......
......@@ -21,11 +21,13 @@ const ManagerMenuContainer = (props : ManagerMenuProps) => {
const [doctorDetail, setDoctorDetail] = useState<any>({});
const [modalUp, setModalUp] = useState<boolean>(false);
const [validate, setValidate] = useState<string>('W');
const fetchData = async() => {
setModalUp(false);
setValidate('W');
try {
await managerApi.getDoctorRegReqList(token)
......@@ -43,6 +45,8 @@ const ManagerMenuContainer = (props : ManagerMenuProps) => {
const onViewDetailReq = async (doctorId : string) => {
setValidate('W');
try {
await managerApi.getDoctorRegReqDetail(token, doctorId)
.then((res : any) => {
......@@ -58,6 +62,14 @@ const ManagerMenuContainer = (props : ManagerMenuProps) => {
//회원 가입 수락
const onAcceptRequest = () => {
if(validate === 'W') {
Alert.onError('먼저 의사의 자격번호가 유효한지 검증해주세요.', () => null);
return;
} else if(validate === 'N') {
Alert.onError('유효한 자격 번호가 아닙니다.', () => null);
return;
}
const onAccept = async() => {
try {
await managerApi.acceptDoctorRegReq(token, doctorDetail)
......@@ -92,6 +104,28 @@ const ManagerMenuContainer = (props : ManagerMenuProps) => {
Alert.onCheck('회원 가입 요청을 취소하시겠습니까?', onReject, () => null);
};
const onValidate = async () => {
try {
await managerApi.validateDoctorLicense(token, {
doctorLicense : doctorDetail.info.doctorLicense,
}).then(res => {
if(res.statusText === 'OK') {
setValidate(res.data.result ? 'Y' : 'N');
}
}).catch(err => {
Alert.onError(err.response.data, () => {
setModalUp(false);
setValidate('W');
});
})
} catch(e) {
Alert.onError(e.response.data, () => {
setModalUp(false);
setValidate('W');
});
}
};
useEffect(() => {
fetchData();
}, []);
......@@ -104,6 +138,8 @@ const ManagerMenuContainer = (props : ManagerMenuProps) => {
modalUp = {modalUp}
setModalUp = {setModalUp}
onViewDetailReq = {onViewDetailReq}
validate = {validate}
onValidate = {onValidate}
onAcceptRequest = {onAcceptRequest}
onRejectRequest = {onRejectRequest}
......
......@@ -13,6 +13,8 @@ interface ManagerMenuProps {
modalUp : boolean;
setModalUp : any;
onViewDetailReq : (arg0 : string) => void;
validate : string;
onValidate : () => void;
onAcceptRequest : () => void;
onRejectRequest : () => void;
......@@ -42,7 +44,23 @@ const ManagerMenuPresenter = (props : ManagerMenuProps) => {
<styled.ModalBodyLeftAndRight>
<styled.ModalInfoWrapper>
<styled.ModalInfoExplain>의사 자격 번호</styled.ModalInfoExplain>
<styled.ModalInfo>{props.doctorDetail.info.doctorLicense}</styled.ModalInfo>
<styled.ModalInfo>
{props.doctorDetail.info.doctorLicense}
<styled.ValidateButton
onClick = {props.onValidate}
disabled = {props.validate !== 'W'}
validate = {props.validate}
>
{
props.validate === 'Y' ?
'검증 완료' :
props.validate === 'W' ?
'검증' :
props.validate === 'N' ?
'검증 실패' : null
}
</styled.ValidateButton>
</styled.ModalInfo>
</styled.ModalInfoWrapper>
<styled.ModalInfoWrapper>
<styled.ModalInfoExplain>이름</styled.ModalInfoExplain>
......
......@@ -194,6 +194,43 @@ export const ModalInfo = styled.div `
margin : 5px 0 20px 0;
font-size : 20px;
font-weight : 700;
display : flex;
flex-direction : row;
align-items : center;
`;
export const ValidateButton = styled.button<{validate : string}> `
margin : 0 0 0 15px;
padding : 2px 5px;
border-radius : 3px;
border : ${props => props.validate === 'W' ? '1px solid #343434'
: props.validate === 'Y' ? '1px solid #337DFF'
: props.validate === 'N' ? '1px solid #dedede' : 'transparent'
};
background-color : ${props => props.validate === 'W' ? 'transparent'
: props.validate === 'Y' ? '#377DFF'
: props.validate === 'N' ? '#f2f2f2' : 'transparent'
};
color : ${props => props.validate === 'W' ? '#343434'
: props.validate === 'Y' ? '#fff'
: props.validate === 'N' ? '#a0a0a0' : 'transparent'
};
transition : .25s all;
:not(:disabled) {
cursor : pointer;
&:hover {
background-color : #343434;
color : #fff;
border : 1px solid #343434;
}
}
`;
export const ModalButtonWrapper = styled.div `
......