feat: Account Hub admin page with smart search and account management (ENG-391)#26
feat: Account Hub admin page with smart search and account management (ENG-391)#26forge0x wants to merge 18 commits into
Conversation
UAT Fixes (commit 638da4a)✅ Shortcut order — Account Hub shortcut now sits beside Alert Users and Account Management at the top (moved before Tools card in workspace content) ✅ Default user list — On page load, recent upgrade requests now appear in the left panel. Searching filters this local list in real-time. Clicking a result fetches full account details via the API. ✅ Network error resilience — The smart search backend now catches To redeploy: cd /Users/forgemini/dev/frappe-flash-admin
git checkout feat/eng-391-account-hub
git pull
bench --site flashapp.me.localhost migrateThen visit |
brh28
left a comment
There was a problem hiding this comment.
Reviewing with Claude noticed some possible issues:
- approve_upgrade_request: Sends DocType name instead of Flash UID to the mutation; never sets local status to "Approved" │
- reject_upgrade_request: Writes "REJECTED" (uppercase) which isn't a valid Select option; should be "Rejected"
|
|
||
| local_result = _search_local_doctype(query) | ||
| if local_result: | ||
| return local_result |
There was a problem hiding this comment.
I'm not a fan of returning the AccountUpgradeRequest when flash api fails. it could be outdated and therefore misleading.
There was a problem hiding this comment.
Removed the local Account Upgrade Request fallback from Account Hub search. search_account_smart now returns Flash GraphQL account data only; API misses return 404 and Flash API failures return 503 instead of synthesizing stale local data as an account.
|
Addressed the stale fallback concern in Change:
Verification:
|
Task 2 — graphql_client.py: - Add ACCOUNT_DETAIL_FRAGMENT reusable fragment with all account fields (id, uuid, username, npub, level, status, title, erpParty, owner, coordinates, wallets, merchants, createdAt) - Update ACCOUNT_BY_PHONE_QUERY to use the fragment - Add ACCOUNT_BY_USERNAME_QUERY (by username) - Add ACCOUNT_BY_EMAIL_QUERY (by email via accountDetailsByUserEmail) - Add ACCOUNT_BY_ID_QUERY (by account ID via accountDetailsByAccountId) - Add UPDATE_STATUS_MUTATION (accountUpdateStatus) - Add USER_UPDATE_PHONE_MUTATION (userUpdatePhone) - Add MERCHANT_MAP_VALIDATE_MUTATION (merchantMapValidate) - Add MERCHANT_MAP_DELETE_MUTATION (merchantMapDelete) - Add client methods: get_account_by_username, get_account_by_email, get_account_by_id, update_account_status, update_user_phone, validate_merchant, delete_merchant Task 3 — admin_api.py: - Add search_account_smart: auto-detects phone/email/username/ID input and routes to the correct GraphQL query with fallback - Add update_account_status_api: wrapper for account status mutation - Add update_user_phone_api: wrapper for user phone update mutation - Add validate_merchant_api: wrapper for merchant validation mutation - Add delete_merchant_api: wrapper for merchant deletion mutation - Add get_upgrade_requests_by_account: queries local Account Upgrade Request doctype by username All endpoints follow existing patterns: @frappe.whitelist(), @handle_api_errors, and GraphQLClient usage.
- New Account Hub page at /app/account-hub - Split panel layout with search (left) and detail view (right) - 5 tabs: Overview, Wallets, Documents, Merchant, Upgrade History - Smart search via search_account_smart API - Actions: Change Level, Lock/Activate Account, Update Phone - Merchant validate/delete actions - ID document viewer with pre-signed URL loading - Wallet display with USD/USDT balances in cents format - Upgrade history table from local DocType - Role guard for Accounts Manager - Consistent styling with existing Account Management page
1. Workspace: move Account Hub shortcut before Tools card so it appears beside Alert Users and Account Management at the top 2. Default user list: on page load, show recent upgrade requests in the left panel as clickable results. Search input filters this local list in real-time and also searches the Flash API 3. Network error resilience: backend search_account_smart now falls back to searching the local Account Upgrade Request DocType when the Flash API is unreachable or unconfigured. Also catches ValueError for missing config gracefully. 4. on_result_click: clicking a local upgrade request item triggers a full API search by username when available 5. show_search_error no longer clears previous results 6. show_search_result auto-selects the result item
- ACCOUNT_BY_EMAIL_QUERY: use 'accountDetailsByEmail' (not accountDetailsByUserEmail) to match the exported field name in Flash schema's queries.ts - get_account_by_email: update extract path to match - Merchant coordinates in fragment: nested under 'coordinates' object (lat/lng are sub-fields of Coordinates type, not top-level Merchant fields) - account_hub.js: update merchant latitude/longitude access to use m.coordinates sub-object
…ists on click
- Documents tab: View button now opens the Account Upgrade Request
DocType form directly (window.open to /app/account-upgrade-request/{name})
instead of calling the failing get_id_document_url API
- Result list: on_result_click now calls fetch_account_details() which
fetches full account data without replacing/re-rendering the result
list. The list stays intact so users can switch between accounts.
- Added fetch_account_details() helper that populates the detail panel
independently of the search results list
…details this.$.detailPanel and this.$.detailLoading were never defined in the page template, causing a silent TypeError when clicking a result item.
fetch_account_details now accepts a fallback object built from local DocType data. If the API returns 'not found' or a network error occurs, the local data is shown silently instead of an error dialog. This handles placeholder/seed records that only exist in Frappe but not on the Flash API.
- Removed frappe.response['http_status_code'] from @handle_api_errors
decorator — always returns 200 with {success: false, error: msg}
so the frontend callback fires instead of the error handler
- Removed 400/404 status codes from search_account_smart for same
reason
- Updated frontend error callback message to be more descriptive
- Cleaner error messages: 'Account not found...' and
'Flash API unreachable. Search limited to local data.'
instead of 'Network error. Please try again.'
Show the actual error message to the user and log the traceback so we can identify root causes.
Account Upgrade Request has phone_number and email columns, not phone and email_id. Fixed _search_local_doctype SQL queries, return mapping, and all frontend references to match the actual schema.
…requests New /app/admin-dashboard page: - 4 stat cards: pending, approved today, total approved, total requests - 3 quick action cards: Account Hub, Account Management, Alert Users - Recent upgrade requests table with clickable rows - Responsive grid layout, auto-dark mode compatible Backend: get_dashboard_stats endpoint for aggregated counts Workspace: Dashboard is now the first shortcut in the Admin Panel workspace Setup: syncs admin-dashboard page on after_migrate
- Added responsive breakpoints at 1024px, 768px, and 480px - Stat cards compact at each breakpoint (smaller icons, padding, font) - Tool cards switch to horizontal row layout on tablets (768px) - Table gets horizontal scroll wrapper on mobile - Added touch-friendly :active states for all clickable elements - Removed hover-only interactions that don't work on touch - Section spacing tightens on small screens
1c330bc to
afc5924
Compare
Summary
New Account Hub page at
/app/account-hubfor Flash support and admin staff to look up any customer account and perform management actions.Features
Files Changed
admin_panel/api/graphql_client.pyadmin_panel/api/admin_api.pyadmin_panel/admin_panel/page/account_hub/__init__.py,account_hub.json,account_hub.js(1664 lines)admin_panel/fixtures/workspace.jsonTo Deploy
Then navigate to
/app/account-hub.Closes ENG-391