page.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. 'use client';
  2. import './style.scss';
  3. import Link from 'next/link';
  4. import Image from 'next/image';
  5. import { useState, useEffect } from 'react';
  6. import useAuth from '@/hooks/useAuth';
  7. import { formatDate, stripHtmlTags } from '@/lib/utils/client';
  8. import NavTabs from '../navTabs';
  9. import Loading from '@/app/component/Loading';
  10. export default function Profile()
  11. {
  12. const { member } = useAuth();
  13. const [error, setError] = useState<string>('');
  14. const [loading, setLoading] = useState<boolean>(true);
  15. useEffect(() => {
  16. if (error) {
  17. alert(error);
  18. setError('');
  19. }
  20. }, [error]);
  21. useEffect(() => {
  22. if (member) {
  23. setLoading(false);
  24. }
  25. }, [member]);
  26. if (!member) {
  27. return <Loading />;
  28. }
  29. return (
  30. <>
  31. <NavTabs />
  32. <div id="profile">
  33. { loading && <Loading /> }
  34. <h1>내 정보</h1>
  35. <div className="grid grid-cols-1 xl:grid-cols-2 gap-3">
  36. <table className="table-auto">
  37. <caption>등록 정보</caption>
  38. <colgroup>
  39. <col style={{width: "100%", minWidth: "80px", maxWidth: "30%"}}/>
  40. <col/>
  41. <col/>
  42. </colgroup>
  43. <tbody>
  44. <tr>
  45. <th>사용자 ID</th>
  46. <td colSpan={2}>{member?.sid}</td>
  47. </tr>
  48. <tr>
  49. <th>이메일</th>
  50. <td>{member?.email}</td>
  51. <td>
  52. <Link href="/change-email" className="btn btn-default">이메일 변경</Link>
  53. </td>
  54. </tr>
  55. <tr>
  56. <th>별명</th>
  57. <td>{member?.name || '-'}</td>
  58. <td>
  59. <Link href="/change-name" className="btn btn-default">별명 변경</Link>
  60. </td>
  61. </tr>
  62. <tr>
  63. <th>본인인증</th>
  64. <td>{member?.isAuthCertified ? '인증 완료' : '-'}</td>
  65. <td></td>
  66. </tr>
  67. <tr>
  68. <th>회원가입 일시</th>
  69. <td colSpan={2}>{formatDate(member.createdAt)}</td>
  70. </tr>
  71. <tr>
  72. <th>마지막 로그인 일시</th>
  73. <td colSpan={2}>{formatDate(member.lastLoginAt)}</td>
  74. </tr>
  75. <tr>
  76. <th>알림 수신</th>
  77. <td>
  78. <div className="flex items-center gap-6">
  79. <div className="flex items-center gap-4">
  80. <label className="flex items-center gap-2 text-gray-700">
  81. <input type="checkbox" checked={member.memberApprove.isReceiveSMS} readOnly disabled className="h-5 w-5 accent-gray-500 cursor-not-allowed" />
  82. SMS
  83. </label>
  84. <label className="flex items-center gap-2 text-gray-700">
  85. <input type="checkbox" checked={member.memberApprove.isReceiveEmail} readOnly disabled className="h-5 w-5 accent-gray-500 cursor-not-allowed" />
  86. 메일
  87. </label>
  88. <label className="flex items-center gap-2 text-gray-700">
  89. <input type="checkbox" checked={member.memberApprove.isReceiveNote} readOnly disabled className="h-5 w-5 accent-gray-500 cursor-not-allowed" />
  90. 쪽지
  91. </label>
  92. </div>
  93. </div>
  94. </td>
  95. <td>
  96. <Link href="/change-approve" className="btn btn-default">수신 설정</Link>
  97. </td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. <table className="mt-3 xl:mt-0 table-auto">
  102. <caption>활동 정보</caption>
  103. <colgroup>
  104. <col style={{width: "100%", minWidth: "80px", maxWidth: "30%"}}/>
  105. <col width="*"/>
  106. <col width="*"/>
  107. </colgroup>
  108. <tbody>
  109. <tr>
  110. <th>회원 사진</th>
  111. <td>
  112. {/* {member?.photo ? <Image src={member?.photo} alt="회원 사진" width={98} height={98} style={{objectFit: "cover"}} unoptimized={true} /> : '-'} */}
  113. </td>
  114. <td>
  115. <Link href="/change-photo" className="btn btn-default">사진 변경</Link>
  116. </td>
  117. </tr>
  118. <tr>
  119. <th>회원 등급</th>
  120. <td></td>
  121. <td></td>
  122. </tr>
  123. <tr>
  124. <th>한마디</th>
  125. <td colSpan={2}>
  126. <div className="grid grid-cols-[1fr_auto] gap-2 items-center">
  127. <span className="truncate">{member?.summary || '-'}</span>
  128. <Link href="/change-summary" className="btn btn-default">한마디 변경</Link>
  129. </div>
  130. </td>
  131. </tr>
  132. <tr>
  133. <th>자기소개</th>
  134. <td colSpan={2}>
  135. <div className="grid grid-cols-[1fr_auto] gap-2 items-center">
  136. <span className="truncate">{stripHtmlTags(member.intro) || '-'}</span>
  137. <Link href="/change-intro" className="btn btn-default">자기소개 변경</Link>
  138. </div>
  139. </td>
  140. </tr>
  141. <tr>
  142. <th>경험치</th>
  143. <td colSpan={2}>{member?.exp}</td>
  144. </tr>
  145. <tr>
  146. <th>작성 게시글</th>
  147. <td colSpan={2}>{member?.posts}</td>
  148. </tr>
  149. <tr>
  150. <th>작성 댓글</th>
  151. <td colSpan={2}>{member?.comments}</td>
  152. </tr>
  153. <tr>
  154. <th>구독자</th>
  155. <td colSpan={2}>{member?.following}</td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. </div>
  160. <br />
  161. <dl>
  162. <dt>회원님의 개인정보는 안전하게 보호됩니다.</dt>
  163. <dd>※ 의심스러운 활동이 감지되면 즉시 비밀번호를 변경하세요.</dd>
  164. <dd>※ 보안을 위해 비밀번호를 주기적으로 변경하는 것이 좋습니다.</dd>
  165. <dd>※ 자동 로그인 기능을 사용하면, 로그인 상태가 유지됩니다.</dd>
  166. <dd>※ 공용 컴퓨터에서는 자동 로그인을 사용하지 않는 것이 좋습니다. </dd>
  167. </dl>
  168. </div>
  169. </>
  170. );
  171. }