// admin-app.jsx — Standalone admin app with login, sidebar, routing function AdminApp() { const [authed, setAuthed] = React.useState(() => sessionStorage.getItem('istabraq_admin') === '1'); const [lang, setLang] = React.useState('ar'); const [route, setRoute] = React.useState('dashboard'); const [sideOpen, setSideOpen] = React.useState(false); React.useEffect(() => { document.documentElement.lang = lang; document.documentElement.dir = lang === 'ar' ? 'rtl' : 'ltr'; }, [lang]); if (!authed) { return { sessionStorage.setItem('istabraq_admin', '1'); setAuthed(true); }} lang={lang} setLang={setLang} />; } return (
{ setRoute(r); setSideOpen(false); }} lang={lang} setLang={setLang} open={sideOpen} onClose={() => setSideOpen(false)} onLogout={() => { sessionStorage.removeItem('istabraq_admin'); setAuthed(false); }} />
setSideOpen(true)} lang={lang} />
{route === 'dashboard' && } {route === 'transactions' && } {route === 'expenses' && } {route === 'invoices' && } {route === 'pnl' && } {route === 'tax' && } {route === 'products' && } {route === 'orders' && } {route === 'analytics' && } {route === 'customers' && } {route === 'settings' && }
); } function AdminLogin({ onAuth, lang, setLang }) { const t = (ar, en) => lang === 'ar' ? ar : en; const [email, setEmail] = React.useState('admin@istabraq.ae'); const [pwd, setPwd] = React.useState('••••••••'); const submit = (e) => { e.preventDefault(); onAuth(); }; return (
{t('استبرق', 'ISTABRAQ')}
{t('Admin Dashboard · لوحة التحكم', 'Admin Dashboard')}
{t('تسجيل الدخول', 'Sign in')}

{t('أهلاً بعودتك.', 'Welcome back.')}

setEmail(e.target.value)} autoFocus />
setPwd(e.target.value)} />
{t('نسيت كلمة المرور؟', 'Forgot password?')}
{t('وصول آمن', 'Secure access')} · {t('هذه اللوحة مخصّصة للإدارة فقط. اتصال مشفّر TLS 1.3.', 'Admin only. Encrypted TLS 1.3 connection.')}
{t('العودة إلى المتجر', 'Back to storefront')}
{t('بيان', 'Manifesto')}

{t('"من قلب الهند إلى خزانتك. كل قطرة، كل دفتر، كل عميل."', '"From the heart of India to your shelf. Every drop, every ledger, every customer."')}

); } function AdminSidebar({ route, setRoute, lang, setLang, open, onClose, onLogout }) { const t = (ar, en) => lang === 'ar' ? ar : en; const groups = [ { title: t('المالية', 'Finance'), items: [ { id: 'dashboard', label: t('لوحة الإيرادات', 'Overview'), icon: }, { id: 'transactions', label: t('المعاملات', 'Transactions'), icon: }, { id: 'expenses', label: t('المصاريف', 'Expenses'), icon: }, { id: 'invoices', label: t('الفواتير', 'Invoices'), icon: }, { id: 'pnl', label: t('الأرباح والخسائر', 'P & L'), icon: }, { id: 'tax', label: t('الضرائب', 'VAT & Tax'), icon: }, ], }, { title: t('المتجر', 'Store'), items: [ { id: 'products', label: t('المنتجات', 'Products'), icon: }, { id: 'orders', label: t('الطلبات', 'Orders'), icon: }, { id: 'analytics', label: t('التحليلات', 'Analytics'), icon: }, { id: 'customers', label: t('العملاء', 'Customers'), icon: }, { id: 'settings', label: t('الإعدادات', 'Settings'), icon: }, ], }, ]; return ( <> {open &&
} ); } function AdminTopbar({ route, onMenu, lang }) { const t = (ar, en) => lang === 'ar' ? ar : en; const labels = { dashboard: t('لوحة الإيرادات', 'Financial Overview'), transactions: t('المعاملات', 'Transactions'), expenses: t('المصاريف', 'Expenses'), invoices: t('الفواتير', 'Invoices'), pnl: t('الأرباح والخسائر', 'Profit & Loss'), tax: t('الضرائب', 'VAT & Tax'), products: t('المنتجات', 'Products'), orders: t('الطلبات', 'Orders'), analytics: t('التحليلات', 'Analytics'), customers: t('العملاء', 'Customers'), settings: t('الإعدادات', 'Settings'), }; return (
{t('الإدارة', 'Admin')} / {labels[route] || route}
⌘K
); } window.AdminApp = AdminApp;