import React from "react"; import { useNavigate, useLocation } from "react-router"; import SubTitle from "../../component/SubTitle.jsx"; import Modal_Guardian from "../../component/Modal_Guardian.jsx"; import Modal_SeniorInsert from "../../component/Modal_SeniorInsert.jsx"; export default function AgentSelectOne() { const navigate = useNavigate(); const location = useLocation(); //대상자(시니어) 등록 모달 오픈 여부 const [modalSeniorInsertIsOpen, setModalSeniorInsertIsOpen] = React.useState(false); //대상자(시니어) 등록 모달 오픈 const modalSeniorInsertOpen = () => { setModalSeniorInsertIsOpen(true); }; //대상자(시니어) 등록 모달 닫기 const modalSeniorInsertClose = () => { setModalSeniorInsertIsOpen(false); }; //시니어 정보 const [agent, setAgent] = React.useState({ 'user_id': location.state['agent_id'], 'user_name': null, 'user_password': null, 'user_phonenumber': null, 'user_birth': null, 'user_gender': null, 'user_address': null, 'user_email': null, 'authority': 'ROLE_AGENCY', 'agency_id': null, 'government_id': null, 'agent_id': location.state['agent_id'], }); //시니어 상세 조회 const agentSelectOne = () => { fetch("/user/userSelectOne.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify(agent), }).then((response) => response.json()).then((data) => { console.log("agentSelectOne data : ", data); data['agent_id'] = location.state['agent_id']; setAgent(data); }).catch((error) => { console.log('agentSelectOne() /user/userSelectOne.json error : ', error); }); }; //생활보호사의 대상자 목록 const [seniorByAgent, setSeniorByAgent] = React.useState({ seniorListByAgent: [], seniorListCountByAgent: 0 }); //생활보호사의 선택한 대상자 정보 const [senior, setSenior] = React.useState({}); //생활보호사의 대상자 목록 조회 const seniorSelectListByAgent = () => { fetch("/user/seniorSelectListByAgent.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify(agent), }).then((response) => response.json()).then((data) => { console.log("seniorSelectListByAgent data : ", data); setSeniorByAgent(data); }).catch((error) => { console.log('seniorSelectListByAgent() /user/seniorSelectListByAgent.json error : ', error); }); }; //선택한 보호자 정보 관리 const guardianByAgentManagement = (item) => { setSenior(item); } //가입승인 const userUpdate = () => { agent['is_accept'] = true; fetch("/user/userUpdate.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify(agent), }).then((response) => response.json()).then((data) => { console.log("가입승인 결과(건수) : ", data); if (data > 0) { alert("승인완료"); agentSelectOne(); } else { alert("승인에 실패하였습니다. 관리자에게 문의바랍니다."); } }).catch((error) => { console.log('userUpdate() /user/userUpdate.json error : ', error); }); } //보호자의 대상자 제거 const agentSeniorDelete = (senior) => { if (confirm('해당 보호대상자의 케어를 종료하시겠습니까?') == false) { return; } fetch("/user/agentSeniorDelete.json", { method: "POST", headers: { 'Content-Type': 'application/json; charset=UTF-8' }, body: JSON.stringify(senior), }).then((response) => response.json()).then((data) => { console.log("보호자의 대상자 제거 결과(건수) : ", data); if (data > 0) { alert("케어종료완료"); seniorSelectListByAgent(); } else { alert("케어종료에 실패하였습니다. 관리자에게 문의바랍니다."); } }).catch((error) => { console.log('agentSeniorDelete() /user/agentSeniorDelete.json error : ', error); }); } React.useEffect(() => { agentSelectOne(); seniorSelectListByAgent(); }, []) return (
{ seniorSelectListByAgent(); modalSeniorInsertClose(); }} defaultAgentId={agent['agent_id']} defaultAgencyId={agent['agency_id']} defaultGovernmentId={agent['government_id']} />
관리기관 {agent['government_name']}
시행기관 {agent['agency_name']}
이름(아이디) {agent['user_name']}({agent['user_id']})
연락처 {agent['user_phonenumber']}
이메일 {agent['user_email']}
계정활성화여부 {agent['user_use'] ? '활성화' : '비활성화'}
{/* */} {seniorByAgent.seniorListByAgent.map((item, idx) => { return ( {/* */} ) })} {seniorByAgent.seniorListByAgent == null || seniorByAgent.seniorListByAgent.length == 0 ? : null}
No관리기관명 소속기관명이름 연락처 생년월일 성별 상태 배정시작일 배정종료일 상세보기
{idx + 1}{item['government_name']} {item['agency_name']}{item['user_name']} {item['user_phonenumber']} {item['user_birth']} {item['user_gender']} {item['agent_match_state'] ? 케어중 : 케어완료} {item['agent_match_start_date']} {item['agent_match_state'] ? : item['agent_match_end_date'] }
조회된 데이터가 없습니다
); }