'use client'; import './style.scss'; import { useState, useEffect } from 'react'; import { LoginLogType } from '@/constants/common'; import { fetchApi, getDateTime } from '@/lib/utils/client'; import { LoginLogsResponse } from '@/types/response/account/loginLogs'; import Loading from '@/app/component/Loading'; import Pagination from '@/app/component/Pagination'; import NavTabs from '../navTabs'; export default function LoginLog() { const [error, setError] = useState(''); const [loading, setLoading] = useState(true); const [page, setPage] = useState(1); const [type, setType] = useState(LoginLogType.Today); const [logs, setLogs] = useState({ total: 0, list: [] }); useEffect(() => { if (error) { alert(error); setError(''); } }, [error]); useEffect(() => { setLoading(true); fetchApi(`/api/mypage/login-logs?type=${type}&page=${page}&perPage=20`).then((res) => { setLogs(res.data!); }).catch(err => { setError(err.message); }).finally(() => { setLoading(false); }); }, [type, page]); useEffect(() => { setPage(1); }, [type]); const tabItems = [ { label: "오늘", value: LoginLogType.Today }, { label: "1주일", value: LoginLogType.Week }, { label: "1개월", value: LoginLogType.Month }, { label: "3개월", value: LoginLogType.QuarterYear }, { label: "6개월", value: LoginLogType.HalfYear } ]; return ( <>
{ loading && }

로그인 기록

합계: {logs.total}
{tabItems.map((item, i) => ( ))}
  • 일시
  • 접속 IP
  • 접속 기기
  • 브라우저
  • 결과
{logs.list.length > 0 ? ( logs.list.map((row) => (
{/* PC */}
  1. {getDateTime(row.createdAt)}
  2. {row.ipAddress}
  3. {row.ipAddress}
  4. {row.userAgent}
  5. {row.success ? '성공' : '실패'}
{/* Mobile */}
)) ) : (

기록이 없습니다.

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