diff --git a/src/App.tsx b/src/App.tsx index 284dd06..e766b11 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -import { Database, RefreshCw, RefreshCcw } from 'lucide-react'; +import { Database, RefreshCw, RefreshCcw, Menu, Sparkles } from 'lucide-react'; import { API_BASE } from './services/api'; import type { AdminTabType } from './types'; @@ -47,6 +47,7 @@ export default function App() { const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(() => { return localStorage.getItem('admin_sidebar_collapsed') === 'true'; }); + const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); // Database & Backups State const [dbInfo, setDbInfo] = useState(null); @@ -918,7 +919,34 @@ export default function App() { return (
- {/* 1. Collapsible Sidebar */} + {/* Mobile Top Header Bar (Only visible on screens < md) */} +
+ + +
+
+ +
+
+

ACUPEDIA

+

ADMIN CONSOLE

+
+
+ + {/* Current Tab Indicator Badge on Mobile */} +
+ {adminSubTab === 'users_subscriptions' ? 'Subscriptions' : adminSubTab.replace('_', ' ')} +
+
+ + {/* 1. Collapsible & Responsive Sidebar */} setIsMobileMenuOpen(false)} /> {/* 2. Main Administrative Workspace */} @@ -974,7 +1004,7 @@ export default function App() { {adminSubTab === 'payments' && 'View Razorpay transactions, currencies, invoice details, and captured amounts.'} {adminSubTab === 'admins' && 'Assign administrator credentials and RBAC privilege levels.'} {adminSubTab === 'database' && 'Export PostgreSQL dumps and verify database connectivity.'} - {adminSubTab === 'reports' && 'Download accounting CSVs, tax summaries, and financial reports.'} + {adminSubTab === 'reports' && 'Download revenue ledgers, customer records, and financial reports.'}

diff --git a/src/components/coupons/CouponModal.tsx b/src/components/coupons/CouponModal.tsx index dba7891..e5178f8 100644 --- a/src/components/coupons/CouponModal.tsx +++ b/src/components/coupons/CouponModal.tsx @@ -74,7 +74,7 @@ export const CouponModal: React.FC = ({ Block 1: Promo Code & Discount Value -
+
= ({
-
+
= ({ Block 4: Conditions & Usage Limits
-
+
= ({ ))}
-
+
= ({ @@ -146,7 +146,7 @@ export const CouponsTab: React.FC = ({ ) : (
- +
diff --git a/src/components/database/DatabaseBackupTab.tsx b/src/components/database/DatabaseBackupTab.tsx index 75b2139..7231c3e 100644 --- a/src/components/database/DatabaseBackupTab.tsx +++ b/src/components/database/DatabaseBackupTab.tsx @@ -106,16 +106,16 @@ export const DatabaseBackupTab: React.FC = ({ Downloads a complete SQL dump of all database schemas, including clinical data, user profiles, authentication records, subscriptions, transactions, and coupons.

-
-
+
+
Format: Compressed .sql.gz (gzip -9)
-
+
Estimated Download Size: ~1.4 MB
-
+
Relational Integrity: ACID Consistent (pg_dump)
@@ -154,16 +154,16 @@ export const DatabaseBackupTab: React.FC = ({ Exports strictly the acu_content schema. Includes acupuncture points, clinical modules, questions bank, protocols, and taxonomy data without user accounts or payment data.

-
-
+
+
Target Schema: acu_content
-
+
Target Entities: Modules, Points, Channels, Quizzes
-
+
Use Case: Content Staging & Seed Distribution
diff --git a/src/components/database/ReportsExportTab.tsx b/src/components/database/ReportsExportTab.tsx index d7c3a99..a39cf61 100644 --- a/src/components/database/ReportsExportTab.tsx +++ b/src/components/database/ReportsExportTab.tsx @@ -48,7 +48,7 @@ export const ReportsExportTab: React.FC = ({ Reports & Financial Export Hub

- Generate and download audit-compliant CSV spreadsheets for registered customers, Razorpay payment transactions with GST tax splits (CGST 9% / SGST 9%), active subscriber entitlements, and promotional coupon redemptions. + Generate and download audit-compliant CSV spreadsheets for registered customers, Razorpay payment transactions and sales revenue, active subscriber entitlements, and promotional coupon redemptions.

@@ -133,12 +133,12 @@ export const ReportsExportTab: React.FC = ({ Export complete customer database with contact details, country, active subscription counts, active plans, total order counts, and cumulative lifetime spend.

-
-
+
+
Included Columns: User ID, Email, Name, Phone, Role, Spend
-
+
Target Audience: CRM & Growth Audits
@@ -165,7 +165,7 @@ export const ReportsExportTab: React.FC = ({
- {/* Report 2: Financial & GST Tax Ledger */} + {/* Report 2: Financial & Revenue Ledger */}
@@ -177,19 +177,19 @@ export const ReportsExportTab: React.FC = ({
-

Payments & GST Tax Ledger

+

Payments & Revenue Ledger

- Accounting & taxation ledger containing Razorpay Payment IDs, invoice numbers, base plan fees, coupon discounts, taxable subtotal, CGST (9%), SGST (9%), and net total paid. + Accounting & transaction ledger containing Razorpay Payment IDs, invoice numbers, base plan fees, coupon discounts, order currency, and total amounts paid.

-
-
- Tax Compliance: - CGST (9%) + SGST (9%) Breakdown +
+
+ Financial Scope: + Collected Revenue & Order Totals
-
+
Primary Use: - Monthly GST Filing & Bookkeeping + Financial Reconciliation & Revenue Auditing
@@ -207,7 +207,7 @@ export const ReportsExportTab: React.FC = ({ ) : ( <> - Export Tax & Revenue Ledger (.csv) + Export Payments & Revenue Ledger (.csv) )} @@ -231,12 +231,12 @@ export const ReportsExportTab: React.FC = ({ Export clinical plan access records, customer identities, subscription status, billing cycle, auto-renewal flag, activation dates, expiration dates, and remaining days.

-
-
+
+
Metrics Included: Remaining Days, Expiration, Plan Code
-
+
Primary Use: Churn & Expiration Tracking
@@ -280,12 +280,12 @@ export const ReportsExportTab: React.FC = ({ Track coupon performance and redemptions across orders, including discount rates, caps, customer emails, associated invoices, and total discount value granted.

-
-
+
+
Campaign Metrics: Code, Category, Discount INR, User
-
+
Primary Use: Marketing & Partner ROI
diff --git a/src/components/layout/AdminSidebar.tsx b/src/components/layout/AdminSidebar.tsx index 90918f5..475eff6 100644 --- a/src/components/layout/AdminSidebar.tsx +++ b/src/components/layout/AdminSidebar.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Sparkles, ChevronLeft, ChevronRight, LogOut, List, BookOpen, Tag, Ticket, Users, CheckCircle, - Receipt, Shield, Database, FileText + Receipt, Shield, Database, FileText, X } from 'lucide-react'; import type { LoggedInUser, AdminTabType } from '../../types'; @@ -29,6 +29,8 @@ interface AdminSidebarProps { isCollapsed: boolean; onToggleCollapse: () => void; onLogout: () => void; + isMobileOpen?: boolean; + onCloseMobile?: () => void; } export const AdminSidebar: React.FC = ({ @@ -39,7 +41,26 @@ export const AdminSidebar: React.FC = ({ isCollapsed, onToggleCollapse, onLogout, + isMobileOpen = false, + onCloseMobile, }) => { + React.useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape' && isMobileOpen && onCloseMobile) { + onCloseMobile(); + } + }; + window.addEventListener('keydown', handleKeyDown); + return () => window.removeEventListener('keydown', handleKeyDown); + }, [isMobileOpen, onCloseMobile]); + + const handleTabClick = (key: AdminTabType) => { + onSelectTab(key); + if (onCloseMobile) { + onCloseMobile(); + } + }; + const tabs: TabItem[] = [ { key: 'overview', label: 'Overview & Logs', icon: }, { key: 'modules', label: 'Modules', count: counts.modules, icon: }, @@ -53,124 +74,156 @@ export const AdminSidebar: React.FC = ({ { key: 'reports', label: 'Reports & Exports', icon: }, ]; + const showExpandedContent = !isCollapsed || isMobileOpen; + return ( - + )} +
+ + ); }; diff --git a/src/components/modules/ModulesTab.tsx b/src/components/modules/ModulesTab.tsx index 25680a5..6312b8b 100644 --- a/src/components/modules/ModulesTab.tsx +++ b/src/components/modules/ModulesTab.tsx @@ -156,7 +156,7 @@ export const ModulesTab: React.FC = ({ ) : (
-
Coupon Code
+
diff --git a/src/components/payments/PaymentsTab.tsx b/src/components/payments/PaymentsTab.tsx index 9246042..b05fbd7 100644 --- a/src/components/payments/PaymentsTab.tsx +++ b/src/components/payments/PaymentsTab.tsx @@ -146,7 +146,7 @@ export const PaymentsTab: React.FC = ({ ) : (
-
Module Name & Details
+
diff --git a/src/components/plans/PlansTab.tsx b/src/components/plans/PlansTab.tsx index ae77620..283a55f 100644 --- a/src/components/plans/PlansTab.tsx +++ b/src/components/plans/PlansTab.tsx @@ -133,7 +133,7 @@ export const PlansTab: React.FC = ({ ) : (
-
Payment ID
+
diff --git a/src/components/subscriptions/SubscriptionsTab.tsx b/src/components/subscriptions/SubscriptionsTab.tsx index 22c29f8..6272691 100644 --- a/src/components/subscriptions/SubscriptionsTab.tsx +++ b/src/components/subscriptions/SubscriptionsTab.tsx @@ -96,7 +96,7 @@ export const SubscriptionsTab: React.FC = ({ {/* Sort & Count Bar */} -
+
Plan Details
+
diff --git a/src/components/sync/SyncOverview.tsx b/src/components/sync/SyncOverview.tsx index cfd94ac..5436c89 100644 --- a/src/components/sync/SyncOverview.tsx +++ b/src/components/sync/SyncOverview.tsx @@ -117,15 +117,15 @@ export const SyncTopCards: React.FC<{ )} - {/* Compliance Box */} + {/* Compliance & Transaction Processing Box */}

- Tax Compliance + Gateway & Transaction Processing

-
-

✓ CGST: 9% split

-

✓ SGST: 9% split

-

✓ ISO compliance generated automatically

+
+

✓ All-inclusive customer pricing (no tax markup)

+

✓ Merchant gateway fees handled directly via Razorpay

+

✓ Automated invoice & payment receipt generation

diff --git a/src/components/users/CustomerDrawer.tsx b/src/components/users/CustomerDrawer.tsx index 55788ce..d610ffd 100644 --- a/src/components/users/CustomerDrawer.tsx +++ b/src/components/users/CustomerDrawer.tsx @@ -35,19 +35,19 @@ export const CustomerDrawer: React.FC = ({
{/* Drawer Top Bar */} -
-
-
+
+
+
{customerData?.display_name ? customerData.display_name[0].toUpperCase() : 'U'}
-
-
-

+
+
+

{customerData?.display_name || 'Customer Account'}

{customerData && ( = ({ )}
-

{customerData?.email || 'Loading...'}

+

{customerData?.email || 'Loading...'}

{/* Drawer Body */} -
+
{loading ? (
@@ -80,10 +81,10 @@ export const CustomerDrawer: React.FC = ({ ) : customerData ? ( <> {/* Account Status Control */} -
-
+
+
- + Account Access Control

@@ -97,7 +98,7 @@ export const CustomerDrawer: React.FC = ({ type="button" onClick={onToggleStatus} disabled={statusToggling} - className={`px-3 py-1.5 rounded-xl text-xs font-black transition-all flex items-center gap-1.5 cursor-pointer shadow-xs disabled:opacity-50 ${ + className={`self-start sm:self-auto shrink-0 px-3.5 py-1.5 rounded-xl text-xs font-black transition-all flex items-center gap-1.5 cursor-pointer shadow-xs disabled:opacity-50 ${ customerData.is_active ? 'bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200' : 'bg-emerald-600 hover:bg-emerald-500 text-white shadow-emerald-600/20' @@ -114,7 +115,7 @@ export const CustomerDrawer: React.FC = ({

{/* Drawer Sub-Tabs */} -
+
{[ { id: 'overview' as const, label: 'Overview' }, { @@ -130,7 +131,7 @@ export const CustomerDrawer: React.FC = ({ key={tab.id} type="button" onClick={() => onTabChange(tab.id)} - className={`px-3 py-2 text-xs font-bold rounded-xl transition-all cursor-pointer ${ + className={`px-3 py-2 text-xs font-bold rounded-xl transition-all cursor-pointer shrink-0 whitespace-nowrap ${ activeTab === tab.id ? 'bg-indigo-600 text-white shadow-xs' : 'text-slate-500 hover:text-slate-800 hover:bg-slate-100' @@ -145,9 +146,9 @@ export const CustomerDrawer: React.FC = ({ {activeTab === 'overview' && (
-
- Total Spent -

+

+ Total Spent +

{customerData.total_spent_formatted || formatCurrency( customerData.total_spent ?? customerData.total_spent_inr ?? 0, @@ -155,9 +156,9 @@ export const CustomerDrawer: React.FC = ({ )}

-
- Total Orders -

{customerData.total_orders || 0}

+
+ Total Orders +

{customerData.total_orders || 0}

@@ -165,35 +166,35 @@ export const CustomerDrawer: React.FC = ({

Contact & Account Information

-
-
+
+
Email Address - {customerData.email} + {customerData.email}
-
+
Phone Number - {customerData.phone_number || 'Not provided'} + {customerData.phone_number || 'Not provided'}
-
+
Country {customerData.country || 'India'}
-
+
Assigned Roles {customerData.roles?.join(', ') || 'user'}
-
+
Member Since {customerData.created_at ? customerData.created_at.split('T')[0] : 'N/A'}
{customerData.external_ref && ( -
+
Gateway Ref - {customerData.external_ref} + {customerData.external_ref}
)}
@@ -281,25 +282,25 @@ export const CustomerDrawer: React.FC = ({ return (
-
-
- {invNumber} +
+
+ {invNumber} {tx.invoice?.invoice_number && ( - + Invoice )}
-

+

{tx.created_at?.split('T')[0] || '—'} {tx.gateway_transaction_id && ` • ${tx.gateway_transaction_id}`}

-
-
+
+

{formatCurrency(amount, curr)}

Subscriber