update route,

reducing unnecessary complexity.
 Update Dashboard and Review pages, refactor statistics endpoint

Replace source-based summary with categorized breakdown on Dashboard,
remove
batch confirm and individual confirm actions from Review page, and
update
server stats route to return category breakdown with max income/expense
details
This commit is contained in:
2026-05-06 02:02:39 +08:00
parent 1d7a27c105
commit 1598455f5f
3 changed files with 134 additions and 110 deletions
+5 -50
View File
@@ -1,9 +1,8 @@
import React, { useState, useEffect } from "react";
import { CheckCircle, Edit3, Loader2 } from "lucide-react";
import { Edit3, Loader2 } from "lucide-react";
import {
getDeals,
updateDeal,
batchConfirmDeals,
formatAmount,
formatDate,
SOURCE_TYPE_MAP,
@@ -21,7 +20,7 @@ export default function Review() {
const [totalPages, setTotalPages] = useState(0);
const [categories, setCategories] = useState([]);
const [editingDeal, setEditingDeal] = useState(null);
const [showReviewed, setShowReviewed] = useState(false);
const [showReviewed, setShowReviewed] = useState(true);
const [keyword, setKeyword] = useState("");
useEffect(() => {
@@ -60,7 +59,6 @@ export default function Review() {
if (keyword) params.keyword = keyword;
const result = await getDeals(params);
if (append) {
setDeals((prev) => [...prev, ...result.deals]);
} else {
@@ -69,7 +67,6 @@ export default function Review() {
setTotal(result.total);
setPage(result.page);
setTotalPages(result.totalPages);
updateBadge(result, isFirstPage);
} catch (err) {}
setLoading(false);
@@ -98,13 +95,6 @@ export default function Review() {
loadReviewDeals(page + 1, true);
}
async function handleConfirm(deal) {
try {
await updateDeal(deal.id, { reviewed: 1 });
loadReviewDeals(1, false);
} catch (err) {}
}
async function handleUpdateDeal(id, updates) {
try {
await updateDeal(id, updates);
@@ -113,21 +103,6 @@ export default function Review() {
} catch (err) {}
}
async function handleConfirmAll() {
const unreviewed = deals.filter((d) => !d.reviewed);
if (unreviewed.length === 0) return;
if (
!window.confirm(
`确定要批量确认当前已加载的 ${unreviewed.length} 笔交易吗?(共 ${total} 笔待确认)`,
)
)
return;
try {
await batchConfirmDeals(unreviewed.map((d) => d.id));
loadReviewDeals(1, false);
} catch (err) {}
}
const hasMore = page < totalPages;
return (
@@ -181,11 +156,6 @@ export default function Review() {
</span>
)}
</span>
{!showReviewed && deals.length > 0 && (
<button className="btn btn-success btn-sm" onClick={handleConfirmAll}>
<CheckCircle size={14} /> 全部确认
</button>
)}
</div>
{/* Review List */}
@@ -206,7 +176,6 @@ export default function Review() {
>
{formatAmount(deal.amount)}
</div>
<div className="info-col">
<div className="title">
{deal.ai_description || deal.description || "无描述"}
@@ -237,7 +206,6 @@ export default function Review() {
)}
</div>
</div>
<div className="action-col">
{deal.transactions && deal.transactions.length > 0 && (
<span
@@ -251,16 +219,8 @@ export default function Review() {
className="btn btn-secondary btn-sm"
onClick={() => setEditingDeal({ ...deal })}
>
<Edit3 size={12} /> 编辑
<Edit3 size={12} /> {deal.reviewed ? "修改" : "编辑"}
</button>
{!deal.reviewed && (
<button
className="btn btn-success btn-sm"
onClick={() => handleConfirm(deal)}
>
<CheckCircle size={12} /> 确认
</button>
)}
</div>
</div>
))}
@@ -278,12 +238,8 @@ export default function Review() {
<>
<Loader2
size={14}
className="spinner"
style={{
border: "none",
animation: "spin 0.8s linear infinite",
}}
/>
style={{ animation: "spin 0.8s linear infinite" }}
/>{" "}
加载中...
</>
) : (
@@ -362,7 +318,6 @@ export default function Review() {
)}
</div>
{/* Show associated transactions in modal */}
{editingDeal.transactions &&
editingDeal.transactions.length > 0 && (
<div