diff --git a/frontend/src/components/layout/Sidebar.tsx b/frontend/src/components/layout/Sidebar.tsx index 6f25b3d..ccf9259 100644 --- a/frontend/src/components/layout/Sidebar.tsx +++ b/frontend/src/components/layout/Sidebar.tsx @@ -18,7 +18,7 @@ import { useAuthStore } from '../../store/authStore'; const menuItems = [ { icon: LayoutDashboard, label: 'الرئيسية', path: '/dashboard' }, - { icon: Crown, label: 'لوحة النخبة', path: '/elite-dashboard' }, + { icon: Crown, label: 'المركز الضريبي الموحد', path: '/elite-dashboard' }, { icon: FileText, label: 'الفواتير', path: '/invoices' }, { icon: Building2, label: 'الشركات', path: '/companies' }, { icon: Users, label: 'الموظفون', path: '/staff' }, diff --git a/frontend/src/pages/companies/CompaniesPage.tsx b/frontend/src/pages/companies/CompaniesPage.tsx index 81c4d96..874ee47 100644 --- a/frontend/src/pages/companies/CompaniesPage.tsx +++ b/frontend/src/pages/companies/CompaniesPage.tsx @@ -1,11 +1,12 @@ /** * ════════════════════════════════════════════════════════════ - * مُصادَق (Musadaq) — Companies Management Page + * مُصادَق (Musadaq) — Companies Management Page (Premium Dark) * ════════════════════════════════════════════════════════════ */ import { useState, useEffect } from 'react'; -import { Building2, Plus, Search, MoreVertical, ShieldCheck, Key } from 'lucide-react'; +import { Building2, Plus, Search, MoreVertical, ShieldCheck, Key, Loader2, X, MapPin, Hash } from 'lucide-react'; +import { motion, AnimatePresence } from 'framer-motion'; import apiClient from '../../api/client'; export const CompaniesPage = () => { @@ -20,10 +21,12 @@ export const CompaniesPage = () => { const [name, setName] = useState(''); const [tin, setTin] = useState(''); const [address, setAddress] = useState(''); + const [isCreating, setIsCreating] = useState(false); // Form State (JoFotara) const [clientId, setClientId] = useState(''); const [secretKey, setSecretKey] = useState(''); + const [isLinking, setIsLinking] = useState(false); const fetchCompanies = async () => { try { @@ -42,6 +45,7 @@ export const CompaniesPage = () => { const handleCreateCompany = async (e: React.FormEvent) => { e.preventDefault(); + setIsCreating(true); try { await apiClient.post('/companies', { name, @@ -56,18 +60,21 @@ export const CompaniesPage = () => { } catch (error) { console.error('Failed to create company', error); alert('حدث خطأ أثناء إضافة الشركة'); + } finally { + setIsCreating(false); } }; const handleOpenJoFotara = (company: any) => { setSelectedCompany(company); - setClientId(''); // We don't fetch existing keys for security, user has to enter new ones if they want to update + setClientId(''); setSecretKey(''); setIsJoFotaraModalOpen(true); }; const handleSubmitJoFotara = async (e: React.FormEvent) => { e.preventDefault(); + setIsLinking(true); try { await apiClient.put(`/companies/${selectedCompany.id}/jofotara`, { clientId, @@ -75,27 +82,30 @@ export const CompaniesPage = () => { }); setIsJoFotaraModalOpen(false); setSelectedCompany(null); - fetchCompanies(); // Refresh to show "Linked" status + fetchCompanies(); } catch (error) { console.error('Failed to link JoFotara', error); alert('حدث خطأ أثناء ربط حساب جو فوترة'); + } finally { + setIsLinking(false); } }; const filteredCompanies = companies.filter(c => - c.name.includes(searchTerm) || c.tax_identification_number?.includes(searchTerm) + c.name.toLowerCase().includes(searchTerm.toLowerCase()) || + c.tax_identification_number?.includes(searchTerm) ); return ( -
أضف عملائك وشركاتك لربط فواتيرهم بنظام جو فوترة.
+أضف عملائك وشركاتك لربط فواتيرهم بنظام جو فوترة.
جاري تحميل الشركات...
ابدأ بإضافة أول شركة لكي تتمكن من رفع فواتيرها ومعالجتها ضريبياً.
-الرقم الضريبي: {company.tax_identification_number || 'غير محدد'}
+ +{selectedCompany?.name}
+{selectedCompany?.name}
-عرض، معالجة، وإرسال الفواتير الضريبية لبوابة الضريبة.
+عرض، معالجة، وإرسال الفواتير الضريبية لبوابة الضريبة.
جاري جلب الفواتير...
ابدأ برفع أول فاتورة ليقوم محرك الذكاء الاصطناعي باستخراج بياناتها ومصادقتها ضريبياً.
-| رقم الفاتورة | -الشركة | -التاريخ | -المجموع (JOD) | -الحالة | -إجراءات | +رقم الفاتورة | +الشركة | +التاريخ | +المجموع (JOD) | +الحالة | +إجراءات | {inv.invoice_number || '---'} | -+ | {inv.invoice_number || '---'} | +
-
-
- {inv.company?.name || 'شركة غير معروفة'}
+ |
{inv.invoice_date ? new Date(inv.invoice_date).toLocaleDateString('ar-JO') : '---'} | -+ | {Number(inv.grand_total).toLocaleString('en-US', { minimumFractionDigits: 3 })} |
-
+
+ |
@@ -325,13 +261,13 @@ export const InvoicesPage = () => {
{/* ── Pagination ───────────────────────────────────────── */}
{!isLoading && filteredInvoices.length > 0 && (
- e.stopPropagation()}>
-
+
-
- |
|---|