최정우 최정우 2023-04-04
230404 최정우 사용자 관리 커밋2
@7d3919b8540a9d12c4714db0e60ddff03f9ac09c
client/views/component/Modal_Guardian.jsx
--- client/views/component/Modal_Guardian.jsx
+++ client/views/component/Modal_Guardian.jsx
@@ -1,11 +1,118 @@
 import React from "react";
-import Button from "./Button.jsx";
 import SubTitle from "./SubTitle.jsx";
-import Table from "./Table.jsx";
-import Pagination from "./Pagination.jsx";
+import CommonUtil from "../../resources/js/CommonUtil.js";
+
+export default function Modal_Guardian({ open, close, guardianManagementCallback, seniorId, guardianListBySenior }) {
+
+  //시니어 정보
+  const [guardian, setGuardian] = React.useState({
+    'user_id': null,
+    'user_name': null,
+    'user_password': null,
+    'user_phonenumber': null,
+    'user_birth': null,
+    'user_gender': null,
+    'user_address': null,
+    'user_email': null,
+    'authority': 'ROLE_GUARDIAN',
+    'agency_id': null,
+    'government_id': null,
+
+    'senior_id': seniorId,
+    'senior_relationship': '자녀',
+    'senior_relationship_etc': '',
+  });
+
+  //각 데이터별로 Dom 정보 담을 Ref 생성
+  const guardianRefInit = JSON.parse(JSON.stringify(guardian));
+  guardianRefInit['user_gender'] = {};
+  const guardianRef = React.useRef(guardianRefInit);
+
+  //등록할 시니어 정보 변경
+  const guardianValueChange = (targetKey, value) => {
+    let newGuardian = JSON.parse(JSON.stringify(guardian));
+    newGuardian[targetKey] = value;
+    setGuardian(newGuardian);
+  }
+
+  //시니어 등록 유효성 검사
+  const guardianInsertValidation = () => {
+    if (CommonUtil.isEmpty(guardian['user_name']) == true) {
+      guardianRef.current['user_name'].focus();
+      alert("이름을 입력해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(guardian['user_gender']) == true) {
+      guardianRef.current['user_gender']['m'].focus();
+      alert("성별을 선택해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(guardian['user_birth']) == true) {
+      guardianRef.current['user_birth'].focus();
+      alert("생년월일을 선택해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(guardian['user_phonenumber']) == true) {
+      guardianRef.current['user_phonenumber'].focus();
+      alert("연락처를 입력해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(guardian['user_address']) == true) {
+      guardianRef.current['user_address'].focus();
+      alert("주소를 입력해 주세요.");
+      return false;
+    }
+    if (CommonUtil.isEmpty(guardian['senior_relationship']) == true) {
+      guardianRef.current['senior_relationship'].focus();
+      alert("대상자와의 관계를 선택해 주세요.");
+      return false;
+    }
+    
+    if (guardian['senior_relationship'] == '기타' && CommonUtil.isEmpty(guardian['senior_relationship_etc']) == true) {
+      guardianRef.current['senior_relationship_etc'].focus();
+      alert("대상자와의 관계를 입력해 주세요.");
+      return false;
+    }
+
+    return true;
+  }
+  //시니어 등록
+  const guardianInsert = () => {
+    if (guardianInsertValidation() == false) {
+      return;
+    }
+
+    fetch("/user/guardianInsert.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(guardian),
+    }).then((response) => response.json()).then((data) => {
+      console.log("시니어 등록 결과(건수) : ", data);
+      if (data > 0) {
+        alert("등록완료");
+        guardianInsertCallback();
+      } else {
+        alert("등록에 실패하였습니다. 관리자에게 문의바랍니다.");
+      }
+    }).catch((error) => {
+      console.log('guardianInsert() /user/guardianInsert.json error : ', error);
+    });
+  }
 
 
-export default function Modal_Guardian({ open, close, seniorId }) {
+
+  //Mounted
+  React.useEffect(() => {
+    const government_id = !defaultGovernmentId ? state.loginUser['government_id'] : defaultGovernmentId;
+    const agency_id = !defaultAgencyId ? state.loginUser['agency_id'] : defaultAgencyId;
+
+    let newSenior = JSON.parse(JSON.stringify(senior));
+    newSenior['government_id'] = government_id;
+    newSenior['agency_id'] = agency_id;
+    setSenior(newSenior);
+  }, [defaultGovernmentId, defaultAgencyId]);
 
   return (
     <div class={open ? "openModal modal" : "modal"}>
@@ -18,65 +125,95 @@
           <div className="modal-main">
             <div className="board-wrap">
 
-              <SubTitle explanation={"OOO님의 보호자(가족)"} className="margin-bottom" />
-              <div>
-                <table className='caregiver-user'>
-                  <thead>
-                    <tr>
-                      <th>No</th>
-                      <th>이름</th>
-                      <th>대상자와의 관계</th>
-                      <th>연락처</th>
-                      <th>생년월일</th>
-                      <th>삭제</th>
-                    </tr>
-                  </thead>
-                  <tbody>
-                    <tr>
-                      <td>No</td>
-                      <td>이름</td>
-                      <td>대상자와의 관계</td>
-                      <td>연락처</td>
-                      <td>생년월일</td>
-                      <td><button className={"btn-small gray-btn"} onClick={() => {}}>삭제</button></td>
-                    </tr>
-                  </tbody>
-                </table>
-              </div>
-              <div>
-                {/* <Pagination total={guardianTotal} limit={limit} page={page} setPage={setPage} /> */}
-              </div>
-
-
               <SubTitle explanation={"최초 ID는 연락처, PW는 생년월일 8자리입니다."} className="margin-bottom" />
               <table className="margin-bottom2 senior-insert">
                 <tr>
                   <th><span style={{color : "red"}}>*</span>이름</th>
                   <td>
-                    <input type="text"/>
+                    <input type="text"
+                      value={guardian['user_name']}
+                      onChange={(e) => {guardianValueChange('user_name', e.target.value)}}
+                      ref={el => guardianRef.current['user_name'] = el}
+                    />
                   </td>
+                  <th><span style={{color : "red"}}>*</span>성별</th>
+                  <td className=" gender">
+                    <div className="flex-start">
+                      <input type="radio" id="user_gender_m" name="user_gender" value="남"
+                        onChange={(e) => {e.target.checked ? guardianValueChange('user_gender', e.target.value) : null}}
+                        ref={el => guardianRef.current['user_gender']['m'] = el}
+                        />
+                      <label for="user_gender_m">남</label>
+                    </div>
+                    <div className="flex-start">
+                      <input type="radio" id="user_gender_f" name="user_gender" value="여"
+                        onChange={(e) => {e.target.checked ? guardianValueChange('user_gender', e.target.value) : null}}
+                        ref={el => guardianRef.current['user_gender']['f'] = el}
+                        />
+                      <label for="user_gender_f">여</label>
+                    </div>
+                  </td>
+                </tr>
+                <tr>
                   <th><span style={{color : "red"}}>*</span>생년월일</th>
                   <td>
                     <div className="flex">
-                      <input type='date' />
+                      <input type='date'
+                        value={guardian['user_birth']}
+                        onChange={(e) => {guardianValueChange('user_birth', e.target.value)}}
+                        ref={el => guardianRef.current['user_birth'] = el}
+                      />
                     </div>
                   </td>
                 </tr>
                 <tr>
                   <th><span style={{color : "red"}}>*</span>연락처</th>
                   <td colSpan={3}>
-                    <input type="input" maxLength="13" />
+                    <input type="number" maxLength="11"
+                      value={guardian['user_phonenumber']}
+                      onChange={(e) => {guardianValueChange('user_phonenumber', e.target.value)}}
+                      ref={el => guardianRef.current['user_phonenumber'] = el}
+                    />
                   </td>
                 </tr>
                 <tr>
-                  <th>대상자와의 관계</th>
+                  <th><span style={{color : "red"}}>*</span>주소</th>
                   <td colSpan={3}>
-                    <input type="text" />
+                    <input type="text"
+                      value={guardian['user_address']}
+                      onChange={(e) => {guardianValueChange('user_address', e.target.value)}}
+                      ref={el => guardianRef.current['user_address'] = el}
+                    />
+                  </td>
+                </tr>
+                <tr>
+                  <th><span style={{color : "red"}}>*</span>대상자와의 관계</th>
+                  <td colSpan={3}>
+                    <select onChange={(e) => {guardianValueChange('senior_relationship', e.target.value)}}
+                            ref={el => guardianRef.current['senior_relationship'] = el}>
+                      <option>자녀</option>
+                      <option>손자녀</option>
+                      <option>배우자</option>
+                      <option>사위</option>
+                      <option>며느리</option>
+                      <option>형제</option>
+                      <option>자매</option>
+                      <option>남매</option>
+                      <option>친척</option>
+                      <option selected={guardian['senior_relationship'].indexOf('기타') > -1}>기타</option>
+                    </select>
+                    {guardian['senior_relationship'].indexOf('기타') > -1 ? (
+                      <input type="text"
+                        value={guardian['senior_relationship_etc']}
+                        onChange={(e) => {guardianValueChange('senior_relationship_etc', e.target.value)}}
+                        ref={el => guardianRef.current['senior_relationship_etc'] = el}
+                      />
+                    ) : null}
                   </td>
                 </tr>
               </table>
               <div className="btn-wrap flex-center margin-bottom5">
-                <button className={"btn-small green-btn"} onClick={() => {}}>추가</button>
+                <button className={"btn-small green-btn"} onClick={guardianInsert}>추가</button>
               </div>
 
             </div>
client/views/component/Modal_SeniorInsert.jsx
--- client/views/component/Modal_SeniorInsert.jsx
+++ client/views/component/Modal_SeniorInsert.jsx
@@ -1,6 +1,5 @@
 import React, { useState, useRef } from "react";
 import { useSelector } from "react-redux";
-import Button from "./Button.jsx";
 import SubTitle from "./SubTitle.jsx";
 
 import CommonUtil from "../../resources/js/CommonUtil.js";
client/views/pages/App.jsx
--- client/views/pages/App.jsx
+++ client/views/pages/App.jsx
@@ -55,7 +55,6 @@
 
   //URL 변경 시, 발생 이벤트(hook)
   React.useEffect(() => {
-    console.log('location : ', location);
     loginUserSelectOne((loginResultData) => {
       //console.log('loginResultData : ', loginResultData);
       //console.log('isLogin : ', isLogin, ', authority : ', loginResultData['authority']);
client/views/pages/senior_management/SeniorSelectOne.jsx
--- client/views/pages/senior_management/SeniorSelectOne.jsx
+++ client/views/pages/senior_management/SeniorSelectOne.jsx
@@ -1,187 +1,225 @@
 import React from "react";
-import Button from "../../component/Button.jsx";
+import { useNavigate, useLocation } from "react-router";
+
 import SubTitle from "../../component/SubTitle.jsx";
-import { useNavigate } from "react-router";
-import ContentTitle from "../../component/ContentTitle.jsx";
-import PersonIcon from '@mui/icons-material/Person';
-import { useParams } from "react-router";
+import Modal_Guardian from "../../component/Modal_Guardian.jsx";
+
 
 export default function SeniorSelectOne() {
   const navigate = useNavigate();
-  let { seniorId } = useParams();
-  console.log("seniorId : ", seniorId);
+  const location = useLocation();
+  console.log('location.state : ', location.state);
 
-  const [seniortOne, setSeniorOne] = React.useState([]);
-
-  //-------- 상세페이지 선택된 대상자의 정보 불러오기 --------//
-  const getSeniorDataOne = () => {
-    fetch("/user/selectSeniorOne.json", {
-      method: "POST",
-      headers: {
-        'Content-Type': 'application/json; charset=UTF-8'
-      },
-      body: JSON.stringify({
-        user_id: seniorId
-      }),
-    }).then((response) => response.json()).then((data) => {
-      console.log("data : ", data[0]);
-      setSeniorOne(data[0]);
-
-    }).catch((error) => {
-      console.log('getSeniorDataOne() /user/selectSeniorOne.json error : ', error);
-    });
+  //보호자 모달 오픈 여부
+  const [modalGuardianIsOpen, setModalGuardianIsOpen] = React.useState(false);
+  //보호자 모달 오픈
+  const modalGuardianOpen = () => {
+    setModalGuardianIsOpen(true);
+  };
+  //보호자 모달 닫기
+  const modalGuardianClose = () => {
+    setModalGuardianIsOpen(false);
   };
 
-   // 시니어 보호자 매칭 제거
-	const updateSeniorGuardianMatch = () => {
-    fetch("/user/updateGuardianMatchEnd.json", {
+
+  const [medicationTimeCodeList, setMedicationTimeCodeList] = React.useState([]);
+  //복약 시간 코드 목록 조회
+  const medicationTimeCodeSelectList = () => {
+    fetch("/common/medicationTimeCodeSelectList.json", {
       method: "POST",
       headers: {
         'Content-Type': 'application/json; charset=UTF-8'
       },
-      body: JSON.stringify({
-        senior_id: seniorId,
-      }),
+      body: JSON.stringify({}),
     }).then((response) => response.json()).then((data) => {
-      
-      }).catch((error) => {
-      console.log('updateSeniorGuardianMatch() /user/updateGuardianMatchEnd.json error : ', error);
+      console.log("복약 시간 코드 목록 조회 : ", data);
+      setMedicationTimeCodeList(data);
+      setSenior(newSenior);
+    }).catch((error) => {
+      console.log('medicationTimeCodeSelectList() /common/medicationTimeCodeSelectList.json error : ', error);
     });
-	}
-   // 시니어 - 담당자 매칭 종료
-   const updateSeniorAgencyMatchEnd = () => {
-    
-      fetch("/user/updateWorkerMatchEnd.json", {
-        method: "POST",
-        headers: {
-          'Content-Type': 'application/json; charset=UTF-8'
-        },
-        body: JSON.stringify({
-          senior_id: seniorId,
-        }),
-      }).then((response) => response.json()).then((data) => {
-        }).catch((error) => {
-        console.log('updateSeniorAgencyMatchEnd() /user/updateWorkerMatchEnd.json error : ', error);
-      });
-	}
-
-  // 시니어 삭제 (user_use :  true > false)
-  const updateUserState = () => {
-    
-    fetch("/user/updateUserState.json", {
-      method: "POST",
-      headers: {
-        'Content-Type': 'application/json; charset=UTF-8'
-      },
-      body: JSON.stringify({
-        user_id: seniorId,
-      }),
-    }).then((response) => response.json()).then((data) => {
-      }).catch((error) => {
-      console.log('updateUserState() /user/updateUserState.json error : ', error);
-    });
-  
-}
-
-  const delSeniorData = () => {
-    let insertBtn = confirm("삭제하시겠습니까?");
-    if (insertBtn) {
-    updateSeniorGuardianMatch();
-    updateSeniorAgencyMatchEnd();
-    updateUserState();
-    alert('사용자가 삭제되었습니다.');
-    navigate(`/UserAuthoriySelect_agency`);
-    }
-    else {
-      return ;
-    }
   }
 
 
-  React.useEffect(() => {
-    getSeniorDataOne();
+  //시니어 정보
+  const [senior, setSenior] = React.useState({
+    'user_id': location.state['senior_id'],
+    'user_name': null,
+    'user_password': null,
+    'user_phonenumber': null,
+    'user_birth': null,
+    'user_gender': null,
+    'user_address': null,
+    'user_email': null,
+    'authority': 'ROLE_SENIOR',
+    'agency_id': null,
+    'government_id': null,
 
+    'senior_id': location.state['senior_id'],
+    'care_grade': null,
+    'medication_pill': null,
+    'underlie_disease': null,
+    'senior_note': null,
+
+    'seniorMedicationList': [],
+  });
+  //시니어 상세 조회
+  const seniorSelectOne = () => {
+    fetch("/user/seniorSelectOne.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("seniorSelectOne data : ", data);
+      setSenior(data);
+    }).catch((error) => {
+      console.log('seniorSelectOne() /user/seniorSelectOne.json error : ', error);
+    });
+  };
+
+  //보호자 상세 조회
+  const [guardianListBySenior, setGuardianListBySenior] = React.useState([]);
+  const guardianSelectListBySenior = () => {
+    fetch("/user/guardianSelectListBySenior.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("guardianSelectListBySenior data : ", data);
+      setGuardianListBySenior(data);
+    }).catch((error) => {
+      console.log('guardianSelectListBySenior() /user/guardianSelectListBySenior.json error : ', error);
+    });
+  };
+  //선택한 보호자 정보
+  const [guardianBySenior, setGuardianBySenior] = React.useState({});
+
+  //선택한 보호자 정보 관리
+  const guardianBySeniorManagement = (item) => {
+    setGuardianBySenior(item);
+    modalGuardianOpen();
+  }
+
+  React.useEffect(() => {
+    medicationTimeCodeSelectList();
+    seniorSelectOne();
+    guardianSelectListBySenior();
   }, [])
+
+
   return (
     <main>
+    <Modal_Guardian open={modalGuardianIsOpen} close={modalGuardianClose} seniorId={location.state['senior_id']}
+      guardianBySenior={guardianBySenior}
+      guardianManagementCallback={() => {guardianSelectListBySenior(); modalGuardianClose()}}/>
     <div className="content-wrap row">
-    <SubTitle explanation={"대상자 상세 프로필"} className="margin-bottom" />
+      <SubTitle explanation={"대상자 상세 프로필"} className="margin-bottom" />
       <div>
         <table className="margin-bottom senior-detail">
           <tbody>
           <tr>
               <th>아이디</th>
               <td>
-                <span>{seniortOne.user_id}</span>
+                <span>{senior['user_id']}</span>
               </td>             
             </tr>
             <tr>
               <th>이름</th>
               <td>
-                <span>{seniortOne.user_name}</span>
+                <span>{senior['user_name']}</span>
               </td>
               <th>성별</th>
               <td>
-                <span>{seniortOne.user_gender}</span>
+                <span>{senior['user_gender']}</span>
               </td>              
             </tr>
             <tr>
             <th>생년월일</th>
               <td>
-                <span>{seniortOne.user_birth}</span>
+                <span>{senior['user_birth']}</span>
               </td>
               <th>연락처</th>
               <td>
-                <span>{seniortOne.user_phonenumber}</span>
+                <span>{senior['user_phonenumber']}</span>
               </td>
             </tr>
             <tr>
               <th>주소</th>
               <td>
-                <span>{seniortOne.user_address}</span>
+                <span>{senior['user_address']}</span>
               </td>
                             
             </tr>
             <tr>
             <th>필요복약</th>
               <td className="flex-start">
-                {seniortOne.breakfast_medication_check ? <span>아침</span> : <></>}
-                {seniortOne.lunch_medication_check ? <span>점심</span> : <></>}
-                {seniortOne.dinner_medication_check ? <span>저녁</span> : <></>}
+              {medicationTimeCodeList.filter(item => senior.seniorMedicationList.indexOf(item['medication_time_code']) > -1).map((item, idx) => { return (
+                <span>{item['medication_time_code_name']}</span>
+              )})}
               </td>              
             </tr>
             <tr>
               <th>복용중인 약</th>
               <td colSpan={3}>
-                <span className="medicine" cols="30" rows="2">{seniortOne.medication_pill}</span>
+                <span className="medicine" cols="30" rows="2">{senior['medication_pill']}</span>
               </td>
             </tr>
             <tr>
               <th>비고</th>
               <td colSpan={3}>
-                <span className="note" cols="30" rows="2">{seniortOne.senior_note}</span>
+                <span className="note" cols="30" rows="2">{senior['senior_note']}</span>
               </td>
             </tr>
           </tbody>
         </table>
         <div className="btn-wrap flex-center">
-          <Button
-            className={"btn-large gray-btn"}
-            btnName={"수정"}
-            onClick={() => {
-              navigate(`/SeniorEdit/${seniorId}`);
-            }}
-          />
-          <Button
-            className={"btn-large red-btn"}
-            btnName={"삭제"}
-            onClick={() => {
-              delSeniorData();
-            }}
-          />
+          <button className={"btn-large green-btn"} onClick={() => modalGuardianOpen()}>보호자 추가</button>
+          <button className={"btn-large gray-btn"} onClick={() => modalGuardianOpen()}>수정</button>
+          <button className={"btn-large red-btn"} onClick={() => modalGuardianOpen()}>삭제</button>
         </div>
       </div>
+
+      <SubTitle explanation={"대상자의 보호자"} className="margin-bottom" />
+      <div>
+        <table className={"protector-user"}>
+          <thead>
+            <tr>
+              <th>No</th>
+              <th>이름</th>
+              <th>관계</th>
+              <th>연락처</th>
+              <th>주소</th>
+              <th>관리</th>
+            </tr>
+          </thead>
+          <tbody>
+            {guardianListBySenior.map((item, idx) => { return (
+              <tr key={idx}>
+                <td>{idx + 1}</td>
+                <td>{item['user_name']}</td>
+                <td>{item['senior_relationship']}</td>
+                <td>{item['user_phonenumber']}</td>
+                <td>{item['user_address']}</td>
+                <td>
+                  <button className={"btn-small lightgray-btn"} onClick={() => guardianBySeniorManagement(item)}>관리</button>
+                </td>
+              </tr>
+            )})}
+            {guardianListBySenior == null || guardianListBySenior.length == 0 ?
+              <tr>
+                <td colSpan={7}>조회된 데이터가 없습니다</td>
+              </tr>  
+            : null}
+          </tbody>
+        </table>
+      </div>
+
     </div>
+
   </main>
   );
 }
 
client/views/pages/senior_management/SeniorSelectOne_back_230404.jsx (added)
+++ client/views/pages/senior_management/SeniorSelectOne_back_230404.jsx
@@ -0,0 +1,187 @@
+import React from "react";
+import Button from "../../component/Button.jsx";
+import SubTitle from "../../component/SubTitle.jsx";
+import { useNavigate } from "react-router";
+import ContentTitle from "../../component/ContentTitle.jsx";
+import PersonIcon from '@mui/icons-material/Person';
+import { useParams } from "react-router";
+
+export default function SeniorSelectOne() {
+  const navigate = useNavigate();
+  let { seniorId } = useParams();
+  console.log("seniorId : ", seniorId);
+
+  const [seniortOne, setSeniorOne] = React.useState([]);
+
+  //-------- 상세페이지 선택된 대상자의 정보 불러오기 --------//
+  const getSeniorDataOne = () => {
+    fetch("/user/selectSeniorOne.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify({
+        user_id: seniorId
+      }),
+    }).then((response) => response.json()).then((data) => {
+      console.log("data : ", data[0]);
+      setSeniorOne(data[0]);
+
+    }).catch((error) => {
+      console.log('getSeniorDataOne() /user/selectSeniorOne.json error : ', error);
+    });
+  };
+
+   // 시니어 보호자 매칭 제거
+	const updateSeniorGuardianMatch = () => {
+    fetch("/user/updateGuardianMatchEnd.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify({
+        senior_id: seniorId,
+      }),
+    }).then((response) => response.json()).then((data) => {
+      
+      }).catch((error) => {
+      console.log('updateSeniorGuardianMatch() /user/updateGuardianMatchEnd.json error : ', error);
+    });
+	}
+   // 시니어 - 담당자 매칭 종료
+   const updateSeniorAgencyMatchEnd = () => {
+    
+      fetch("/user/updateWorkerMatchEnd.json", {
+        method: "POST",
+        headers: {
+          'Content-Type': 'application/json; charset=UTF-8'
+        },
+        body: JSON.stringify({
+          senior_id: seniorId,
+        }),
+      }).then((response) => response.json()).then((data) => {
+        }).catch((error) => {
+        console.log('updateSeniorAgencyMatchEnd() /user/updateWorkerMatchEnd.json error : ', error);
+      });
+	}
+
+  // 시니어 삭제 (user_use :  true > false)
+  const updateUserState = () => {
+    
+    fetch("/user/updateUserState.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify({
+        user_id: seniorId,
+      }),
+    }).then((response) => response.json()).then((data) => {
+      }).catch((error) => {
+      console.log('updateUserState() /user/updateUserState.json error : ', error);
+    });
+  
+}
+
+  const delSeniorData = () => {
+    let insertBtn = confirm("삭제하시겠습니까?");
+    if (insertBtn) {
+    updateSeniorGuardianMatch();
+    updateSeniorAgencyMatchEnd();
+    updateUserState();
+    alert('사용자가 삭제되었습니다.');
+    navigate(`/UserAuthoriySelect_agency`);
+    }
+    else {
+      return ;
+    }
+  }
+
+
+  React.useEffect(() => {
+    getSeniorDataOne();
+
+  }, [])
+  return (
+    <main>
+    <div className="content-wrap row">
+    <SubTitle explanation={"대상자 상세 프로필"} className="margin-bottom" />
+      <div>
+        <table className="margin-bottom senior-detail">
+          <tbody>
+          <tr>
+              <th>아이디</th>
+              <td>
+                <span>{seniortOne.user_id}</span>
+              </td>             
+            </tr>
+            <tr>
+              <th>이름</th>
+              <td>
+                <span>{seniortOne.user_name}</span>
+              </td>
+              <th>성별</th>
+              <td>
+                <span>{seniortOne.user_gender}</span>
+              </td>              
+            </tr>
+            <tr>
+            <th>생년월일</th>
+              <td>
+                <span>{seniortOne.user_birth}</span>
+              </td>
+              <th>연락처</th>
+              <td>
+                <span>{seniortOne.user_phonenumber}</span>
+              </td>
+            </tr>
+            <tr>
+              <th>주소</th>
+              <td>
+                <span>{seniortOne.user_address}</span>
+              </td>
+                            
+            </tr>
+            <tr>
+            <th>필요복약</th>
+              <td className="flex-start">
+                {seniortOne.breakfast_medication_check ? <span>아침</span> : <></>}
+                {seniortOne.lunch_medication_check ? <span>점심</span> : <></>}
+                {seniortOne.dinner_medication_check ? <span>저녁</span> : <></>}
+              </td>              
+            </tr>
+            <tr>
+              <th>복용중인 약</th>
+              <td colSpan={3}>
+                <span className="medicine" cols="30" rows="2">{seniortOne.medication_pill}</span>
+              </td>
+            </tr>
+            <tr>
+              <th>비고</th>
+              <td colSpan={3}>
+                <span className="note" cols="30" rows="2">{seniortOne.senior_note}</span>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+        <div className="btn-wrap flex-center">
+          <Button
+            className={"btn-large gray-btn"}
+            btnName={"수정"}
+            onClick={() => {
+              navigate(`/SeniorEdit/${seniorId}`);
+            }}
+          />
+          <Button
+            className={"btn-large red-btn"}
+            btnName={"삭제"}
+            onClick={() => {
+              delSeniorData();
+            }}
+          />
+        </div>
+      </div>
+    </div>
+  </main>
+  );
+}
client/views/pages/user_management/UserAuthoriySelect.jsx
--- client/views/pages/user_management/UserAuthoriySelect.jsx
+++ client/views/pages/user_management/UserAuthoriySelect.jsx
@@ -404,12 +404,11 @@
                                 <th>성별</th>
                                 <th>연락처</th>
                                 <th>주소</th>
-                                
                               </tr>
                             </thead>
                             <tbody>
                               {senior.userList.map((item, idx) => { return (
-                                <tr key={idx} onClick={() => {navigate("/SeniorSelectOne")}}>
+                                <tr key={idx} onClick={() => {navigate("/SeniorSelectOne", {state: {'senior_id': item['user_id']}})}}>
                                   <td>{senior.userListCount - idx - (senior.search.currentPage - 1) * senior.search.perPage}</td>
                                   <td>{item['agency_name']}</td>
                                   <td>{item['user_name']}</td>
@@ -471,8 +470,8 @@
                                 <th>이름</th>
                                 <th>연락처</th>
                                 <th>이메일</th>
-                                <th>담당 대상자(어르신)</th>
                                 <th>가입승인</th>
+                                <th>상세보기</th>
                               </tr>
                             </thead>
                             <tbody>
@@ -485,12 +484,12 @@
                                   <td>{item['user_phonenumber']}</td>
                                   <td>{item['user_email']}</td>
                                   <td>
-                                    <button className={"btn-small lightgray-btn"} onClick={() => modalGuardianOpen()}>담당 대상자(어르신) 보기</button>
-                                  </td>
-                                  <td>
                                     {item['is_accept'] ? "승인완료" : 
                                       <button className={"btn-small red-btn"} onClick={() => {}}>가입승인</button>
                                     }
+                                  </td>
+                                  <td>
+                                    <button className={"btn-small lightgray-btn"} onClick={() => modalGuardianOpen()}>상세 페이지 이동</button>
                                   </td>
                                 </tr>
                               )})}
@@ -546,6 +545,7 @@
                                 <th>연락처</th>
                                 <th>이메일</th>
                                 <th>가입승인</th>
+                                <th>관리</th>
                               </tr>
                             </thead>
                             <tbody>
@@ -561,11 +561,14 @@
                                       <button className={"btn-small red-btn"} onClick={() => {}}>가입승인</button>
                                     }
                                   </td>
+                                  <td>
+                                    <button className={"btn-small lightgray-btn"} onClick={() => modalGuardianOpen()}>정보 수정</button>
+                                  </td>
                                 </tr>
                               )})}
                               {government.userList == null || government.userList.length == 0 ?
                                 <tr>
-                                  <td colSpan={6}>조회된 데이터가 없습니다</td>
+                                  <td colSpan={7}>조회된 데이터가 없습니다</td>
                                 </tr>
                               : null}
                             </tbody>
@@ -608,6 +611,7 @@
                                 <th>연락처</th>
                                 <th>이메일</th>
                                 <th>가입승인</th>
+                                <th>관리</th>
                               </tr>
                             </thead>
                             <tbody>
@@ -622,11 +626,14 @@
                                       <button className={"btn-small red-btn"} onClick={() => {}}>가입승인</button>
                                     }
                                   </td>
+                                  <td>
+                                    <button className={"btn-small lightgray-btn"} onClick={() => modalGuardianOpen()}>정보 수정</button>
+                                  </td>
                                 </tr>
                               )})}
                               {admin.userList == null || admin.userList.length == 0 ?
                                 <tr>
-                                  <td colSpan={5}>조회된 데이터가 없습니다</td>
+                                  <td colSpan={6}>조회된 데이터가 없습니다</td>
                                 </tr>
                               : null}
                             </tbody>
Add a comment
List