feat: major platform upgrade — AI extraction pipeline, responsive UI, admin chatbot enhancements
CRITICAL FIXES - Fix blank pages: useCallback declared after useEffect in all 5 pages - Fix showToast undefined everywhere (ToastContext exported addToast not showToast) - Fix admin doc upload always 422 (missing doc_key + doc_label form fields) - Fix audit log wrong field names (log.details -> log.detail, remove user_agent) - Fix SPA catch-all missing in main.py (direct URL access was 404) - Fix chatbot using broken nvidia free model -> llama-3.3-70b AI EXTRACTION PIPELINE - 3-stage pipeline: Stage1 native text (free) -> Stage2 Tesseract OCR (free CPU) -> Stage3 Qwen vision (paid) - Tesseract installed with eng+hin bilingual support, psm6, 2.5x DPI - Scanned PDF fallback via PyMuPDF page render - Blank template fallback: returns form_type/purpose/tax_year instead of empty - Improved prompt: extracts actual document field names, no predefined terms - Auto-poll UI: shows Processing spinner when extraction is running - backfill_extraction.py: re-process all docs, fixed empty-dict-as-None bug ADMIN DASHBOARD - Pending docs split into Pending Personal + Pending Business stat cards - User cards show typed badges: N personal / N business instead of generic N pending - Backend returns pending_personal, pending_business, pending_docs per user ADMIN USER DETAIL - Doc count chips in user info bar: personal / business / returns / total - Doc name bold 15px, date with calendar icon + TY chip, status as colored badges - Responsive layout: doc-review-layout CSS classes replace inline flex styles - Filing Timeline sidebar stacks above doc list on mobile - AI Summary: bold labels and values, blank template shows metadata CHATBOT ENHANCEMENTS - Ask anything free-text input on menu screen (both admin and user chatbots) - Admin: live context with latest uploads by date, new users today - Admin: per-user activity lookup by name/email (docs + audit log) - New endpoint: /api/chatbot/admin-user-context - ExpandableSummaryBlock + ExpandableValue: bold navy field labels and values RESPONSIVENESS - components.css: 480px/640px/768px breakpoints for all pages - Admin table, stat cards, tabs, toasts, FAB all properly responsive - Auth shell stacks on mobile correctly
This commit is contained in:
@@ -479,7 +479,7 @@ def list_users_for_admin(
|
||||
"""
|
||||
from sqlalchemy import func as sqlfunc
|
||||
|
||||
def _pending_count(uid: int) -> int:
|
||||
def _pending_count(uid: int) -> dict:
|
||||
p = db.query(sqlfunc.count(PersonalDocument.id)).filter(
|
||||
PersonalDocument.user_id == uid,
|
||||
PersonalDocument.review_status == "pending",
|
||||
@@ -490,7 +490,7 @@ def list_users_for_admin(
|
||||
BusinessDocument.review_status == "pending",
|
||||
BusinessDocument.deleted_at == None,
|
||||
).scalar() or 0
|
||||
return p + b
|
||||
return {"pending_personal": p, "pending_business": b, "pending_docs": p + b}
|
||||
|
||||
if current_user.role == UserRole.super_admin:
|
||||
q = db.query(UserModel)
|
||||
@@ -503,12 +503,12 @@ def list_users_for_admin(
|
||||
return {
|
||||
"users": [
|
||||
{
|
||||
"id": u.id,
|
||||
"name": u.name,
|
||||
"email": u.email,
|
||||
"phone": u.phone,
|
||||
"role": u.role.value if hasattr(u.role, "value") else str(u.role),
|
||||
"pending_docs": _pending_count(u.id),
|
||||
"id": u.id,
|
||||
"name": u.name,
|
||||
"email": u.email,
|
||||
"phone": u.phone,
|
||||
"role": u.role.value if hasattr(u.role, "value") else str(u.role),
|
||||
**_pending_count(u.id), # inlines pending_personal, pending_business, pending_docs (total)
|
||||
}
|
||||
for u in users
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user