'use client'; import './style.scss'; import { useState, useEffect } from 'react'; import { LoginLogType } from '@/constants/common'; import { fetchApi, getDateTime } from '@/lib/utils/client'; import type { ChargeLogsResponse } from '@/types/response/account/chargeLogs'; import Loading from '@/app/component/Loading'; import Pagination from '@/app/component/Pagination'; import NavTabs from '../navTabs'; const STATUS_MAP: Record = { Paid: { label: '완료', cls: 'status--paid' }, Pending: { label: '대기', cls: 'status--pending' }, WaitingDeposit: { label: '입금대기', cls: 'status--pending' }, Failed: { label: '실패', cls: 'status--failed' }, Cancelled: { label: '취소', cls: 'status--cancelled' } }; const METHOD_MAP: Record = { Card: '신용카드', VirtualAccount: '가상계좌', Mobile: '휴대폰', Transfer: '계좌이체', NaverPay: '네이버페이', KakaoPay: '카카오페이', Payco: '페이코', Integrated: '통합결제' }; export default function ChargeLogs() { const [error, setError] = useState(''); const [loading, setLoading] = useState(true); const [page, setPage] = useState(1); const [type, setType] = useState(LoginLogType.Today); const [data, setData] = useState({ total: 0, list: [] }); useEffect(() => { if (error) { alert(error); setError(''); } }, [error]); useEffect(() => { setLoading(true); fetchApi(`/api/mypage/charge-logs?type=${type}&page=${page}&perPage=20`).then((res) => { setData(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 } ]; const getStatus = (status: string) => STATUS_MAP[status] ?? { label: status, cls: '' }; const getMethod = (method: string) => METHOD_MAP[method] ?? method; return ( <>
{loading && }

(P) 충전 내역

합계: {data.total}
{tabItems.map((item, i) => ( ))}
  • 일시
  • 주문번호
  • 결제 수단
  • 결제 금액
  • 포인트
  • 상태
{data.list.length > 0 ? ( data.list.map((row) => { const st = getStatus(row.status); return (
{/* PC */}
  1. {getDateTime(row.paidAt ?? row.createdAt)}
  2. {row.orderID}
  3. {getMethod(row.paymentMethod)}
  4. {row.amount.toLocaleString()}원
  5. +{row.pointAmount.toLocaleString()}P
  6. {st.label}
{/* Mobile */}
); }) ) : (

충전 기록이 없습니다.

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