blob: 9df8f67f9ccaf2cb6bef4f9a59cb8f4166d3c2f6 [file] [log] [blame]
TRM-coding85e5c322025-06-18 19:49:21 +08001import React, { useState, useEffect } from 'react';
2import { fetchRecordLog } from '../api/posts_trm';
3
4function TransactionLogs({ userId }) {
5 const [records, setRecords] = useState([]);
6
7 useEffect(() => {
8 fetchRecordLog(userId)
9 .then(data => setRecords(data))
10 .catch(err => console.error('fetchRecordLog error:', err));
11 }, [userId]);
12
13 return (
14 <section className="dashboard-logs">
15 <table className="admin-table">
16 <thead>
17 <tr>
18 <th>ID</th>
19 <th>用户ID</th>
20 <th>类型</th>
21 <th>内容</th>
22 <th>IP</th>
23 <th>创建时间</th>
24 </tr>
25 </thead>
26 <tbody>
27 {records.length > 0
28 ? records.map((r, i) => (
29 <tr key={i}>
30 <td>{r.id}</td>
31 <td>{r.user_id}</td>
32 <td>{r.type}</td>
33 <td>{r.content}</td>
34 <td>{r.ip}</td>
35 <td>{new Date(r.created_at).toLocaleString()}</td>
36 </tr>
37 ))
38 : (
39 <tr>
40 <td colSpan="6" style={{ textAlign: 'center' }}>暂无数据</td>
41 </tr>
42 )
43 }
44 </tbody>
45 </table>
46 </section>
47 );
48}
49
50export default TransactionLogs;