setUserFilter('pending_business')} style={{ cursor: 'pointer', border: userFilter === 'pending_business' ? '2px solid var(--orange)' : 'none' }}>
business
{stats.pending_business}
Pending Business
diff --git a/frontend/src/pages/AdminUserDetail.jsx b/frontend/src/pages/AdminUserDetail.jsx
index ce122cb..54fb9b1 100644
--- a/frontend/src/pages/AdminUserDetail.jsx
+++ b/frontend/src/pages/AdminUserDetail.jsx
@@ -14,6 +14,7 @@ export default function AdminUserDetail() {
const [userDetail, setUserDetail] = useState(null);
const [documents, setDocuments] = useState([]);
+ const [showAiSummary, setShowAiSummary] = useState({});
const [activeTab, setActiveTab] = useState('personal');
const [taxYear, setTaxYear] = useState("");
const [loading, setLoading] = useState(true);
@@ -23,6 +24,9 @@ export default function AdminUserDetail() {
const [personalTimeline, setPersonalTimeline] = useState(0);
const [businessTimeline, setBusinessTimeline] = useState(0);
+ // Reject comment panel: { docId, type, note }
+ const [rejectPanel, setRejectPanel] = useState(null);
+
// Export Excel Function
const exportToExcel = async () => {
try {
@@ -33,7 +37,7 @@ export default function AdminUserDetail() {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
- a.download = `user_${userId}_documents.xlsx`;
+ a.download = `user_${userId}_excel_summaries.zip`;
document.body.appendChild(a);
a.click();
a.remove();
@@ -165,26 +169,31 @@ export default function AdminUserDetail() {
}
};
- const handleDocApprove = async (docId, type, isApproved) => {
+ const handleDocApprove = async (docId, type, isApproved, note = '') => {
try {
const status = isApproved ? 'approved' : 'rejected';
const ep = type === "personal" ? `/api/upload/personal-documents/${docId}/review-status` : `/api/upload/business-documents/${docId}/review-status`;
const res = await authFetch(ep, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ status, note: "" })
+ body: JSON.stringify({ status, note })
});
if (res.ok) {
+ setRejectPanel(null);
fetchUserDetails(); // reload docs
} else {
showToast("Failed to save review status", "error");
}
} catch (err) { console.error(err);
- console.error("Approval error", err);
showToast("Approval error", "error");
}
};
+ const openRejectPanel = (docId, type) => {
+ setRejectPanel({ docId, type, note: '' });
+ };
+
+
const deleteAdminDoc = async (docId) => {
if (!window.confirm("Delete this admin document?")) return;
try {
@@ -309,13 +318,38 @@ export default function AdminUserDetail() {
};
if (loading && !userDetail) {
- return
;
+ return
;
}
if (!userDetail) {
- return
;
+ return
;
}
+ const exportAllToZip = async () => {
+ try {
+ showToast("Preparing ZIP export... This may take a moment.", "info");
+ const url = taxYear ? `/api/upload/admin/users/${userId}/export-zip?tax_year=${taxYear}` : `/api/upload/admin/users/${userId}/export-zip`;
+ const res = await authFetch(url);
+ if (res.ok) {
+ const blob = await res.blob();
+ const downloadUrl = window.URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = downloadUrl;
+ a.download = `user_${userId}_documents.zip`;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ window.URL.revokeObjectURL(downloadUrl);
+ showToast("ZIP export ready!", "success");
+ } else {
+ showToast("Failed to export ZIP file", "error");
+ }
+ } catch (err) {
+ console.error(err);
+ showToast("Error exporting ZIP file", "error");
+ }
+ };
+
const currentYear = new Date().getFullYear();
const yearOptions = [currentYear - 1, currentYear, currentYear + 1];
@@ -324,7 +358,12 @@ export default function AdminUserDetail() {
const returnDocs = documents.filter(d => d.type === "admin");
return (
-
+
+
+
{/* User Info Bar */}
@@ -389,6 +428,7 @@ export default function AdminUserDetail() {
{yearOptions.map(y => )}
+
@@ -424,19 +464,87 @@ export default function AdminUserDetail() {
{doc.notes &&
β {doc.notes}
}
{doc.review_status && (
-
+
{doc.review_status.toUpperCase()}
+ {doc.review_status === 'rejected' && doc.review_note && (
+ "{doc.review_note}"
+ )}
)}
-
+
+
+
+ {/* Inline Reject Comment Panel */}
+ {rejectPanel?.docId === doc.id && rejectPanel?.type === doc.type && (
+
+ )}
+
+ {showAiSummary[doc.id] && (
+ <>
{doc.extracted_data && Object.keys(doc.extracted_data).length > 0 ? (
) : null}
+ >
+ )}