방선주 방선주 2023-02-27
230227 방선주 user등록 및 조회 수정
@c8c699b3d2c7ff5d83a77535022ac5d1c5458fea
 
client/views/component/MatchingModal.jsx (added)
+++ client/views/component/MatchingModal.jsx
@@ -0,0 +1,93 @@
+import React from "react";
+import Button from "./Button.jsx";
+import SubTitle from "./SubTitle.jsx";
+import Table from "./Table.jsx";
+import Pagination from "./Pagination.jsx";
+
+export default function Modal({ children, open, close, header }) {
+
+  //-------- 페이징 작업 설정 시작 --------//
+  const limit = 10; // 페이지당 보여줄 공지 개수
+  const [page, setPage] = React.useState(1); //page index
+  const offset = (page - 1) * limit; //게시물 위치 계산
+  const [agencyTotal, setAgencyTotal] = React.useState(0); //최대길이 넣을 변수
+  //-------- 페이징 작업 설정 끝 --------//
+
+  const thead4 = [
+    "No",
+    "보호사 명",
+    "보호사 ID",
+    "보호사 연락처",
+    "매칭 일자",
+  ];
+  const key4 = [
+    "No",
+    "name",
+    "Id",
+    "phone",
+    "date",
+  ];
+  const content4 = [
+    {
+      No: 1,
+      name: "정복지",
+      Id: "worker5",
+      phone: "010-9876-5432",
+      date: "2023-01-10",
+    },
+    {
+      No: 2,
+      name: "문간호",
+      Id: "worker13",
+      phone: "010-1357-2468",
+      date: "2023-02-07",
+    },
+  ];
+
+  return (
+    <div class={open ? "openModal modal" : "modal"}>
+      {open ? (
+        <div className="modal-inner">
+          <div className="modal-header flex">
+            {header}
+            <Button className={"close"} onClick={close} btnName={"X"} />
+          </div>
+          <div className="modal-main">{children}
+            <div className="board-wrap">
+              <SubTitle explanation={"담당자 선택"} className="margin-bottom" />
+              <div className="flex-start protectorlist margin-bottom5">
+                <input type="text" list="protectorlist" />
+                <datalist id="protectorlist">
+                  <option value="보호사1(ID)"></option>
+                  <option value="보호사2(ID)"></option>
+                  <option value="보호사3(ID)"></option>
+                </datalist>
+                <div className="btn-wrap">
+                  <Button
+                    className={"btn-small green-btn"}
+                    btnName={"등록"}
+                  />
+                </div>
+              </div>
+            </div>
+            <div>
+              <Table
+                className={"caregiver-user"}
+                head={thead4}
+                contents={content4}
+                contentKey={key4}
+                view={"matching"}
+                offset={offset}
+                limit={limit}
+              />
+            </div>
+            <div>
+              <Pagination total={content4.length} limit={limit} page={page} setPage={setPage} />
+            </div>
+          </div>
+        </div>
+
+      ) : null}
+    </div>
+  );
+}
client/views/component/Table.jsx
--- client/views/component/Table.jsx
+++ client/views/component/Table.jsx
@@ -1,8 +1,13 @@
 import React from "react";
 import Button from "./Button.jsx";
+import Modal from "./MatchingModal.jsx";
+import Modal2 from "./Modal.jsx";
+import SubTitle from "./SubTitle.jsx";
+
 // import styled from "styled-components";
 
-export default function Table({ head, contents, contentKey, onClick, className, view, offset, limit}) {
+export default function Table({ head, contents, contentKey, onClick, className, view, offset, limit }) {
+  const [userName, setUserName] = React.useState("");
   const [modalOpen, setModalOpen] = React.useState(false);
   const openModal = () => {
     setModalOpen(true);
@@ -12,24 +17,57 @@
   const openModal2 = () => {
     setModalOpen2(true);
   };
-  
 
+  const closeModal = () => {
+    setModalOpen(false);
+  };
+
+  const closeModal2 = () => {
+    setModalOpen2(false);
+  };
+
+  // 보호자 등록페이지 데이터
+  const thead3 = [
+    "No",
+    "이름",
+    "생년월일",
+    "연락처",
+    "대상자와의 관계",
+  ];
+  const key3 = [
+    "No",
+    "name",
+    "birth",
+    "phone",
+    "relationship",
+  ];
+  const content3 = [
+    {
+      No: 1,
+      name: "김훈",
+      birth: "1965.01.01",
+      relationship: "아들",
+      phone: "010-1234-1234",
+    },
+  ];
+
+  
   const buttonPrint = () => {
-    if(view == 'mySenior'){
-      return(
-      <td>
-        <Button
-          className={"btn-small gray-btn"}
-          btnName={"보기"}
-          onClick={openModal}
-        />
-      </td>)
+    if (view == 'mySenior') {
+      return (
+        <td>
+          <Button
+            className={"btn-small gray-btn"}
+            btnName={"보기"}
+            onClick={openModal}
+          />
+        </td>)
     }
-    else if(view == 'allSenior'){
-      return(
+    else if (view == 'allSenior') {
+      return (
         <>
           <td>
-          <Button
+            <Button
               className={"btn-small gray-btn"}
               btnName={"선택"}
               onClick={openModal2}
@@ -41,46 +79,99 @@
               btnName={"보기"}
               onClick={openModal}
             />
-            </td>
-          </>
+          </td>
+        </>
       )
     }
   }
-  
+
   return (
-    <table className={className}>
-      <thead>
-        <tr>
-          {head.map((i) => {
-            return <th>{i}</th>;
-          })}
-        </tr>
-      </thead>
-      <tbody>
-        {contents.slice(offset, offset + limit).map((i, index) => {
-          return (
-            <tr key={index}>
-            {/* //   <td>{i.rn}</td>
-            //   <td>{i.user_name}</td>
-            //   <td>{i.user_phonenumber}</td>
-            //   <td>{i.user_gender}</td>
-            //   <td>{i.user_birth}</td>
-            //   <td>{i.user_address}</td>
-            //   {buttonPrint()} */}
-            {contentKey.map((kes) => {
-                return (
-                  <>
-                  <td onClick={onClick}>{i[kes]}</td>
-                  </>
-                )
-            })}
-            {buttonPrint()}
+    <>
+      <Modal open={modalOpen2} close={closeModal2} header="담당자 배정" />
+      <Modal2 open={modalOpen} close={closeModal} header={userName+"님의 가족"}>
+        <div className="board-wrap">
+          <SubTitle explanation={"최초 ID는 연락처, PW는 생년월일 8자리입니다."} className="margin-bottom" />
+          <table className="margin-bottom2 senior-insert">
+            <tr>
+              <th>이름</th>
+              <td>
+                <input type="text" />
+              </td>
+              <th>생년월일</th>
+              <td>
+                <div className="flex">
+                  <select name="year" id="year">
+                    <option value="">년</option>
+                  </select>
+                  <select name="month" id="month">
+                    <option value="">월</option>
+                  </select>
+                  <select name="days" id="days">
+                    <option value="">일</option>
+                  </select>
+                </div>
+              </td>
             </tr>
-          );
-        })}
-      </tbody>
-    </table>
-    
+            <tr>
+              <th>연락처</th>
+              <td colSpan={3}>
+                <input type="input" maxLength="11" />
+              </td>
+            </tr>
+            <tr>
+              <th>대상자와의 관계</th>
+              <td colSpan={3}>
+                <input type="text" />
+              </td>
+            </tr>
+          </table>
+          <div className="btn-wrap flex-center margin-bottom5">
+            <Button
+              className={"btn-small green-btn"}
+              btnName={"추가"}
+              onClick={() => {
+                navigate("/SeniorInsert");
+              }}
+            />
+          </div>
+          <div>
+            <Table
+              className={"caregiver-user"}
+              head={thead3}
+              contents={content3}
+              contentKey={key3}
+            />
+          </div>
+        </div>
+      </Modal2>
+      <table className={className}>
+        <thead>
+          <tr>
+            {head.map((i) => {
+              return <th>{i}</th>;
+            })}
+          </tr>
+        </thead>
+        <tbody>
+          {contents.slice(offset, offset + limit).map((i, index) => {
+            const name = i.user_name;
+            return (
+              <tr key={index}>
+                {contentKey.map((kes) => {
+                  return (
+                    <>
+                      <td onClick={onClick}>{i[kes]}</td>
+                      {console.log("userName : ", userName)}
+                    </>
+                  )
+                })}
+                {buttonPrint()}
+              </tr>
+            );
+          })}
+        </tbody>
+      </table>
+    </>
   );
 }
 
client/views/pages/user_management/UserAuthoriySelect_agency.jsx
--- client/views/pages/user_management/UserAuthoriySelect_agency.jsx
+++ client/views/pages/user_management/UserAuthoriySelect_agency.jsx
@@ -7,17 +7,21 @@
 import Pagination from "../../component/Pagination.jsx";
 
 export default function UserAuthoriySelect_agency() {
-  // 화면 진입 시 탭 별 노출될ㄹ 리스트 초기화 
-  const [subjectList, setSubjectList] = React.useState([]);
-  const [subjectMyList, setSubjectMyList] = React.useState([]);
-  
+  // 화면 진입 시 탭 별 노출될 리스트 초기화 
+  const [seniortList, setSeniorList] = React.useState([]);
+  const [seniorMyList, setSeniorMyList] = React.useState([]);
 
-  //페이징 작업
+  //category 설정 초기화
+  const [selectUserCode, setSelectUserCode] = React.useState("전체");
+  const [selectUserData, setSelectUserData] = React.useState("이름");
+  
+  //-------- 페이징 작업 설정 시작 --------//
   const limit = 15; // 페이지당 보여줄 공지 개수
   const [page, setPage] = React.useState(1); //page index
   const offset = (page - 1) * limit; //게시물 위치 계산
   const [myUserTotal, setMyUserTotal] = React.useState(0); //최대길이 넣을 변수
   const [userTotal, setUserTotal] = React.useState(0); //최대길이 넣을 변수
+  //-------- 페이징 작업 설정 끝 --------//
 
   // ------ 등록 버튼 클릭 시 노출되는 모달 데이터 ------//
 
@@ -46,7 +50,7 @@
     setMedication("");
     setNote("");
   }
-  // 변경되는 데이터 Handler
+  //-------- 변경되는 데이터 Handler 설정 --------//
   const handleUserName = (e) => {
     setUserName(e.target.value);
   };
@@ -78,8 +82,16 @@
   const handleNote = (e) => {
     setNote(e.target.value);
   };
-
-  // 대상자 등록 함수 
+  const handleSelectUserCode = (e) => {
+    console.log("e.target.value : ", e.target.value)
+    setSelectUserCode(e.target.value);
+  };
+  const handleSelectUserData = (e) => {
+    console.log("e.target.value : ", e.target.value)
+    setSelectUserData(e.target.value);
+  };
+  //-------- 등록 버튼 동작 수행 영역 시작 --------//
+  // 등록 버튼 클릭 시 수행 함수
   const InsertSenior = () => {
     var insertBtn = confirm("등록하시겠습니까?");
     if (insertBtn) {
@@ -87,8 +99,8 @@
       alert("등록 되었습니다.");
       dataReset();
       closeModal3();
-      getSelectSubjectList();
-      getSelectMySubjectList();
+      getSelectSeniorList();
+      getSelectMySeniorList();
     } else {
       return;
     }
@@ -107,15 +119,15 @@
         user_birth: brith,
         user_phonenumber: telNum,
         user_address: homeAddress,
-        agency_id: 'agency1',
-        government_id: 'government1',
-        user_code: '4'
+        agency_id: 'agency01',
+        government_id: 'government01',
+        user_code: '4',
       }),
     }).then((response) => response.json()).then((data) => {
       console.log("대상자 정보 등록");
       InsertUserPillData();
     }).catch((error) => {
-      console.log('insertSeniorData() /Notice/insertSeniorData.json error : ', error);
+      console.log('insertSeniorData() /user/insertSeniorData.json error : ', error);
     });
   };
   // 대상자 약 복용 정보 등록을 위한 함수 
@@ -139,40 +151,42 @@
       console.log('InsertUserPillData() /user/insertSeniorMadication.json error : ', error);
     });
   };
+  //-------- 등록 버튼 동작 수행 영역 끝 --------//
  //select 
-  const getSelectSubjectList = () => {
+  const getSelectSeniorList = () => {
     fetch("/user/selectUserList.json", {
       method: "POST",
       headers: {
         'Content-Type': 'application/json; charset=UTF-8'
       },
       body: JSON.stringify({
+        agency_id: 'agency01',
         user_code: '4',
       }),
     }).then((response) => response.json()).then((data) => {
       const rowData = data;
       console.log(data);
-      setSubjectList(rowData)
+      setSeniorList(rowData)
       setUserTotal(rowData.length)
     }).catch((error) => {
-      console.log('getSelectSubjectList() /user/selectUserList.json error : ', error);
+      console.log('getSelectSeniorList() /user/selectUserList.json error : ', error);
     });
   };
 
-  const getSelectMySubjectList = () => {
+  const getSelectMySeniorList = () => {
     fetch("/user/selectMyUserList.json", {
       method: "POST",
       headers: {
         'Content-Type': 'application/json; charset=UTF-8'
       },
       body: JSON.stringify({
-        agency_id: 'agency1',
+        agency_id: 'agency01',
         user_code: '4',
       }),
     }).then((response) => response.json()).then((data) => {
       const rowData = data;
       console.log(data);
-      setSubjectMyList(rowData)
+      setSeniorMyList(rowData)
       setMyUserTotal(rowData.length)
     }).catch((error) => {
       console.log('getSubjectMySelect() /user/selectMyUserList.json error : ', error);
@@ -387,7 +401,7 @@
         <Table
           className={"protector-user"}
           head={thead1}
-          contents={subjectMyList}
+          contents={seniorMyList}
           contentKey={key1}
           view={"mySenior"}
           offset={offset}
@@ -402,7 +416,7 @@
         <Table
           className={"caregiver-user"}
           head={thead2}
-          contents={subjectList}
+          contents={seniortList}
           contentKey={key2}
           view={"allSenior"}
           offset={offset}
@@ -416,95 +430,12 @@
 
   
   React.useEffect(() => {
-    getSelectSubjectList();
-    getSelectMySubjectList();
+    getSelectSeniorList();
+    getSelectMySeniorList();
 
   }, [])
   return (
     <main>
-      <Modal open={modalOpen} close={closeModal} header="김복남'님의 가족">
-        <div className="board-wrap">
-          <SubTitle explanation={"최초 ID는 연락처, PW는 생년월일 8자리입니다."} className="margin-bottom" />
-          <table className="margin-bottom2 senior-insert">
-            <tr>
-              <th>이름</th>
-              <td>
-                <input type="text" />
-              </td>
-              <th>생년월일</th>
-              <td>
-                <div className="flex">
-                  <select name="year" id="year">
-                    <option value="">년</option>
-                  </select>
-                  <select name="month" id="month">
-                    <option value="">월</option>
-                  </select>
-                  <select name="days" id="days">
-                    <option value="">일</option>
-                  </select>
-                </div>
-              </td>
-            </tr>
-            <tr>
-              <th>연락처</th>
-              <td colSpan={3}>
-                <input type="input" maxLength="11" />
-              </td>
-            </tr>
-            <tr>
-              <th>대상자와의 관계</th>
-              <td colSpan={3}>
-                <input type="text" />
-              </td>
-            </tr>
-          </table>
-          <div className="btn-wrap flex-center margin-bottom5">
-            <Button
-              className={"btn-small green-btn"}
-              btnName={"추가"}
-              onClick={() => {
-                navigate("/SeniorInsert");
-              }}
-            />
-          </div>
-          <div>
-            <Table
-              className={"caregiver-user"}
-              head={thead3}
-              contents={content3}
-              contentKey={key3}
-            />
-          </div>
-        </div>
-      </Modal>
-      <Modal open={modalOpen2} close={closeModal2} header="담당자 배정">
-        <div className="board-wrap">
-          <SubTitle explanation={"담당자 선택"} className="margin-bottom" />
-          <div className="flex-start protectorlist margin-bottom5">
-            <input type="text" list="protectorlist" />
-            <datalist id="protectorlist">
-              <option value="보호사1(ID)"></option>
-              <option value="보호사2(ID)"></option>
-              <option value="보호사3(ID)"></option>
-            </datalist>
-            <div className="btn-wrap">
-              <Button
-                className={"btn-small green-btn"}
-                btnName={"등록"}
-              />
-            </div>
-          </div>
-          <div>
-            <Table
-              className={"caregiver-user"}
-              head={thead4}
-              contents={content4}
-              contentKey={key4}
-            />
-          </div>
-        </div>
-      </Modal>
       <Modal open={modalOpen3} close={closeModal3} header="대상자 등록">
         <div className="board-wrap">
           <SubTitle explanation={"회원 등록 시 ID는 연락처, 패스워드는 생년월일 8자리입니다."} className="margin-bottom" />
@@ -609,7 +540,7 @@
             <li
               key={item.id}
               className={index === item.id ? "active" : null}
-              onClick={() => setIndex(item.id)}
+              onClick={() => {setIndex(item.id); setPage(1)}}
             >
               {item.title}
             </li>
@@ -617,16 +548,16 @@
         </ul>
         <div className="content-wrap">
           <div className="search-management flex-start margin-bottom2">
-            <select name="management-agency">
+            <select name="management-agency" onChange={handleSelectUserCode} value={selectUserCode}>
               <option value="기관전체">전체</option>
-              <option value="군위군청">대상자</option>
-              <option value="대구보훈병원">복지사</option>
-              <option value="대구보훈병원">보호자</option>
+              <option value="대상자">대상자</option>
+              <option value="담당자">담당자</option>
+              <option value="보호자">보호자</option>
             </select>
-            <select>
+            <select onChange={handleSelectUserData} value={selectUserData}>
               <option value="이름">이름</option>
               <option value="아이디">아이디</option>
-              <option value="아이디">등록번호</option>
+              <option value="등록번호">등록번호</option>
             </select>
             <input type="text" />
             <Button
@@ -645,9 +576,7 @@
               ))}
           </ul>
           <div>
-            {console.log("data.id : ", data)}
-          
-            <Pagination total={data === 1 ? myUserTotal:userTotal} limit={limit} page={page} setPage={setPage} />
+            <Pagination total={index === 1 ? myUserTotal:userTotal} limit={limit} page={page} setPage={setPage} />
           </div>
         </div>
       </div>
Add a comment
List