Merge pull request 'feat(admin): improve mobile responsiveness and update ledger wording' (#30) from feat/responsive-admin-sidebar into main

Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-web-ui/pulls/30
Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
Amit Salunke 2026-11-03 05:13:30 +00:00
commit 660b7493e9
12 changed files with 280 additions and 196 deletions

View File

@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import axios from 'axios'; 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 { API_BASE } from './services/api';
import type { AdminTabType } from './types'; import type { AdminTabType } from './types';
@ -47,6 +47,7 @@ export default function App() {
const [isSidebarCollapsed, setIsSidebarCollapsed] = useState<boolean>(() => { const [isSidebarCollapsed, setIsSidebarCollapsed] = useState<boolean>(() => {
return localStorage.getItem('admin_sidebar_collapsed') === 'true'; return localStorage.getItem('admin_sidebar_collapsed') === 'true';
}); });
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState<boolean>(false);
// Database & Backups State // Database & Backups State
const [dbInfo, setDbInfo] = useState<any | null>(null); const [dbInfo, setDbInfo] = useState<any | null>(null);
@ -918,7 +919,34 @@ export default function App() {
return ( return (
<div className="min-h-screen bg-slate-50 flex flex-col md:flex-row text-slate-800 selection:bg-indigo-500 selection:text-white"> <div className="min-h-screen bg-slate-50 flex flex-col md:flex-row text-slate-800 selection:bg-indigo-500 selection:text-white">
{/* 1. Collapsible Sidebar */} {/* Mobile Top Header Bar (Only visible on screens < md) */}
<header className="md:hidden flex items-center justify-between px-4 py-3 bg-[#0A0A0E] text-white border-b border-slate-800 sticky top-0 z-30 shadow-md">
<button
type="button"
onClick={() => setIsMobileMenuOpen(true)}
className="p-2 -ml-2 rounded-xl text-slate-300 hover:text-white hover:bg-slate-800/80 transition-colors cursor-pointer border border-transparent hover:border-slate-700/60"
aria-label="Open navigation menu"
>
<Menu className="h-5 w-5" />
</button>
<div className="flex items-center gap-2">
<div className="h-7 w-7 rounded-lg bg-gradient-to-tr from-indigo-500 to-cyan-400 flex items-center justify-center shadow-xs">
<Sparkles className="h-3.5 w-3.5 text-white" />
</div>
<div>
<h1 className="text-xs font-black tracking-tight text-white leading-tight">ACUPEDIA</h1>
<p className="text-[7px] text-slate-400 font-bold tracking-widest uppercase leading-none">ADMIN CONSOLE</p>
</div>
</div>
{/* Current Tab Indicator Badge on Mobile */}
<div className="text-[11px] font-bold text-indigo-400 bg-indigo-950/80 border border-indigo-500/30 px-2.5 py-0.5 rounded-full capitalize max-w-[120px] truncate">
{adminSubTab === 'users_subscriptions' ? 'Subscriptions' : adminSubTab.replace('_', ' ')}
</div>
</header>
{/* 1. Collapsible & Responsive Sidebar */}
<AdminSidebar <AdminSidebar
loggedInUser={loggedInUser} loggedInUser={loggedInUser}
activeTab={adminSubTab} activeTab={adminSubTab}
@ -941,6 +969,8 @@ export default function App() {
}); });
}} }}
onLogout={handleLogout} onLogout={handleLogout}
isMobileOpen={isMobileMenuOpen}
onCloseMobile={() => setIsMobileMenuOpen(false)}
/> />
{/* 2. Main Administrative Workspace */} {/* 2. Main Administrative Workspace */}
@ -974,7 +1004,7 @@ export default function App() {
{adminSubTab === 'payments' && 'View Razorpay transactions, currencies, invoice details, and captured amounts.'} {adminSubTab === 'payments' && 'View Razorpay transactions, currencies, invoice details, and captured amounts.'}
{adminSubTab === 'admins' && 'Assign administrator credentials and RBAC privilege levels.'} {adminSubTab === 'admins' && 'Assign administrator credentials and RBAC privilege levels.'}
{adminSubTab === 'database' && 'Export PostgreSQL dumps and verify database connectivity.'} {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.'}
</p> </p>
</div> </div>

View File

@ -74,7 +74,7 @@ export const CouponModal: React.FC<CouponModalProps> = ({
<span className="text-xs font-bold text-slate-700">Block 1: Promo Code & Discount Value</span> <span className="text-xs font-bold text-slate-700">Block 1: Promo Code & Discount Value</span>
</div> </div>
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label className="block text-[11px] font-bold text-slate-600 mb-1">Coupon Code *</label> <label className="block text-[11px] font-bold text-slate-600 mb-1">Coupon Code *</label>
<input <input
@ -104,7 +104,7 @@ export const CouponModal: React.FC<CouponModalProps> = ({
</div> </div>
</div> </div>
<div className="grid grid-cols-3 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div> <div>
<label className="block text-[11px] font-bold text-slate-600 mb-1">Discount Type</label> <label className="block text-[11px] font-bold text-slate-600 mb-1">Discount Type</label>
<select <select
@ -164,7 +164,7 @@ export const CouponModal: React.FC<CouponModalProps> = ({
<span className="text-xs font-bold text-slate-700">Block 2: Schedule & Date Window</span> <span className="text-xs font-bold text-slate-700">Block 2: Schedule & Date Window</span>
</div> </div>
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label className="block text-[11px] font-bold text-slate-600 mb-1">Start Date</label> <label className="block text-[11px] font-bold text-slate-600 mb-1">Start Date</label>
<input <input
@ -279,7 +279,7 @@ export const CouponModal: React.FC<CouponModalProps> = ({
<span className="text-xs font-bold text-slate-700">Block 4: Conditions & Usage Limits</span> <span className="text-xs font-bold text-slate-700">Block 4: Conditions & Usage Limits</span>
</div> </div>
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div> <div>
<label className="block text-[11px] font-bold text-slate-600 mb-1">Min Spend (0=None)</label> <label className="block text-[11px] font-bold text-slate-600 mb-1">Min Spend (0=None)</label>
<input <input

View File

@ -115,7 +115,7 @@ export const CouponsTab: React.FC<CouponsTabProps> = ({
))} ))}
</div> </div>
<div className="flex items-center gap-3 w-full sm:w-auto"> <div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-2.5 sm:gap-3 w-full sm:w-auto">
<input <input
type="text" type="text"
placeholder="Search code or description..." placeholder="Search code or description..."
@ -129,7 +129,7 @@ export const CouponsTab: React.FC<CouponsTabProps> = ({
<button <button
type="button" type="button"
onClick={onOpenCreateCoupon} onClick={onOpenCreateCoupon}
className="inline-flex items-center gap-1.5 px-4 py-2 rounded-xl text-xs font-bold bg-indigo-600 hover:bg-indigo-500 text-white shadow-md shadow-indigo-600/20 transition-all cursor-pointer whitespace-nowrap" className="inline-flex items-center justify-center gap-1.5 px-4 py-2 rounded-xl text-xs font-bold bg-indigo-600 hover:bg-indigo-500 text-white shadow-md shadow-indigo-600/20 transition-all cursor-pointer whitespace-nowrap"
> >
<Plus className="h-3.5 w-3.5" /> Create Coupon <Plus className="h-3.5 w-3.5" /> Create Coupon
</button> </button>
@ -146,7 +146,7 @@ export const CouponsTab: React.FC<CouponsTabProps> = ({
) : ( ) : (
<div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white"> <div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-left text-xs"> <table className="w-full text-left text-xs min-w-[720px]">
<thead className="bg-slate-50 border-b border-slate-200 text-slate-500 uppercase tracking-wider text-[10px] font-extrabold"> <thead className="bg-slate-50 border-b border-slate-200 text-slate-500 uppercase tracking-wider text-[10px] font-extrabold">
<tr> <tr>
<th className="py-3 px-4">Coupon Code</th> <th className="py-3 px-4">Coupon Code</th>

View File

@ -106,16 +106,16 @@ export const DatabaseBackupTab: React.FC<DatabaseBackupTabProps> = ({
Downloads a complete SQL dump of all database schemas, including clinical data, user profiles, authentication records, subscriptions, transactions, and coupons. Downloads a complete SQL dump of all database schemas, including clinical data, user profiles, authentication records, subscriptions, transactions, and coupons.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Format:</span> <span className="text-slate-400 font-semibold">Format:</span>
<span className="font-mono font-bold text-slate-700">Compressed .sql.gz (gzip -9)</span> <span className="font-mono font-bold text-slate-700">Compressed .sql.gz (gzip -9)</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Estimated Download Size:</span> <span className="text-slate-400 font-semibold">Estimated Download Size:</span>
<span className="font-mono font-bold text-indigo-600">~1.4 MB</span> <span className="font-mono font-bold text-indigo-600">~1.4 MB</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Relational Integrity:</span> <span className="text-slate-400 font-semibold">Relational Integrity:</span>
<span className="font-bold text-emerald-600">ACID Consistent (pg_dump)</span> <span className="font-bold text-emerald-600">ACID Consistent (pg_dump)</span>
</div> </div>
@ -154,16 +154,16 @@ export const DatabaseBackupTab: React.FC<DatabaseBackupTabProps> = ({
Exports strictly the <code className="text-emerald-700 bg-emerald-50 px-1 py-0.5 rounded font-mono font-bold">acu_content</code> schema. Includes acupuncture points, clinical modules, questions bank, protocols, and taxonomy data without user accounts or payment data. Exports strictly the <code className="text-emerald-700 bg-emerald-50 px-1 py-0.5 rounded font-mono font-bold">acu_content</code> schema. Includes acupuncture points, clinical modules, questions bank, protocols, and taxonomy data without user accounts or payment data.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Target Schema:</span> <span className="text-slate-400 font-semibold">Target Schema:</span>
<span className="font-mono font-bold text-slate-700">acu_content</span> <span className="font-mono font-bold text-slate-700">acu_content</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Target Entities:</span> <span className="text-slate-400 font-semibold">Target Entities:</span>
<span className="font-bold text-slate-700">Modules, Points, Channels, Quizzes</span> <span className="font-bold text-slate-700">Modules, Points, Channels, Quizzes</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Use Case:</span> <span className="text-slate-400 font-semibold">Use Case:</span>
<span className="font-bold text-emerald-600">Content Staging & Seed Distribution</span> <span className="font-bold text-emerald-600">Content Staging & Seed Distribution</span>
</div> </div>

View File

@ -48,7 +48,7 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
Reports & Financial Export Hub Reports & Financial Export Hub
</h2> </h2>
<p className="text-xs text-slate-300 max-w-2xl font-medium leading-relaxed"> <p className="text-xs text-slate-300 max-w-2xl font-medium leading-relaxed">
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.
</p> </p>
</div> </div>
</div> </div>
@ -133,12 +133,12 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
Export complete customer database with contact details, country, active subscription counts, active plans, total order counts, and cumulative lifetime spend. Export complete customer database with contact details, country, active subscription counts, active plans, total order counts, and cumulative lifetime spend.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Included Columns:</span> <span className="text-slate-400 font-semibold">Included Columns:</span>
<span className="font-semibold text-slate-700">User ID, Email, Name, Phone, Role, Spend</span> <span className="font-semibold text-slate-700">User ID, Email, Name, Phone, Role, Spend</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Target Audience:</span> <span className="text-slate-400 font-semibold">Target Audience:</span>
<span className="font-semibold text-indigo-600">CRM & Growth Audits</span> <span className="font-semibold text-indigo-600">CRM & Growth Audits</span>
</div> </div>
@ -165,7 +165,7 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
</div> </div>
</div> </div>
{/* Report 2: Financial & GST Tax Ledger */} {/* Report 2: Financial & Revenue Ledger */}
<div className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm flex flex-col justify-between hover:border-emerald-300 transition-all space-y-4"> <div className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm flex flex-col justify-between hover:border-emerald-300 transition-all space-y-4">
<div className="space-y-3"> <div className="space-y-3">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
@ -177,19 +177,19 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
</span> </span>
</div> </div>
<div> <div>
<h3 className="text-base font-black text-slate-800">Payments & GST Tax Ledger</h3> <h3 className="text-base font-black text-slate-800">Payments & Revenue Ledger</h3>
<p className="text-xs text-slate-500 mt-1 font-medium leading-relaxed"> <p className="text-xs text-slate-500 mt-1 font-medium leading-relaxed">
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.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Tax Compliance:</span> <span className="text-slate-400 font-semibold">Financial Scope:</span>
<span className="font-semibold text-emerald-600">CGST (9%) + SGST (9%) Breakdown</span> <span className="font-semibold text-emerald-600">Collected Revenue & Order Totals</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Primary Use:</span> <span className="text-slate-400 font-semibold">Primary Use:</span>
<span className="font-semibold text-slate-700">Monthly GST Filing & Bookkeeping</span> <span className="font-semibold text-slate-700">Financial Reconciliation & Revenue Auditing</span>
</div> </div>
</div> </div>
</div> </div>
@ -207,7 +207,7 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
</> </>
) : ( ) : (
<> <>
<Download className="h-3.5 w-3.5" /> Export Tax & Revenue Ledger (.csv) <Download className="h-3.5 w-3.5" /> Export Payments & Revenue Ledger (.csv)
</> </>
)} )}
</button> </button>
@ -231,12 +231,12 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
Export clinical plan access records, customer identities, subscription status, billing cycle, auto-renewal flag, activation dates, expiration dates, and remaining days. Export clinical plan access records, customer identities, subscription status, billing cycle, auto-renewal flag, activation dates, expiration dates, and remaining days.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Metrics Included:</span> <span className="text-slate-400 font-semibold">Metrics Included:</span>
<span className="font-semibold text-slate-700">Remaining Days, Expiration, Plan Code</span> <span className="font-semibold text-slate-700">Remaining Days, Expiration, Plan Code</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Primary Use:</span> <span className="text-slate-400 font-semibold">Primary Use:</span>
<span className="font-semibold text-blue-600">Churn & Expiration Tracking</span> <span className="font-semibold text-blue-600">Churn & Expiration Tracking</span>
</div> </div>
@ -280,12 +280,12 @@ export const ReportsExportTab: React.FC<ReportsExportTabProps> = ({
Track coupon performance and redemptions across orders, including discount rates, caps, customer emails, associated invoices, and total discount value granted. Track coupon performance and redemptions across orders, including discount rates, caps, customer emails, associated invoices, and total discount value granted.
</p> </p>
</div> </div>
<div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1"> <div className="bg-slate-50 border border-slate-200/60 rounded-xl p-3 text-[11px] text-slate-600 space-y-1.5">
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Campaign Metrics:</span> <span className="text-slate-400 font-semibold">Campaign Metrics:</span>
<span className="font-semibold text-slate-700">Code, Category, Discount INR, User</span> <span className="font-semibold text-slate-700">Code, Category, Discount INR, User</span>
</div> </div>
<div className="flex justify-between"> <div className="flex flex-col sm:flex-row sm:justify-between gap-0.5 sm:gap-2">
<span className="text-slate-400 font-semibold">Primary Use:</span> <span className="text-slate-400 font-semibold">Primary Use:</span>
<span className="font-semibold text-purple-600">Marketing & Partner ROI</span> <span className="font-semibold text-purple-600">Marketing & Partner ROI</span>
</div> </div>

View File

@ -2,7 +2,7 @@ import React from 'react';
import { import {
Sparkles, ChevronLeft, ChevronRight, LogOut, Sparkles, ChevronLeft, ChevronRight, LogOut,
List, BookOpen, Tag, Ticket, Users, CheckCircle, List, BookOpen, Tag, Ticket, Users, CheckCircle,
Receipt, Shield, Database, FileText Receipt, Shield, Database, FileText, X
} from 'lucide-react'; } from 'lucide-react';
import type { LoggedInUser, AdminTabType } from '../../types'; import type { LoggedInUser, AdminTabType } from '../../types';
@ -29,6 +29,8 @@ interface AdminSidebarProps {
isCollapsed: boolean; isCollapsed: boolean;
onToggleCollapse: () => void; onToggleCollapse: () => void;
onLogout: () => void; onLogout: () => void;
isMobileOpen?: boolean;
onCloseMobile?: () => void;
} }
export const AdminSidebar: React.FC<AdminSidebarProps> = ({ export const AdminSidebar: React.FC<AdminSidebarProps> = ({
@ -39,7 +41,26 @@ export const AdminSidebar: React.FC<AdminSidebarProps> = ({
isCollapsed, isCollapsed,
onToggleCollapse, onToggleCollapse,
onLogout, 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[] = [ const tabs: TabItem[] = [
{ key: 'overview', label: 'Overview & Logs', icon: <List className="h-4 w-4 shrink-0" /> }, { key: 'overview', label: 'Overview & Logs', icon: <List className="h-4 w-4 shrink-0" /> },
{ key: 'modules', label: 'Modules', count: counts.modules, icon: <BookOpen className="h-4 w-4 shrink-0" /> }, { key: 'modules', label: 'Modules', count: counts.modules, icon: <BookOpen className="h-4 w-4 shrink-0" /> },
@ -53,124 +74,156 @@ export const AdminSidebar: React.FC<AdminSidebarProps> = ({
{ key: 'reports', label: 'Reports & Exports', icon: <FileText className="h-4 w-4 shrink-0" /> }, { key: 'reports', label: 'Reports & Exports', icon: <FileText className="h-4 w-4 shrink-0" /> },
]; ];
const showExpandedContent = !isCollapsed || isMobileOpen;
return ( return (
<aside <>
className={`bg-[#0A0A0E] border-b md:border-b-0 md:border-r border-slate-800/80 flex flex-col justify-between py-4 transition-all duration-300 ease-in-out flex-shrink-0 text-slate-300 shadow-2xl select-none relative z-30 ${ {/* Mobile Backdrop Overlay */}
isCollapsed ? 'w-full md:w-[68px] px-2' : 'w-full md:w-60 px-3' {isMobileOpen && (
}`} <div
> className="fixed inset-0 z-40 bg-slate-950/75 backdrop-blur-xs md:hidden"
<div className="space-y-4"> onClick={onCloseMobile}
{/* Brand & Collapse Header */} aria-hidden="true"
<div className={`flex items-center ${isCollapsed ? 'justify-center' : 'justify-between'} gap-2 px-1`}> />
<div className="flex items-center gap-2.5 min-w-0"> )}
<div className="h-8 w-8 rounded-xl bg-gradient-to-tr from-indigo-500 to-cyan-400 flex items-center justify-center shadow-md shadow-indigo-500/20 shrink-0">
<Sparkles className="h-4 w-4 text-white" /> <aside
</div> className={`bg-[#0A0A0E] border-r border-slate-800/80 flex flex-col justify-between py-4 text-slate-300 shadow-2xl select-none z-50
{!isCollapsed && ( fixed md:sticky top-0 inset-y-0 left-0 md:h-screen overflow-y-auto transition-transform duration-300 ease-in-out flex-shrink-0
<div className="min-w-0"> ${isMobileOpen ? 'translate-x-0' : '-translate-x-full md:translate-x-0'}
<h1 className="text-sm font-black tracking-tight text-white truncate"> ${isCollapsed ? 'md:w-[68px] md:px-2' : 'md:w-60 md:px-3'}
ACUPEDIA w-72 max-w-[85vw] px-3
</h1> `}
<p className="text-[8px] text-slate-400 font-bold tracking-widest uppercase">ADMIN CONSOLE</p> >
<div className="space-y-4">
{/* Brand & Collapse Header */}
<div className={`flex items-center ${!showExpandedContent ? 'justify-center' : 'justify-between'} gap-2 px-1`}>
<div className="flex items-center gap-2.5 min-w-0">
<div className="h-8 w-8 rounded-xl bg-gradient-to-tr from-indigo-500 to-cyan-400 flex items-center justify-center shadow-md shadow-indigo-500/20 shrink-0">
<Sparkles className="h-4 w-4 text-white" />
</div> </div>
)} {showExpandedContent && (
<div className="min-w-0">
<h1 className="text-sm font-black tracking-tight text-white truncate">
ACUPEDIA
</h1>
<p className="text-[8px] text-slate-400 font-bold tracking-widest uppercase">ADMIN CONSOLE</p>
</div>
)}
</div>
<div className="flex items-center gap-1">
{/* Close Button on Mobile Drawer */}
<button
type="button"
onClick={onCloseMobile}
className="flex md:hidden h-7 w-7 rounded-lg bg-slate-800/80 hover:bg-slate-700 text-slate-400 hover:text-white items-center justify-center transition-colors cursor-pointer border border-slate-700/60"
aria-label="Close sidebar"
>
<X className="h-4 w-4" />
</button>
{/* Collapse Button on Desktop */}
<button
type="button"
onClick={onToggleCollapse}
className="hidden md:flex h-7 w-7 rounded-lg bg-slate-800/80 hover:bg-slate-700 text-slate-400 hover:text-white items-center justify-center transition-colors cursor-pointer border border-slate-700/60"
title={isCollapsed ? 'Expand sidebar' : 'Collapse sidebar'}
>
{isCollapsed ? <ChevronRight className="h-3.5 w-3.5" /> : <ChevronLeft className="h-3.5 w-3.5" />}
</button>
</div>
</div> </div>
<button {/* Navigation Tabs */}
type="button" <nav className="space-y-1">
onClick={onToggleCollapse} {tabs.map((tab) => {
className="hidden md:flex h-7 w-7 rounded-lg bg-slate-800/80 hover:bg-slate-700 text-slate-400 hover:text-white items-center justify-center transition-colors cursor-pointer border border-slate-700/60" const isActive = activeTab === tab.key;
title={isCollapsed ? 'Expand sidebar' : 'Collapse sidebar'} return (
> <button
{isCollapsed ? <ChevronRight className="h-3.5 w-3.5" /> : <ChevronLeft className="h-3.5 w-3.5" />} key={tab.key}
</button> type="button"
onClick={() => handleTabClick(tab.key)}
className={`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-xs font-bold transition-all cursor-pointer relative group ${
isActive
? 'bg-indigo-600 text-white shadow-lg shadow-indigo-600/30'
: 'text-slate-400 hover:text-slate-100 hover:bg-slate-800/60'
} ${!showExpandedContent ? 'justify-center px-0' : ''}`}
title={!showExpandedContent ? `${tab.label} ${tab.count !== undefined ? `(${tab.count})` : ''}` : undefined}
>
{tab.icon}
{showExpandedContent && (
<>
<span className="truncate flex-1 text-left">{tab.label}</span>
{tab.count !== undefined && (
<span
className={`text-[10px] font-black px-1.5 py-0.5 rounded-full ${
isActive
? 'bg-white/20 text-white'
: 'bg-slate-800 text-slate-400 group-hover:text-slate-200'
}`}
>
{tab.count}
</span>
)}
</>
)}
{/* Collapsed active dot */}
{!showExpandedContent && isActive && (
<span className="absolute right-1.5 top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-white rounded-full shadow-xs" />
)}
</button>
);
})}
</nav>
</div> </div>
{/* Navigation Tabs */} {/* User Footer */}
<nav className="space-y-1"> <div className="pt-3 border-t border-slate-800/80 mt-4">
{tabs.map((tab) => { {showExpandedContent ? (
const isActive = activeTab === tab.key; <div className="space-y-2.5 px-1">
return ( <div className="flex items-center gap-2.5">
<div className="h-8 w-8 rounded-xl bg-gradient-to-tr from-indigo-950 to-indigo-900 border border-indigo-500/30 flex items-center justify-center text-indigo-400 font-black text-xs shrink-0 shadow-inner">
{loggedInUser?.display_name ? loggedInUser.display_name[0].toUpperCase() : 'A'}
</div>
<div className="min-w-0 flex-1">
<p className="text-xs font-bold text-white truncate">
{loggedInUser?.display_name || 'Admin'}
</p>
<p className="text-[10px] text-slate-400 truncate">{loggedInUser?.email}</p>
</div>
</div>
<button <button
key={tab.key}
type="button" type="button"
onClick={() => onSelectTab(tab.key)} onClick={() => {
className={`w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-xs font-bold transition-all cursor-pointer relative group ${ if (onCloseMobile) onCloseMobile();
isActive onLogout();
? 'bg-indigo-600 text-white shadow-lg shadow-indigo-600/30' }}
: 'text-slate-400 hover:text-slate-100 hover:bg-slate-800/60' className="w-full flex items-center justify-center gap-2 py-2 rounded-xl text-xs font-bold bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white transition-colors cursor-pointer border border-slate-700/60"
} ${isCollapsed ? 'justify-center px-0' : ''}`}
title={isCollapsed ? `${tab.label} ${tab.count !== undefined ? `(${tab.count})` : ''}` : undefined}
> >
{tab.icon} <LogOut className="h-3.5 w-3.5" /> Log Out
{!isCollapsed && (
<>
<span className="truncate flex-1 text-left">{tab.label}</span>
{tab.count !== undefined && (
<span
className={`text-[10px] font-black px-1.5 py-0.5 rounded-full ${
isActive
? 'bg-white/20 text-white'
: 'bg-slate-800 text-slate-400 group-hover:text-slate-200'
}`}
>
{tab.count}
</span>
)}
</>
)}
{/* Collapsed active dot */}
{isCollapsed && isActive && (
<span className="absolute right-1.5 top-1/2 -translate-y-1/2 w-1.5 h-1.5 bg-white rounded-full shadow-xs" />
)}
</button> </button>
); </div>
})} ) : (
</nav> <div className="flex flex-col items-center gap-2">
</div> <div
className="h-8 w-8 rounded-xl bg-indigo-950/60 border border-indigo-500/30 flex items-center justify-center text-indigo-400 font-bold text-xs shrink-0"
{/* User Footer */} title={`${loggedInUser?.display_name || 'Admin'} (${loggedInUser?.email})`}
<div className="pt-3 border-t border-slate-800/80 mt-4"> >
{!isCollapsed ? (
<div className="space-y-2.5 px-1">
<div className="flex items-center gap-2.5">
<div className="h-8 w-8 rounded-xl bg-gradient-to-tr from-indigo-950 to-indigo-900 border border-indigo-500/30 flex items-center justify-center text-indigo-400 font-black text-xs shrink-0 shadow-inner">
{loggedInUser?.display_name ? loggedInUser.display_name[0].toUpperCase() : 'A'} {loggedInUser?.display_name ? loggedInUser.display_name[0].toUpperCase() : 'A'}
</div> </div>
<div className="min-w-0 flex-1"> <button
<p className="text-xs font-bold text-white truncate"> type="button"
{loggedInUser?.display_name || 'Admin'} onClick={onLogout}
</p> className="h-8 w-8 flex items-center justify-center rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white transition-colors cursor-pointer border border-slate-700/60"
<p className="text-[10px] text-slate-400 truncate">{loggedInUser?.email}</p> title="Log Out"
</div> >
<LogOut className="h-3.5 w-3.5" />
</button>
</div> </div>
<button )}
type="button" </div>
onClick={onLogout} </aside>
className="w-full flex items-center justify-center gap-2 py-2 rounded-xl text-xs font-bold bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white transition-colors cursor-pointer border border-slate-700/60" </>
>
<LogOut className="h-3.5 w-3.5" /> Log Out
</button>
</div>
) : (
<div className="flex flex-col items-center gap-2">
<div
className="h-8 w-8 rounded-xl bg-indigo-950/60 border border-indigo-500/30 flex items-center justify-center text-indigo-400 font-bold text-xs shrink-0"
title={`${loggedInUser?.display_name || 'Admin'} (${loggedInUser?.email})`}
>
{loggedInUser?.display_name ? loggedInUser.display_name[0].toUpperCase() : 'A'}
</div>
<button
type="button"
onClick={onLogout}
className="h-8 w-8 flex items-center justify-center rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white transition-colors cursor-pointer border border-slate-700/60"
title="Log Out"
>
<LogOut className="h-3.5 w-3.5" />
</button>
</div>
)}
</div>
</aside>
); );
}; };

View File

@ -156,7 +156,7 @@ export const ModulesTab: React.FC<ModulesTabProps> = ({
) : ( ) : (
<div className="bg-white border border-slate-200 rounded-2xl overflow-hidden shadow-sm p-4"> <div className="bg-white border border-slate-200 rounded-2xl overflow-hidden shadow-sm p-4">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-left border-collapse text-xs"> <table className="w-full text-left border-collapse text-xs min-w-[650px]">
<thead> <thead>
<tr className="bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider border-b border-slate-200"> <tr className="bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider border-b border-slate-200">
<th className="py-3 px-3.5">Module Name & Details</th> <th className="py-3 px-3.5">Module Name & Details</th>

View File

@ -146,7 +146,7 @@ export const PaymentsTab: React.FC<PaymentsTabProps> = ({
) : ( ) : (
<div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white"> <div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-xs"> <table className="w-full text-xs min-w-[760px]">
<thead> <thead>
<tr className="border-b border-slate-200 bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider"> <tr className="border-b border-slate-200 bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider">
<th className="text-left py-3 px-3">Payment ID</th> <th className="text-left py-3 px-3">Payment ID</th>

View File

@ -133,7 +133,7 @@ export const PlansTab: React.FC<PlansTabProps> = ({
) : ( ) : (
<div className="border border-slate-200 rounded-2xl overflow-hidden shadow-sm bg-white p-4"> <div className="border border-slate-200 rounded-2xl overflow-hidden shadow-sm bg-white p-4">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-left border-collapse"> <table className="w-full text-left border-collapse min-w-[720px]">
<thead> <thead>
<tr className="bg-slate-50 border-b border-slate-200 text-[11px] uppercase font-bold text-slate-400 tracking-wider"> <tr className="bg-slate-50 border-b border-slate-200 text-[11px] uppercase font-bold text-slate-400 tracking-wider">
<th className="py-3.5 px-4">Plan Details</th> <th className="py-3.5 px-4">Plan Details</th>

View File

@ -96,7 +96,7 @@ export const SubscriptionsTab: React.FC<SubscriptionsTabProps> = ({
</div> </div>
{/* Sort & Count Bar */} {/* Sort & Count Bar */}
<div className="flex justify-between items-center pt-2 border-t border-slate-200/60"> <div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2 pt-2 border-t border-slate-200/60">
<button <button
type="button" type="button"
onClick={() => setSortOrder(prev => prev === 'desc' ? 'asc' : 'desc')} onClick={() => setSortOrder(prev => prev === 'desc' ? 'asc' : 'desc')}
@ -126,7 +126,7 @@ export const SubscriptionsTab: React.FC<SubscriptionsTabProps> = ({
) : ( ) : (
<div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white"> <div className="border border-slate-200 rounded-2xl overflow-hidden shadow-xs p-4 bg-white">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full text-xs"> <table className="w-full text-xs min-w-[700px]">
<thead> <thead>
<tr className="border-b border-slate-200 bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider"> <tr className="border-b border-slate-200 bg-slate-50/80 text-[10px] uppercase font-bold text-slate-400 tracking-wider">
<th className="text-left py-3 px-3">Subscriber</th> <th className="text-left py-3 px-3">Subscriber</th>

View File

@ -117,15 +117,15 @@ export const SyncTopCards: React.FC<{
)} )}
</div> </div>
{/* Compliance Box */} {/* Compliance & Transaction Processing Box */}
<div className="bg-white border border-slate-200 rounded-2xl p-5 shadow-sm space-y-3"> <div className="bg-white border border-slate-200 rounded-2xl p-5 shadow-sm space-y-3">
<h3 className="text-sm font-bold text-slate-800 flex items-center gap-2"> <h3 className="text-sm font-bold text-slate-800 flex items-center gap-2">
<Shield className="h-4 w-4 text-emerald-500" /> Tax Compliance <Shield className="h-4 w-4 text-emerald-500" /> Gateway & Transaction Processing
</h3> </h3>
<div className="text-[10px] text-slate-400 space-y-1 font-bold"> <div className="text-[10px] text-slate-500 space-y-1 font-semibold">
<p>✓ CGST: 9% split</p> <p>✓ All-inclusive customer pricing (no tax markup)</p>
<p>✓ SGST: 9% split</p> <p>✓ Merchant gateway fees handled directly via Razorpay</p>
<p>✓ ISO compliance generated automatically</p> <p>✓ Automated invoice & payment receipt generation</p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -35,19 +35,19 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
<div className="fixed inset-0 z-50 bg-slate-950/60 backdrop-blur-xs flex justify-end animate-in fade-in duration-200"> <div className="fixed inset-0 z-50 bg-slate-950/60 backdrop-blur-xs flex justify-end animate-in fade-in duration-200">
<div className="w-full max-w-xl bg-white h-full shadow-2xl flex flex-col justify-between overflow-hidden animate-in slide-in-from-right duration-200"> <div className="w-full max-w-xl bg-white h-full shadow-2xl flex flex-col justify-between overflow-hidden animate-in slide-in-from-right duration-200">
{/* Drawer Top Bar */} {/* Drawer Top Bar */}
<div className="p-5 border-b border-slate-200 bg-slate-50 flex items-center justify-between shrink-0"> <div className="p-4 sm:p-5 border-b border-slate-200 bg-slate-50 flex items-center justify-between shrink-0 gap-3">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3 min-w-0">
<div className="h-11 w-11 rounded-2xl bg-indigo-600 text-white font-black text-base flex items-center justify-center shadow-md"> <div className="h-10 w-10 sm:h-11 sm:w-11 rounded-2xl bg-indigo-600 text-white font-black text-sm sm:text-base flex items-center justify-center shadow-md shrink-0">
{customerData?.display_name ? customerData.display_name[0].toUpperCase() : 'U'} {customerData?.display_name ? customerData.display_name[0].toUpperCase() : 'U'}
</div> </div>
<div> <div className="min-w-0 flex-1">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2 flex-wrap">
<h3 className="text-base font-black text-slate-800"> <h3 className="text-sm sm:text-base font-black text-slate-800 truncate">
{customerData?.display_name || 'Customer Account'} {customerData?.display_name || 'Customer Account'}
</h3> </h3>
{customerData && ( {customerData && (
<span <span
className={`text-[10px] font-black uppercase px-2 py-0.5 rounded-full border ${ className={`text-[10px] font-black uppercase px-2 py-0.5 rounded-full border shrink-0 ${
customerData.is_active customerData.is_active
? 'bg-emerald-50 text-emerald-700 border-emerald-200' ? 'bg-emerald-50 text-emerald-700 border-emerald-200'
: 'bg-rose-50 text-rose-700 border-rose-200' : 'bg-rose-50 text-rose-700 border-rose-200'
@ -57,21 +57,22 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
</span> </span>
)} )}
</div> </div>
<p className="text-xs text-slate-400 font-semibold">{customerData?.email || 'Loading...'}</p> <p className="text-xs text-slate-400 font-semibold truncate">{customerData?.email || 'Loading...'}</p>
</div> </div>
</div> </div>
<button <button
type="button" type="button"
onClick={onClose} onClick={onClose}
className="h-8 w-8 rounded-full bg-slate-200/80 hover:bg-slate-300 text-slate-600 flex items-center justify-center text-sm font-black transition-colors cursor-pointer" className="h-8 w-8 rounded-full bg-slate-200/80 hover:bg-slate-300 text-slate-600 flex items-center justify-center text-sm font-black transition-colors cursor-pointer shrink-0"
aria-label="Close customer drawer"
> >
✕ ✕
</button> </button>
</div> </div>
{/* Drawer Body */} {/* Drawer Body */}
<div className="flex-1 overflow-y-auto p-6 space-y-6"> <div className="flex-1 overflow-y-auto p-4 sm:p-6 space-y-5 sm:space-y-6">
{loading ? ( {loading ? (
<div className="flex flex-col items-center justify-center py-20 space-y-3"> <div className="flex flex-col items-center justify-center py-20 space-y-3">
<RefreshCw className="h-8 w-8 animate-spin text-indigo-600" /> <RefreshCw className="h-8 w-8 animate-spin text-indigo-600" />
@ -80,10 +81,10 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
) : customerData ? ( ) : customerData ? (
<> <>
{/* Account Status Control */} {/* Account Status Control */}
<div className="bg-slate-50 border border-slate-200 rounded-2xl p-4 flex items-center justify-between shadow-2xs"> <div className="bg-slate-50 border border-slate-200 rounded-2xl p-4 flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-2xs">
<div className="space-y-0.5"> <div className="space-y-0.5 min-w-0">
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<Shield className="h-3.5 w-3.5 text-indigo-600" /> <Shield className="h-3.5 w-3.5 text-indigo-600 shrink-0" />
<span className="text-xs font-bold text-slate-800">Account Access Control</span> <span className="text-xs font-bold text-slate-800">Account Access Control</span>
</div> </div>
<p className="text-[11px] text-slate-500 font-medium"> <p className="text-[11px] text-slate-500 font-medium">
@ -97,7 +98,7 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
type="button" type="button"
onClick={onToggleStatus} onClick={onToggleStatus}
disabled={statusToggling} 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 customerData.is_active
? 'bg-rose-50 hover:bg-rose-100 text-rose-700 border border-rose-200' ? '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' : 'bg-emerald-600 hover:bg-emerald-500 text-white shadow-emerald-600/20'
@ -114,7 +115,7 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
</div> </div>
{/* Drawer Sub-Tabs */} {/* Drawer Sub-Tabs */}
<div className="flex border-b border-slate-200 gap-1 pb-1"> <div className="flex border-b border-slate-200 gap-1.5 pb-1 overflow-x-auto select-none">
{[ {[
{ id: 'overview' as const, label: 'Overview' }, { id: 'overview' as const, label: 'Overview' },
{ {
@ -130,7 +131,7 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
key={tab.id} key={tab.id}
type="button" type="button"
onClick={() => onTabChange(tab.id)} 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 activeTab === tab.id
? 'bg-indigo-600 text-white shadow-xs' ? 'bg-indigo-600 text-white shadow-xs'
: 'text-slate-500 hover:text-slate-800 hover:bg-slate-100' : 'text-slate-500 hover:text-slate-800 hover:bg-slate-100'
@ -145,9 +146,9 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
{activeTab === 'overview' && ( {activeTab === 'overview' && (
<div className="space-y-4"> <div className="space-y-4">
<div className="grid grid-cols-2 gap-3"> <div className="grid grid-cols-2 gap-3">
<div className="bg-slate-50 rounded-2xl p-3 border border-slate-200/60"> <div className="bg-slate-50 rounded-2xl p-3 border border-slate-200/60 min-w-0">
<span className="text-[10px] font-bold text-slate-400 uppercase tracking-wider">Total Spent</span> <span className="text-[10px] font-bold text-slate-400 uppercase tracking-wider block">Total Spent</span>
<p className="text-xl font-black text-slate-800 mt-0.5"> <p className="text-lg sm:text-xl font-black text-slate-800 mt-0.5 truncate">
{customerData.total_spent_formatted || {customerData.total_spent_formatted ||
formatCurrency( formatCurrency(
customerData.total_spent ?? customerData.total_spent_inr ?? 0, customerData.total_spent ?? customerData.total_spent_inr ?? 0,
@ -155,9 +156,9 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
)} )}
</p> </p>
</div> </div>
<div className="bg-slate-50 rounded-2xl p-3 border border-slate-200/60"> <div className="bg-slate-50 rounded-2xl p-3 border border-slate-200/60 min-w-0">
<span className="text-[10px] font-bold text-slate-400 uppercase tracking-wider">Total Orders</span> <span className="text-[10px] font-bold text-slate-400 uppercase tracking-wider block">Total Orders</span>
<p className="text-xl font-black text-slate-800 mt-0.5">{customerData.total_orders || 0}</p> <p className="text-lg sm:text-xl font-black text-slate-800 mt-0.5 truncate">{customerData.total_orders || 0}</p>
</div> </div>
</div> </div>
@ -165,35 +166,35 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
<h4 className="text-xs font-bold text-slate-700 uppercase tracking-wider border-b border-slate-100 pb-2"> <h4 className="text-xs font-bold text-slate-700 uppercase tracking-wider border-b border-slate-100 pb-2">
Contact & Account Information Contact & Account Information
</h4> </h4>
<div className="grid grid-cols-2 gap-y-2.5 text-xs"> <div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3 text-xs">
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Email Address</span> <span className="text-slate-400 font-semibold block text-[10px]">Email Address</span>
<span className="font-bold text-slate-700">{customerData.email}</span> <span className="font-bold text-slate-700 break-all">{customerData.email}</span>
</div> </div>
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Phone Number</span> <span className="text-slate-400 font-semibold block text-[10px]">Phone Number</span>
<span className="font-bold text-slate-700">{customerData.phone_number || 'Not provided'}</span> <span className="font-bold text-slate-700 break-words">{customerData.phone_number || 'Not provided'}</span>
</div> </div>
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Country</span> <span className="text-slate-400 font-semibold block text-[10px]">Country</span>
<span className="font-bold text-slate-700">{customerData.country || 'India'}</span> <span className="font-bold text-slate-700">{customerData.country || 'India'}</span>
</div> </div>
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Assigned Roles</span> <span className="text-slate-400 font-semibold block text-[10px]">Assigned Roles</span>
<span className="font-bold text-indigo-600 capitalize"> <span className="font-bold text-indigo-600 capitalize">
{customerData.roles?.join(', ') || 'user'} {customerData.roles?.join(', ') || 'user'}
</span> </span>
</div> </div>
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Member Since</span> <span className="text-slate-400 font-semibold block text-[10px]">Member Since</span>
<span className="font-bold text-slate-700"> <span className="font-bold text-slate-700">
{customerData.created_at ? customerData.created_at.split('T')[0] : 'N/A'} {customerData.created_at ? customerData.created_at.split('T')[0] : 'N/A'}
</span> </span>
</div> </div>
{customerData.external_ref && ( {customerData.external_ref && (
<div> <div className="min-w-0">
<span className="text-slate-400 font-semibold block text-[10px]">Gateway Ref</span> <span className="text-slate-400 font-semibold block text-[10px]">Gateway Ref</span>
<span className="font-bold font-mono text-[10px] text-slate-600">{customerData.external_ref}</span> <span className="font-bold font-mono text-[10px] text-slate-600 break-all">{customerData.external_ref}</span>
</div> </div>
)} )}
</div> </div>
@ -281,25 +282,25 @@ export const CustomerDrawer: React.FC<CustomerDrawerProps> = ({
return ( return (
<div <div
key={idx} key={idx}
className="flex justify-between items-center bg-slate-50 border border-slate-200 rounded-xl p-3.5 text-xs shadow-2xs" className="flex flex-col sm:flex-row sm:items-center justify-between gap-2.5 bg-slate-50 border border-slate-200 rounded-xl p-3.5 text-xs shadow-2xs"
> >
<div className="space-y-0.5"> <div className="space-y-0.5 min-w-0">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2 flex-wrap">
<span className="font-mono font-bold text-slate-800">{invNumber}</span> <span className="font-mono font-bold text-slate-800 break-all">{invNumber}</span>
{tx.invoice?.invoice_number && ( {tx.invoice?.invoice_number && (
<span className="text-[9px] bg-indigo-50 border border-indigo-200 text-indigo-700 font-bold px-1.5 py-0.2 rounded"> <span className="text-[9px] bg-indigo-50 border border-indigo-200 text-indigo-700 font-bold px-1.5 py-0.2 rounded shrink-0">
Invoice Invoice
</span> </span>
)} )}
</div> </div>
<p className="text-[10px] text-slate-400"> <p className="text-[10px] text-slate-400 break-all">
{tx.created_at?.split('T')[0] || '—'} {tx.created_at?.split('T')[0] || '—'}
{tx.gateway_transaction_id && ` • ${tx.gateway_transaction_id}`} {tx.gateway_transaction_id && ` • ${tx.gateway_transaction_id}`}
</p> </p>
</div> </div>
<div className="flex items-center gap-3"> <div className="flex items-center justify-between sm:justify-end gap-3 shrink-0 pt-1 sm:pt-0 border-t sm:border-t-0 border-slate-200/60">
<div className="text-right"> <div className="text-left sm:text-right">
<p className="font-bold text-slate-800">{formatCurrency(amount, curr)}</p> <p className="font-bold text-slate-800">{formatCurrency(amount, curr)}</p>
<span <span
className={`text-[10px] font-bold ${ className={`text-[10px] font-bold ${