Remove unused expandable deal UI and review_notes field
Simplify the review page by removing the expandable
This commit is contained in:
+20
-99
@@ -1,11 +1,5 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import { CheckCircle, Edit3, Loader2 } from "lucide-react";
|
||||||
CheckCircle,
|
|
||||||
Edit3,
|
|
||||||
ChevronDown,
|
|
||||||
ChevronRight,
|
|
||||||
Loader2,
|
|
||||||
} from "lucide-react";
|
|
||||||
import {
|
import {
|
||||||
getDeals,
|
getDeals,
|
||||||
updateDeal,
|
updateDeal,
|
||||||
@@ -29,14 +23,12 @@ export default function Review() {
|
|||||||
const [editingDeal, setEditingDeal] = useState(null);
|
const [editingDeal, setEditingDeal] = useState(null);
|
||||||
const [showReviewed, setShowReviewed] = useState(false);
|
const [showReviewed, setShowReviewed] = useState(false);
|
||||||
const [keyword, setKeyword] = useState("");
|
const [keyword, setKeyword] = useState("");
|
||||||
const [expandedDeals, setExpandedDeals] = useState(new Set());
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadCategories();
|
loadCategories();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// When filters change, reset and reload from page 1
|
|
||||||
loadReviewDeals(1, false);
|
loadReviewDeals(1, false);
|
||||||
}, [showReviewed, keyword]);
|
}, [showReviewed, keyword]);
|
||||||
|
|
||||||
@@ -78,7 +70,6 @@ export default function Review() {
|
|||||||
setPage(result.page);
|
setPage(result.page);
|
||||||
setTotalPages(result.totalPages);
|
setTotalPages(result.totalPages);
|
||||||
|
|
||||||
// Update badge count in sidebar
|
|
||||||
updateBadge(result, isFirstPage);
|
updateBadge(result, isFirstPage);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -92,7 +83,6 @@ export default function Review() {
|
|||||||
if (!showReviewed) {
|
if (!showReviewed) {
|
||||||
badge.textContent = result.total;
|
badge.textContent = result.total;
|
||||||
} else if (isFirstPage) {
|
} else if (isFirstPage) {
|
||||||
// When showing reviewed, fetch unreviewed count for badge (only once)
|
|
||||||
const unreviewed = await getDeals({
|
const unreviewed = await getDeals({
|
||||||
min_amount: 100,
|
min_amount: 100,
|
||||||
reviewed: 0,
|
reviewed: 0,
|
||||||
@@ -111,7 +101,6 @@ export default function Review() {
|
|||||||
async function handleConfirm(deal) {
|
async function handleConfirm(deal) {
|
||||||
try {
|
try {
|
||||||
await updateDeal(deal.id, { reviewed: 1 });
|
await updateDeal(deal.id, { reviewed: 1 });
|
||||||
// Reload from page 1
|
|
||||||
loadReviewDeals(1, false);
|
loadReviewDeals(1, false);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
@@ -139,15 +128,6 @@ export default function Review() {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleExpand(dealId) {
|
|
||||||
setExpandedDeals((prev) => {
|
|
||||||
const next = new Set(prev);
|
|
||||||
if (next.has(dealId)) next.delete(dealId);
|
|
||||||
else next.add(dealId);
|
|
||||||
return next;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasMore = page < totalPages;
|
const hasMore = page < totalPages;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -260,18 +240,12 @@ export default function Review() {
|
|||||||
|
|
||||||
<div className="action-col">
|
<div className="action-col">
|
||||||
{deal.transactions && deal.transactions.length > 0 && (
|
{deal.transactions && deal.transactions.length > 0 && (
|
||||||
<button
|
<span
|
||||||
className="tag "
|
className="tag tag-transfer"
|
||||||
// onClick={() => toggleExpand(deal.id)}
|
style={{ fontSize: 11, padding: "3px 8px" }}
|
||||||
title="查看关联明细"
|
|
||||||
>
|
>
|
||||||
{/* {expandedDeals.has(deal.id) ? (*/}
|
|
||||||
{/* <ChevronDown size={12} />*/}
|
|
||||||
{/* ) : (*/}
|
|
||||||
{/* <ChevronRight size={12} />*/}
|
|
||||||
{/* )}{" "}*/}
|
|
||||||
{deal.transactions.length}笔
|
{deal.transactions.length}笔
|
||||||
</button>
|
</span>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary btn-sm"
|
className="btn btn-secondary btn-sm"
|
||||||
@@ -288,56 +262,6 @@ export default function Review() {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Expanded transactions detail */}
|
|
||||||
{expandedDeals.has(deal.id) && deal.transactions && (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: "100%",
|
|
||||||
marginTop: 8,
|
|
||||||
padding: "10px 0 0",
|
|
||||||
borderTop: "1px dashed var(--border)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{deal.transactions.map((tx, i) => (
|
|
||||||
<div
|
|
||||||
key={i}
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
gap: 12,
|
|
||||||
alignItems: "center",
|
|
||||||
padding: "6px 0",
|
|
||||||
fontSize: 12,
|
|
||||||
color: "var(--text-secondary)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className={`source-type-label source-${tx.source_type}`}
|
|
||||||
style={{ minWidth: 64, textAlign: "center" }}
|
|
||||||
>
|
|
||||||
{SOURCE_TYPE_MAP[tx.source_type] || tx.source_type}
|
|
||||||
</span>
|
|
||||||
<span style={{ flex: 1 }}>
|
|
||||||
{tx.description || "无描述"}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
fontWeight: 600,
|
|
||||||
color:
|
|
||||||
tx.direction === "income"
|
|
||||||
? "var(--success)"
|
|
||||||
: "var(--danger)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{formatAmount(tx.amount)}
|
|
||||||
</span>
|
|
||||||
<span style={{ fontSize: 11 }}>
|
|
||||||
{formatDate(tx.transaction_date)}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
@@ -422,6 +346,20 @@ export default function Review() {
|
|||||||
关联 {editingDeal.match_count} 笔原始交易
|
关联 {editingDeal.match_count} 笔原始交易
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{editingDeal.ai_description && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: 8,
|
||||||
|
padding: "6px 10px",
|
||||||
|
background: "#eef2ff",
|
||||||
|
borderRadius: 6,
|
||||||
|
fontSize: 12,
|
||||||
|
color: "var(--primary)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
🤖 AI:{editingDeal.ai_description}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Show associated transactions in modal */}
|
{/* Show associated transactions in modal */}
|
||||||
@@ -504,7 +442,7 @@ export default function Review() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>交易描述</label>
|
<label>描述</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-input"
|
className="form-input"
|
||||||
@@ -519,22 +457,6 @@ export default function Review() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-group">
|
|
||||||
<label>备注</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-input"
|
|
||||||
value={editingDeal.review_notes || ""}
|
|
||||||
onChange={(e) =>
|
|
||||||
setEditingDeal({
|
|
||||||
...editingDeal,
|
|
||||||
review_notes: e.target.value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
placeholder="人工备注(可选)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@@ -555,7 +477,6 @@ export default function Review() {
|
|||||||
handleUpdateDeal(editingDeal.id, {
|
handleUpdateDeal(editingDeal.id, {
|
||||||
category: editingDeal.category,
|
category: editingDeal.category,
|
||||||
ai_description: editingDeal.ai_description,
|
ai_description: editingDeal.ai_description,
|
||||||
review_notes: editingDeal.review_notes,
|
|
||||||
reviewed: 1,
|
reviewed: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ router.get("/", (req, res) => {
|
|||||||
// PUT /api/deals/:id — 编辑分类/确认
|
// PUT /api/deals/:id — 编辑分类/确认
|
||||||
router.put("/:id", (req, res) => {
|
router.put("/:id", (req, res) => {
|
||||||
const db = getDB();
|
const db = getDB();
|
||||||
const { category, ai_description, reviewed, review_notes, tags } = req.body;
|
const { category, ai_description, reviewed, tags } = req.body;
|
||||||
const sets = [];
|
const sets = [];
|
||||||
const params = [];
|
const params = [];
|
||||||
if (category !== undefined) {
|
if (category !== undefined) {
|
||||||
@@ -139,10 +139,7 @@ router.put("/:id", (req, res) => {
|
|||||||
params.push(reviewed);
|
params.push(reviewed);
|
||||||
if (reviewed) sets.push("reviewed_at = CURRENT_TIMESTAMP");
|
if (reviewed) sets.push("reviewed_at = CURRENT_TIMESTAMP");
|
||||||
}
|
}
|
||||||
if (review_notes !== undefined) {
|
|
||||||
sets.push("review_notes = ?");
|
|
||||||
params.push(review_notes);
|
|
||||||
}
|
|
||||||
if (tags !== undefined) {
|
if (tags !== undefined) {
|
||||||
sets.push("tags = ?");
|
sets.push("tags = ?");
|
||||||
params.push(JSON.stringify(tags));
|
params.push(JSON.stringify(tags));
|
||||||
|
|||||||
Reference in New Issue
Block a user