최정임 최정임 2023-03-08
Merge branch 'admin' of http://210.180.118.83/yjryu/senior_care_system into admin
@0ec8a1431e24868c28e56e8054d84b06c07631b8
client/views/component/Modal_Guardian.jsx (Renamed from client/views/component/Modal_Guadian.jsx)
--- client/views/component/Modal_Guadian.jsx
+++ client/views/component/Modal_Guardian.jsx
@@ -5,12 +5,13 @@
 import Pagination from "./Pagination.jsx";
 
 
-export default function Modal({ open, close, header, useseniorId }) {
-  const seniorId = useseniorId;
+export default function Modal_Guardian({ open, close, header, useSeniorId }) {
+
+  const seniorId = useSeniorId;
   //대상자 - 보호자 매칭 리스트 
   const [sgMatchList, setSgMatchList] = React.useState([]);
-  const [addGuadian, setAddGuadian] = React.useState(true); //추가된 보호자가 있는지 확인
-
+  const [guardianList, setGuardianList] = React.useState([]);
+  const [addGuardian, setAddGuardian] = React.useState(true); //추가된 보호자가 있는지 확인
 
   //사용자 등록 초기값 설정
   const [userName, setUserName] = React.useState("");
@@ -19,16 +20,17 @@
   const [telNum, setTelNum] = React.useState("");
   const [homeAddress, setHomeAddress] = React.useState("");
   const [relationship, setRelationship] = React.useState("");
-  const [matchState, setMatchState] = React.useState(true);
+  const [guardianId, setGuardianId] = React.useState("");
 
   //-------- 페이징 작업 설정 시작 --------//
   const limit = 5; // 페이지당 보여줄 공지 개수
   const [page, setPage] = React.useState(1); //page index
   const offset = (page - 1) * limit; //게시물 위치 계산
-  const [guadianTotal, setGuadianTotal] = React.useState(0); //최대길이 넣을 변수
+  const [guardianTotal, setGuardianTotal] = React.useState(0); //최대길이 넣을 변수
 
   //-------- 변경되는 데이터 Handler 설정 --------//
   const handleUserName = (e) => {
+    e.target.value = e.target.value.replace(/[^ㄱ-ㅎ|ㅏ-ㅣ|가-힣|a-z|A-Z]/g, '');
     setUserName(e.target.value);
   };
   const handleBrithday = (e) => {
@@ -41,15 +43,20 @@
   const handelRelationship = (e) => {
     setRelationship(e.target.value);
   };
+  const handleGuarianId = (e) => {
+    setGuardianId(e.target.value);
+  };
+
   // 데이터 초기화 함수
   const dataReset = () => {
+    setGuardianId("");
     setUserName("");
     setBrith("");
     setTelNum("");
     setRelationship("");
   }
   // 매칭 리스트 출력 영역
-  const getselectMatchList = () => {
+  const getSelectMatchList = () => {
     fetch("/user/selectSeniorGuardianMatch.json", {
       method: "POST",
       headers: {
@@ -59,29 +66,50 @@
         senior_id: seniorId,
       }),
     }).then((response) => response.json()).then((data) => {
-      console.log("getselectMatchList : ", data);
+      console.log("getSelectMatchList : ", data);
       setSgMatchList(data);
-      setGuadianTotal(data.length);
-      setAddGuadian(false);
+      setGuardianTotal(data.length);
+      setAddGuardian(false);
     }).catch((error) => {
-      console.log('getselectMatchList() /user/selectSeniorGuardianMatch.json error : ', error);
+      console.log('getSelectMatchList() /user/selectSeniorGuardianMatch.json error : ', error);
     });
   };
+
+  // 보호자 리스트 불러오기
+  const getSelectGuardianList = () => {
+    fetch("/user/selectUserList.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify({
+        agency_id: 'agency01',
+        user_code: '3',
+      }),
+    }).then((response) => response.json()).then((data) => {
+      const rowData = data;
+      setGuardianList(rowData)
+
+    }).catch((error) => {
+      console.log('getSelectSeniorList() /user/selectUserList.json error : ', error);
+    });
+  };
+
   // 보호자 등록 영역
   const insertUser = () => {
-    if(userName == ""){
+    if (userName == "") {
       alert("이름을 입력해 주세요.");
-      return ;
-    } else if(brith == "") {
+      return;
+    } else if (brith == "") {
       alert("생년월일을 선택해 주세요.");
-      return ;
-    } else if(telNum == "") {
+      return;
+    } else if (telNum == "") {
       alert("연락처를 입력해 선택해 주세요.");
-      return ;
+      return;
     }
     var insertBtn = confirm("등록하시겠습니까?");
     if (insertBtn) {
-      fetch("/user/insertSeniorData.json", {
+      fetch("/user/insertUserData.json", {
         method: "POST",
         headers: {
           'Content-Type': 'application/json; charset=UTF-8'
@@ -101,13 +129,12 @@
         console.log("보호자 등록");
         insertGuadian();
       }).catch((error) => {
-        console.log('insertUser() /user/insertSeniorData.json error : ', error);
+        console.log('insertUser() /user/insertUserData.json error : ', error);
       });
     } else {
-      return ;
-    } 
+      return;
+    }
   }
-
   const insertGuadian = () => {
     fetch("/user/insertGuardian.json", {
       method: "POST",
@@ -119,7 +146,7 @@
       }),
     }).then((response) => response.json()).then((data) => {
       console.log("보호자 테이블 데이터 등록");
-      matchSeniorGuadian();
+      matchSeniorGuadian2();
     }).catch((error) => {
       console.log('insertGuadian() /user/insertGuardian.json error : ', error);
     });
@@ -132,15 +159,34 @@
         'Content-Type': 'application/json; charset=UTF-8'
       },
       body: JSON.stringify({
-        senior_id: useseniorId,
-        user_phonenumber: telNum,
+        senior_id: seniorId,
+        guardian_id: guardianId,
         senior_relationship: relationship,
-        guardian_match_state: matchState,
       }),
     }).then((response) => response.json()).then((data) => {
       console.log("매칭 등록");
       dataReset();
-      setAddGuadian(true);
+      setAddGuardian(true);
+    }).catch((error) => {
+      console.log('matchSeniorGuadian() /user/insertSeniorGuardianMatch.json error : ', error);
+    });
+  };
+
+  const matchSeniorGuadian2 = () => {
+    fetch("/user/insertSeniorGuardianMatch.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify({
+        senior_id: seniorId,
+        user_phonenumber: telNum,
+        senior_relationship: relationship,
+      }),
+    }).then((response) => response.json()).then((data) => {
+      console.log("매칭 등록");
+      dataReset();
+      setAddGuardian(true);
     }).catch((error) => {
       console.log('matchSeniorGuadian() /user/insertSeniorGuardianMatch.json error : ', error);
     });
@@ -164,8 +210,9 @@
   ];
 
   React.useEffect(() => {
-    getselectMatchList();
-  }, [addGuadian])
+    getSelectGuardianList();
+    getSelectMatchList();
+  }, [addGuardian])
 
   return (
     <div class={open ? "openModal modal" : "modal"}>
@@ -177,6 +224,38 @@
           </div>
           <div className="modal-main">
             <div className="board-wrap">
+              <SubTitle explanation={"이미 등록된 사용자는 기존 ID,PW를 사용하시면 됩니다."} className="margin-bottom" />
+              <table className="margin-bottom2 senior-insert">
+                <tr>
+                  <th>검색</th>
+                  <input type="text" list="protectorlist" value={guardianId} onChange={handleGuarianId} />
+                  <datalist id="protectorlist">
+                    {/* <option value="가족1(ID)"></option>
+                    <option value="가족2(ID)"></option> */}
+                    {guardianList.map((item) => {
+                      // console.log('item : ',item)
+                      // setGaudianId(item['user_id'])
+                      // setTelNum(item['user_phonenumber'])
+                      return <option value={item['user_id']}>{item['user_name']}({item['user_id']})</option>
+                    })}
+                  </datalist>
+                </tr>
+                <tr>
+                  <th>대상자와의 관계</th>
+                  <td colSpan={3}>
+                    <input type="text" value={relationship} onChange={handelRelationship} />
+                  </td>
+                </tr>
+              </table>
+              <div className="btn-wrap flex-center margin-bottom5">
+                <Button
+                  className={"btn-small green-btn"}
+                  btnName={"등록"}
+                  onClick={() => {
+                    matchSeniorGuadian();
+                  }}
+                />
+              </div>
               <SubTitle explanation={"최초 ID는 연락처, PW는 생년월일 8자리입니다."} className="margin-bottom" />
               <table className="margin-bottom2 senior-insert">
                 <tr>
@@ -204,26 +283,12 @@
                   </td>
                 </tr>
               </table>
-
-              <SubTitle explanation={"이미 등록된 사용자는 기존 ID,PW를 사용하시면 됩니다."} className="margin-bottom" />
-              <div className="flex-start">
-              <Button
-                  className={"btn-small red-btn"}
-                  btnName={"찾기"}
-                />
-                <input type="text" list="protectorlist" />
-                <datalist id="protectorlist">
-                  <option value="가족1(ID)"></option>
-                  <option value="가족2(ID)"></option>
-                </datalist>
-              </div>
               <div className="btn-wrap flex-center margin-bottom5">
                 <Button
-                  className={"btn-small red-btn"}
+                  className={"btn-small green-btn"}
                   btnName={"추가"}
                   onClick={() => {
                     insertUser()
-                    getselectMatchList();
                   }}
                 />
               </div>
@@ -239,7 +304,7 @@
                 />
               </div>
               <div>
-                <Pagination total={guadianTotal} limit={limit} page={page} setPage={setPage} />
+                <Pagination total={guardianTotal} limit={limit} page={page} setPage={setPage} />
               </div>
             </div>
           </div>
@@ -248,4 +313,4 @@
     </div>
 
   );
-}
+}
(파일 끝에 줄바꿈 문자 없음)
client/views/component/Modal_SeniorInsert.jsx
--- client/views/component/Modal_SeniorInsert.jsx
+++ client/views/component/Modal_SeniorInsert.jsx
@@ -4,6 +4,7 @@
 
 export default function Modal({ open, close, header, setModalOpen3, setAddSenior }) {
    // 사용자 등록 시 초기값 세팅
+  //  const [seniorId, setSeniorId] = React.useState("");
    const [userName, setUserName] = React.useState("");
    const [gender, setGender] = React.useState("");
    const [brith, setBrith] = React.useState("");
@@ -15,8 +16,15 @@
    const [medication, setMedication] = React.useState("");
    const [note, setNote] = React.useState("");
 
+  // //id blor 처리 진행 
+  // const inputRef = React.useRef();
+  // const settingBlor = (e) => {
+  //   inputRef.current.blur();
+  // }
+
      // 등록 후 초기화 진행
   const dataReset = () => {
+    // setSeniorId("");
     setUserName("");
     setGender("");
     setBrith("");
@@ -29,7 +37,12 @@
     setNote("");
   }
    //-------- 변경되는 데이터 Handler 설정 --------//
+  // const handleUserId = (e) => {
+  //   console.log(e.target.value);
+  //   setSeniorId(e.target.value);
+  // };
   const handleUserName = (e) => {
+    e.target.value=e.target.value.replace(/[^ㄱ-ㅎ|ㅏ-ㅣ|가-힣|a-z|A-Z]/g, '');
     setUserName(e.target.value);
   };
   const handleGender = (e) => {
@@ -83,7 +96,7 @@
     }
     var insertBtn = confirm("등록하시겠습니까?");
     if (insertBtn) {
-      fetch("/user/insertSeniorData.json", {
+      fetch("/user/insertUserData.json", {
         method: "POST",
         headers: {
           'Content-Type': 'application/json; charset=UTF-8'
@@ -102,7 +115,7 @@
         console.log("대상자 정보 등록");
         InsertUserPillData();
       }).catch((error) => {
-        console.log('insertSeniorData() /user/insertSeniorData.json error : ', error);
+        console.log('insertUserData() /user/insertUserData.json error : ', error);
       });
     } else {
       return;
@@ -137,6 +150,7 @@
   //-------- 등록 버튼 동작 수행 영역 끝 --------/
   //-------- 모달 종료 -------->
   const noticeModalClose = () => {
+    dataReset();
     setModalOpen3(false);
   };
   return (
@@ -161,7 +175,13 @@
             />
               </td>
             </tr> */}
-            <tr>
+            {/* <tr>
+              <th>아이디</th>
+              <td>
+                <input type="text" value={`${telNum}_${userName}`.replace(/[-]/g,'')} onChange={handleUserId} onClick={(e) => settingBlor(e.target.value)} ref={inputRef} style={{backgroundColor : `#D3D3D3`}} readonly/>
+              </td>
+            </tr>*/}
+            <tr> 
               <th>이름</th>
               <td>
                 <input type="text" value={userName} onChange={handleUserName} />
client/views/component/Table.jsx
--- client/views/component/Table.jsx
+++ client/views/component/Table.jsx
@@ -1,7 +1,7 @@
 import React from "react";
 import Button from "./Button.jsx";
 import Modal_Matching from "./Modal_Matching.jsx";
-import Modal_Guadian from "./Modal_Guadian.jsx";
+import Modal_Guardian from "./Modal_Guardian.jsx";
 import { useNavigate } from "react-router";
 // import styled from "styled-components";
 
@@ -19,7 +19,7 @@
   // 모달 title에 대상자 명 출력을 위함
   const [useName, setUseUserName] = React.useState("");
   // 매칭을 위해 대상자 ID 값 전달을 위함
-  const [useseniorId, setUseSeniorId] = React.useState("");
+  const [useSeniorId, setUseSeniorId] = React.useState("");
 
   const [modalOpen, setModalOpen] = React.useState(false);
   const openModal = () => {
@@ -39,7 +39,34 @@
     setModalOpen2(false);
   };
 
-  const buttonPrint = (name, id) => {
+  // 시니어 보호자 매칭 제거
+	const updateSeniorGuardianMatch = (useSeniorId,useGuardianId) => {
+    console.log("useSeniorId",useSeniorId);
+    console.log("useGuardianId",useGuardianId);
+    var insertBtn = confirm("삭제하시겠습니까?");
+    if (insertBtn) {
+      fetch("/user/updateGuardianMatchEnd.json", {
+        method: "POST",
+        headers: {
+          'Content-Type': 'application/json; charset=UTF-8'
+        },
+        body: JSON.stringify({
+          senior_id: useSeniorId,
+          guardian_id: useGuardianId,
+        }),
+      }).then((response) => response.json()).then((data) => {
+        alert('삭제되었습니다.');
+        }).catch((error) => {
+        console.log('updateSeniorGuardianMatch() /user/updateGuardianMatchEnd.json error : ', error);
+      });
+    } else {
+      return;
+    }
+	}
+
+
+  
+  const buttonPrint = (name, id, guardianId, seniorId) => {
     if (view == "mySenior") {
       return (
         <td>
@@ -71,7 +98,7 @@
             <Button
               className={"btn-small gray-btn"}
               btnName={"보기"}
-              onClick={(e) => {
+              onClick={() => {
                 setUseUserName(name);
                 setUseSeniorId(id);
                 openModal();
@@ -82,6 +109,20 @@
       );
     } else if (view == "qna") {
       return;
+    } else if (view == "guadianMatch") {
+      return (
+        <td>
+          <Button
+            className={"btn-small gray-btn"}
+            btnName={"삭제"}
+            onClick={() => {
+              // setUseSeniorId(seniorId);
+              // setUseGuardianId(guardianId);
+              updateSeniorGuardianMatch(seniorId,guardianId,name,id);
+            }}
+          />
+        </td>
+      );
     } else {
       return (
         <td>
@@ -96,7 +137,6 @@
       );
     }
   };
-
   return (
     <>
       {/* 담당자 보기 모달 */}
@@ -107,11 +147,11 @@
       />
       {/* 보호자 보기 모달창  */}
       {modalOpen ? (
-        <Modal_Guadian
+        <Modal_Guardian
           open={modalOpen}
           close={closeModal}
           header={useName + "님의 가족"}
-          useseniorId={useseniorId}
+          useSeniorId={useSeniorId}
         />
       ) : null}
       <table className={className}>
@@ -126,6 +166,8 @@
           {contents.slice(offset, offset + limit).map((i, index) => {
             const userName = i.user_name;
             const userId = i.user_id;
+            const guardianId = i.guardian_id;
+            const seniorId = i.senior_id;
             return (
               <tr key={index}>
                 {contentKey.map((kes) => {
@@ -150,7 +192,7 @@
                     </>
                   );
                 })}
-                {buttonPrint(userName, userId)}
+                {buttonPrint(userName, userId, guardianId, seniorId)}
               </tr>
             );
           })}
client/views/pages/callcenter/QuestionConfirm.jsx
--- client/views/pages/callcenter/QuestionConfirm.jsx
+++ client/views/pages/callcenter/QuestionConfirm.jsx
@@ -8,7 +8,38 @@
 
   const navigate = useNavigate();
 
+  const [username, setUsername] = React.useState("");
+  const [qnaOne, setQnaOne] = React.useState([]);
 
+
+  //qna 조회
+  const getQnaOne = () => {
+    fetch("/qna/qnaSelectOne.json", {
+      method: "POST",
+      headers: {
+        "Content-Type": 'application/json; charset=UTF-8',
+      },
+      body: JSON.stringify({
+        qna_insert_user_name : username
+        
+      }),
+    })
+      .then((response) => response.json())
+      .then((data) => {
+        console.log(data[3]);
+        setQnaOne(data[3]);
+      })
+      .catch((error) => {
+        console.log("qna error : ", error);
+      });
+  };
+
+  React.useEffect(() => {
+
+    getQnaOne();
+
+  }, [])
+  
   return (
     <main>
       <div className="content-wrap row">
@@ -17,29 +48,23 @@
         <table className="margin-bottom2 senior-insert">
           <tr>
             <th>작성자</th>
-            <td>
-              김가족
-            </td>
+            <td>{qnaOne.qna_insert_user_name}</td>
           </tr>
 
           <tr>
             <th>제목</th>
-            <td colSpan={3}>
-              문의
-            </td>
+            <td colSpan={3}>{qnaOne.qna_title}</td>
           </tr>
           <tr>
-              <th>내용</th>
-              <td colSpan={3}>
-                문의합니다.
-              </td>
-            </tr>
-            <tr>
-              <th>답변하기</th>
-              <td colSpan={3}>
-                <textarea className="medicine" cols="30" rows="2"></textarea>
-              </td>
-            </tr>
+            <th>내용</th>
+            <td colSpan={3}>{qnaOne.qna_content}</td>
+          </tr>
+          <tr>
+            <th>답변하기</th>
+            <td colSpan={3}>
+              <textarea className="medicine" cols="30" rows="2"></textarea>
+            </td>
+          </tr>
         </table>
        
         <div className="btn-wrap flex-center">
@@ -62,3 +87,114 @@
     </main>
   );
 }
+
+// import React from "react";
+// import Button from "../../component/Button.jsx";
+// import ContentTitle from "../../component/ContentTitle.jsx";
+// import SubTitle from "../../component/SubTitle.jsx";
+// import { useNavigate } from "react-router";
+// import { useParams } from "react-router";
+
+// export default function QuestionConfirm() {
+//   const navigate = useNavigate();
+
+
+//   const [username, setUsername] = React.useState("");
+//   const [qnaOne, setQnaOne] = React.useState([]);
+
+
+//   //qna 조회
+//   const getQnaOne = () => {
+//     fetch("/qna/qnaSelectOne.json", {
+//       method: "POST",
+//       headers: {
+//         "Content-Type": 'application/json; charset=UTF-8',
+//       },
+//       body: JSON.stringify({
+//         qna_insert_user_name : username
+        
+//       }),
+//     })
+//       .then((response) => response.json())
+//       .then((data) => {
+//         console.log(data[3]);
+//         setQnaOne(data[3]);
+//       })
+//       .catch((error) => {
+//         console.log("qna error : ", error);
+//       });
+//   };
+
+
+//   // 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(() => {
+
+//     getQnaOne();
+
+//   }, [])
+
+
+//   return (
+//     <main>
+//       <div className="content-wrap row">
+//         <ContentTitle contentTitle={"문의글 작성"} />
+//         <SubTitle explanation={"작성자 정보"} />
+//         <table className="margin-bottom2 senior-insert">
+//           <tr>
+//             <th>작성자</th>
+//             <td>{qnaOne.qna_insert_user_name}</td>
+//           </tr>
+
+//           <tr>
+//             <th>제목</th>
+//             <td colSpan={3}>{qnaOne.qna_title}</td>
+//           </tr>
+//           <tr>
+//             <th>내용</th>
+//             <td colSpan={3}>{qnaOne.qna_content}</td>
+//           </tr>
+//           <tr>
+//             <th>답변하기</th>
+//             <td colSpan={3}>
+//               <textarea className="medicine" cols="30" rows="2"></textarea>
+//             </td>
+//           </tr>
+//         </table>
+
+//         <div className="btn-wrap flex-center">
+//           <Button
+//             className={"btn-large gray-btn"}
+//             btnName={"이전"}
+//             onClick={() => {
+//               navigate("/QuestionSelect");
+//             }}
+//           />
+//           <Button
+//             className={"btn-large green-btn"}
+//             btnName={"등록"}
+//             onClick={() => {
+//               navigate("/QuestionSelect");
+//             }}
+//           />
+//         </div>
+//       </div>
+//     </main>
+//   );
+// }
client/views/pages/senior_management/SeniorEdit.jsx
--- client/views/pages/senior_management/SeniorEdit.jsx
+++ client/views/pages/senior_management/SeniorEdit.jsx
@@ -29,7 +29,7 @@
       setMedicineL(data[0].lunch_medication_check)
       setMedicineD(data[0].dinner_medication_check)
       setMedication(data[0].medication_pill)
-      setNote(data[0].user_phonenumber)
+      setNote(data[0].senior_note)
 
     }).catch((error) => {
       console.log('getSeniorDataOne() /user/selectSeniorOne.json error : ', error);
client/views/pages/senior_management/SeniorSelectOne.jsx
--- client/views/pages/senior_management/SeniorSelectOne.jsx
+++ client/views/pages/senior_management/SeniorSelectOne.jsx
@@ -108,9 +108,11 @@
             }}
           />
           <Button
-            className={"btn-large green-btn"}
+            className={"btn-large red-btn"}
             btnName={"삭제"}
-            
+            onClick={() => {
+              alert("삭제 기능 만들거지롱.");
+            }}
           />
         </div>
       </div>
client/views/pages/user_management/UserAuthoriySelect_agency.jsx
--- client/views/pages/user_management/UserAuthoriySelect_agency.jsx
+++ client/views/pages/user_management/UserAuthoriySelect_agency.jsx
@@ -47,12 +47,12 @@
       }),
     }).then((response) => response.json()).then((data) => {
       const rowData = data;
-      if(addSenior || rowData.length !=data.length){
+      
         console.log(data);
         setSeniorList(rowData);
         setUserTotal(rowData.length);
         setAddSenior(false);
-      }
+      
 
     }).catch((error) => {
       console.log('getSelectSeniorList() /user/selectUserList.json error : ', error);
Add a comment
List