방선주 방선주 2023-03-02
230302 방선주 대상자 상세 화면 출력 적용
@fbd2fe900b4b41dca0126800d974d669cf8ebc2d
client/views/component/Modal_Guadian.jsx
--- client/views/component/Modal_Guadian.jsx
+++ client/views/component/Modal_Guadian.jsx
@@ -68,39 +68,45 @@
     });
   };
   // 보호자 등록 영역
-  const test = () => {
-    console.log("userName : ", userName);
-    console.log("gender : ", gender);
-    console.log("brith : ", brith);
-    console.log("telNum : ", telNum);
-    console.log("homeAddress : ", homeAddress);
-    console.log("relationship : ", relationship);
-    console.log("matchState : ", matchState);
-  }
   const insertUser = () => {
-    fetch("/user/insertSeniorData.json", {
-      method: "POST",
-      headers: {
-        'Content-Type': 'application/json; charset=UTF-8'
-      },
-      body: JSON.stringify({
-        user_name: userName,
-        user_gender: gender != "" ? gender : null,
-        user_birth: brith,
-        user_phonenumber: telNum,
-        user_address: homeAddress != "" ? homeAddress : null,
-        agency_id: 'agency01',
-        government_id: 'government01',
-        user_code: '3',
+    if(userName == ""){
+      alert("이름을 입력해 주세요.");
+      return ;
+    } else if(brith == "") {
+      alert("생년월일을 선택해 주세요.");
+      return ;
+    } else if(telNum == "") {
+      alert("연락처를 입력해 선택해 주세요.");
+      return ;
+    }
+    var insertBtn = confirm("등록하시겠습니까?");
+    if (insertBtn) {
+      fetch("/user/insertSeniorData.json", {
+        method: "POST",
+        headers: {
+          'Content-Type': 'application/json; charset=UTF-8'
+        },
+        body: JSON.stringify({
+          user_name: userName,
+          user_gender: gender != "" ? gender : null,
+          user_birth: brith,
+          user_phonenumber: telNum,
+          user_address: homeAddress != "" ? homeAddress : null,
+          agency_id: 'agency01',
+          government_id: 'government01',
+          user_code: '3',
 
-      }),
-    }).then((response) => response.json()).then((data) => {
-      console.log("보호자 등록");
-      insertGuadian();
-    }).catch((error) => {
-      console.log('insertUser() /user/insertSeniorData.json error : ', error);
-    });
-  };
+        }),
+      }).then((response) => response.json()).then((data) => {
+        console.log("보호자 등록");
+        insertGuadian();
+      }).catch((error) => {
+        console.log('insertUser() /user/insertSeniorData.json error : ', error);
+      });
+    } else {
+      return ;
+    } 
+  }
 
   const insertGuadian = () => {
     fetch("/user/insertGuardian.json", {
@@ -203,7 +209,6 @@
                   className={"btn-small green-btn"}
                   btnName={"추가"}
                   onClick={() => {
-                    test();
                     insertUser()
                     getselectMatchList();
                   }}
client/views/component/Modal_SeniorInsert.jsx
--- client/views/component/Modal_SeniorInsert.jsx
+++ client/views/component/Modal_SeniorInsert.jsx
@@ -64,6 +64,23 @@
   //-------- 등록 버튼 동작 수행 영역 시작 --------//
   // 대상자 정보 등록을 위한 함수 
   const InsertUserData = () => {
+    //-------- 유효성 체크 --------//
+    if(userName == ""){
+      alert("이름을 입력해 주세요.");
+      return ;
+    } else if(gender == "") {
+      alert("성별을 선택해 주세요.");
+      return ;
+    } else if(brith == "") {
+      alert("생년월일을 선택해 주세요.");
+      return ;
+    } else if(telNum == "") {
+      alert("연락처를 입력해 선택해 주세요.");
+      return ;
+    } else if(homeAddress == "") {
+      alert("주소를 선택해 주세요.");
+      return ;
+    }
     var insertBtn = confirm("등록하시겠습니까?");
     if (insertBtn) {
       fetch("/user/insertSeniorData.json", {
client/views/component/Table.jsx
--- client/views/component/Table.jsx
+++ client/views/component/Table.jsx
@@ -3,7 +3,6 @@
 import Modal_Matching from "./Modal_Matching.jsx";
 import Modal_Guadian from "./Modal_Guadian.jsx";
 import { useNavigate } from "react-router";
-import { Link } from 'react-router-dom';
 // import styled from "styled-components";
 
 export default function Table({ head, contents, contentKey, onClick, className, view, offset, limit }) {
@@ -106,8 +105,17 @@
                   return (
                     <>
                       <td onClick={() => 
-                        navigate(`/SeniorSelectOne/${i.user_id}`, { state: { index } })}>
+                        {
+                          // 대상자 페이지일 때만 상세페이지로 이동하도록 설정
+                          if(view == 'mySenior' || view == 'allSenior') {
+                            navigate(`/SeniorSelectOne/${i.user_id}`)
+                          } else {
+                            return ;
+                          }
+                        }
+                      }>
                             {i[kes]}
+                        
                       </td>
                     </>
                   )
client/views/pages/AppRoute.jsx
--- client/views/pages/AppRoute.jsx
+++ client/views/pages/AppRoute.jsx
@@ -22,7 +22,7 @@
 import Main_guardian from "./main/Main_guardian.jsx";
 import Main_agency from "./main/Main_agency.jsx";
 import Main from "./main/Main.jsx";
-import SeniorInsert from "./senior_management/SeniorInsert.jsx";
+import SeniorInsert from "./senior_management/SeniorEdit.jsx";
 import SeniorSelectOne from "./senior_management/SeniorSelectOne.jsx";
 import MedicineCareSelectOne from "./healthcare/medicinecare/MedicineCareSelectOne.jsx";
 import TemperatureManagementSelectOne from "./healthcare/temperature/TemperatureManagementSelectOne.jsx";
client/views/pages/senior_management/SeniorEdit.jsx (Renamed from client/views/pages/senior_management/SeniorInsert.jsx)
--- client/views/pages/senior_management/SeniorInsert.jsx
+++ client/views/pages/senior_management/SeniorEdit.jsx
No changes
client/views/pages/senior_management/SeniorSelectOne.jsx
--- client/views/pages/senior_management/SeniorSelectOne.jsx
+++ client/views/pages/senior_management/SeniorSelectOne.jsx
@@ -9,6 +9,33 @@
   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);
+    });
+  };
+
+
+  React.useEffect(() => {
+    getSeniorDataOne();
+
+  }, [])
   return (
     <main>
     <div className="content-wrap row">
@@ -19,48 +46,48 @@
             <tr>
               <th>이름</th>
               <td>
-                <span></span>
+                <span>{seniortOne.user_name}</span>
               </td>
               <th>성별</th>
               <td>
-                <span></span>
+                <span>{seniortOne.user_gender}</span>
               </td>              
             </tr>
             <tr>
             <th>생년월일</th>
               <td>
-                <span></span>
+                <span>{seniortOne.user_birth}</span>
               </td>
               <th>연락처</th>
               <td>
-                <span></span>
+                <span>{seniortOne.user_phonenumber}</span>
               </td>
             </tr>
             <tr>
               <th>주소</th>
               <td>
-                <span>1등급</span>
+                <span>{seniortOne.user_address}</span>
               </td>
                             
             </tr>
             <tr>
             <th>필요복약</th>
               <td className="flex-start">
-                <span>아침</span>
-                <span>점심</span>
-                <span>저녁</span>
+                {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>혈압약</span>
+                <span className="medicine" cols="30" rows="2">{seniortOne.medication_pill}</span>
               </td>
             </tr>
             <tr>
               <th>비고</th>
-              <td colSpan={3} style={{height:"300px"}}>
-                <span></span>
+              <td colSpan={3}>
+                <span className="note" cols="30" rows="2">{seniortOne.senior_note}</span>
               </td>
             </tr>
           </tbody>
Add a comment
List