'use client'; import './style.scss'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import { fetchApi, getDateTime } from '@/lib/utils/client'; import type { MyPostsResponse } from '@/types/response/account/myPosts'; import Loading from '@/app/component/Loading'; import Pagination from '@/app/component/Pagination'; import NavTabs from '../navTabs'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faThumbsUp, faEye } from '@fortawesome/free-regular-svg-icons'; import { faLock, faReply, faFloppyDisk, faImage, faVideo } from '@fortawesome/free-solid-svg-icons'; export default function MyPosts() { const [error, setError] = useState(''); const [loading, setLoading] = useState(true); const [page, setPage] = useState(1); const [data, setData] = useState({ total: 0, list: [] }); useEffect(() => { if (error) { alert(error); setError(''); } }, [error]); useEffect(() => { setLoading(true); fetchApi(`/api/mypage/posts?page=${page}&perPage=20`).then((res) => { setData(res.data!); }).catch(err => { setError(err.message); }).finally(() => { setLoading(false); }); }, [page]); return ( <>
{ loading && }

작성 게시글

합계: {data.total}
  • 번호
  • 게시판
  • 제목
  • 조회
  • 추천
  • 댓글
  • 작성일
{data.list.length > 0 ? ( data.list.map((row) => (
{/* PC */}
  1. {row.num}
  2. {row.boardName}
  3. {row.isSecret && } {row.isReply && } {row.subject} {row.comments > 0 && [{row.comments}]} {row.files > 0 && } {row.images > 0 && } {row.medias > 0 && }
  4. {row.views}
  5. {row.likes}
  6. {row.comments}
  7. {getDateTime(row.createdAt)}
{/* Mobile */}
)) ) : (

작성한 게시글이 없습니다.

)}
{data.list.length > 0 && ( )}
); }