방선주 방선주 2023-03-08
230308 방선주 시니어-보호자 매칭 삭제
@cbc26ee23723aad0a487c38b0a2ca68209a524ec
client/views/component/Modal_Guardian.jsx
--- client/views/component/Modal_Guardian.jsx
+++ client/views/component/Modal_Guardian.jsx
@@ -192,6 +192,30 @@
     });
   };
 
+  // 시니어 보호자 매칭 제거
+	const updateSeniorGuardianMatch = (guardian_id) => {
+    let insertBtn = confirm("삭제하시겠습니까?");
+    if (insertBtn) {
+      fetch("/user/updateGuardianMatchEnd.json", {
+        method: "POST",
+        headers: {
+          'Content-Type': 'application/json; charset=UTF-8'
+        },
+        body: JSON.stringify({
+          senior_id: seniorId,
+          guardian_id: guardian_id,
+        }),
+      }).then((response) => response.json()).then((data) => {
+        alert('삭제되었습니다.');
+        setAddGuardian(true);
+        }).catch((error) => {
+        console.log('updateSeniorGuardianMatch() /user/updateGuardianMatchEnd.json error : ', error);
+      });
+    } else {
+      return;
+    }
+	}
+
   // 보호자 등록페이지 데이터
   const thead3 = [
     "No",
@@ -259,11 +283,11 @@
               <SubTitle explanation={"최초 ID는 연락처, PW는 생년월일 8자리입니다."} className="margin-bottom" />
               <table className="margin-bottom2 senior-insert">
                 <tr>
-                  <th>이름</th>
+                  <th><span style={{color : "red"}}>*</span>이름</th>
                   <td>
                     <input type="text" value={userName} onChange={handleUserName} />
                   </td>
-                  <th>생년월일</th>
+                  <th><span style={{color : "red"}}>*</span>생년월일</th>
                   <td>
                     <div className="flex">
                       <input type='date' value={brith} onChange={handleBrithday} />
@@ -271,7 +295,7 @@
                   </td>
                 </tr>
                 <tr>
-                  <th>연락처</th>
+                  <th><span style={{color : "red"}}>*</span>연락처</th>
                   <td colSpan={3}>
                     <input type="input" maxLength="13" value={telNum} onChange={handleTelNum} />
                   </td>
@@ -293,7 +317,7 @@
                 />
               </div>
               <div>
-                <Table
+                {/* <Table
                   className={"caregiver-user"}
                   head={thead3}
                   contents={sgMatchList}
@@ -301,7 +325,47 @@
                   view={"guadianMatch"}
                   offset={offset}
                   limit={limit}
-                />
+                /> */}
+                <table className='caregiver-user'>
+                  <thead>
+                    <tr>
+                      {thead3.map((i) => {
+                        return <th>{i}</th>;
+                      })}
+                    </tr>
+                  </thead>
+                  <tbody>
+                    {sgMatchList.slice(offset, offset + limit).map((i, index) => {
+                      const guardian_id = i.guardian_id;
+                      return (
+                        <tr key={index}>
+                          {key3.map((kes) => {
+                            return (
+                              <>
+                                <td
+                                onClick={() => {
+                                  // 대상자 페이지일 때만 상세페이지로 이동하도록 설정
+                                    console.log("i.guardian_id : ", i.guardian_id);
+                                  }}>
+                                  {i[kes]}
+                                </td>
+                              </>
+                            );
+                          })}
+                          <td>
+                            <Button
+                              className={"btn-small gray-btn"}
+                              btnName={"삭제"}
+                              onClick={() => {
+                                updateSeniorGuardianMatch(guardian_id);
+                              }}
+                            />
+                          </td>
+                        </tr>
+                      );
+                    })}
+                  </tbody>
+                </table>
               </div>
               <div>
                 <Pagination total={guardianTotal} limit={limit} page={page} setPage={setPage} />
client/views/component/Modal_SeniorInsert.jsx
--- client/views/component/Modal_SeniorInsert.jsx
+++ client/views/component/Modal_SeniorInsert.jsx
@@ -182,11 +182,11 @@
               </td>
             </tr>*/}
             <tr> 
-              <th>이름</th>
+              <th><span style={{color : "red"}}>*</span>이름</th>
               <td>
                 <input type="text" value={userName} onChange={handleUserName} />
               </td>
-              <th>성별</th>
+              <th><span style={{color : "red"}}>*</span>성별</th>
               <td className="flex-start gender">
                 <div className="flex-start">
                   <input type="radio" name="genderSelect" value="남" onChange={handleGender} />
@@ -199,7 +199,7 @@
               </td>
             </tr>
             <tr>
-              <th>생년월일</th>
+              <th><span style={{color : "red"}}>*</span>생년월일</th>
               <td>
                 <div className="flex">
                   <input type='date' value={brith} onChange={handleBrithday} />
@@ -212,13 +212,13 @@
 
             </tr>
             <tr>
-              <th>연락처</th>
+              <th><span style={{color : "red"}}>*</span>연락처</th>
               <td colSpan={3}>
                 <input type="text" maxLength="13" value={telNum} onChange={handleTelNum} />
               </td>
             </tr>
             <tr>
-              <th>주소</th>
+              <th><span style={{color : "red"}}>*</span>주소</th>
               <td colSpan={3}>
                 <input type="text" value={homeAddress} onChange={handleHomeAddress} />
               </td>
client/views/component/Table.jsx
--- client/views/component/Table.jsx
+++ client/views/component/Table.jsx
@@ -39,34 +39,7 @@
     setModalOpen2(false);
   };
 
-  // 시니어 보호자 매칭 제거
-	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) => {
+  const buttonPrint = (name, id) => {
     if (view == "mySenior") {
       return (
         <td>
@@ -109,33 +82,7 @@
       );
     } 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>
-          <Button
-            className={"btn-small gray-btn"}
-            btnName={"삭제"}
-            onClick={() => {
-              alert("삭제만들거예여.");
-            }}
-          />
-        </td>
-      );
-    }
+    } 
   };
   return (
     <>
Add a comment
List