🚀 Initialize Musadaq SaaS: Full Backend + AI + React Dashboard + Docker Setup
This commit is contained in:
159
frontend/src/pages/invoices/InvoicesPage.tsx
Normal file
159
frontend/src/pages/invoices/InvoicesPage.tsx
Normal file
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* ════════════════════════════════════════════════════════════
|
||||
* مُصادَق (Musadaq) — Invoices Management Page
|
||||
* ════════════════════════════════════════════════════════════
|
||||
*/
|
||||
|
||||
import { useState } from 'react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import {
|
||||
Upload,
|
||||
Search,
|
||||
Filter,
|
||||
Eye,
|
||||
CheckCircle2,
|
||||
Clock,
|
||||
AlertCircle,
|
||||
MoreVertical,
|
||||
FileImage,
|
||||
ChevronLeft,
|
||||
ChevronRight
|
||||
} from 'lucide-react';
|
||||
|
||||
const invoices = [
|
||||
{ id: '1', number: 'INV-2024-001', company: 'شركة الأمل', date: '2024-04-15', total: '150.000', status: 'approved', type: 'cash' },
|
||||
{ id: '2', number: 'INV-2024-002', company: 'سوبرماركت المدينة', date: '2024-04-16', total: '2,400.000', status: 'validated', type: 'credit' },
|
||||
{ id: '3', number: 'OCR_PENDING', company: 'مخبز السلام', date: '2024-04-16', total: '0.000', status: 'extracting', type: 'cash' },
|
||||
{ id: '4', number: 'INV-2024-003', company: 'مكتبة النجاح', date: '2024-04-14', total: '85.250', status: 'validation_failed', type: 'cash' },
|
||||
];
|
||||
|
||||
const StatusBadge = ({ status }: { status: string }) => {
|
||||
const config: any = {
|
||||
approved: { color: 'text-emerald-700 bg-emerald-50 border-emerald-100', icon: CheckCircle2, label: 'تم التصديق' },
|
||||
validated: { color: 'text-blue-700 bg-blue-50 border-blue-100', icon: Clock, label: 'جاهز للإرسال' },
|
||||
extracting: { color: 'text-amber-700 bg-amber-50 border-amber-100', icon: Clock, label: 'قيد الاستخراج AI' },
|
||||
validation_failed: { color: 'text-red-700 bg-red-50 border-red-100', icon: AlertCircle, label: 'خطأ في التحقق' },
|
||||
};
|
||||
const { color, icon: Icon, label } = config[status] || config.extracting;
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border ${color}`}>
|
||||
<Icon className="w-3.5 h-3.5" />
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export const InvoicesPage = () => {
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
|
||||
return (
|
||||
<div className="space-y-8 h-full flex flex-col">
|
||||
<header className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-3xl font-bold text-slate-900">إدارة الفواتير</h2>
|
||||
<p className="text-slate-500 mt-1">عرض، معالجة، وإرسال الفواتير الضريبية لبوابة الضريبة.</p>
|
||||
</div>
|
||||
<button className="btn-primary py-3 px-8 rounded-2xl flex items-center gap-2 shadow-xl shadow-primary-500/25 active:scale-95 transition-all">
|
||||
<Upload className="w-5 h-5" />
|
||||
رفع فاتورة جديدة
|
||||
</button>
|
||||
</header>
|
||||
|
||||
{/* ── Filter & Search Bar ──────────────────────────────── */}
|
||||
<div className="flex gap-4">
|
||||
<div className="flex-1 glass border-slate-200 rounded-2xl px-4 py-3 flex items-center gap-3">
|
||||
<Search className="w-5 h-5 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="ابحث برقم الفاتورة، اسم الشركة، أو التاريخ..."
|
||||
className="bg-transparent border-none outline-none flex-1 text-slate-800 text-sm"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<button className="glass border-slate-200 px-6 rounded-2xl flex items-center gap-2 text-slate-600 hover:bg-slate-50 transition-all font-semibold">
|
||||
<Filter className="w-4 h-4" />
|
||||
فلترة متقدمة
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ── Invoices Table ───────────────────────────────────── */}
|
||||
<div className="flex-1 card-premium overflow-hidden flex flex-col bg-white">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-right border-collapse">
|
||||
<thead className="bg-slate-50/80 border-b border-slate-100">
|
||||
<tr>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">رقم الفاتورة</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">الشركة المصدرة</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">التاريخ</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">النوع</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">المجموع (JOD)</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500">الحالة</th>
|
||||
<th className="px-6 py-4 text-sm font-bold text-slate-500 w-20">إجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-slate-100">
|
||||
{invoices.map((inv, idx) => (
|
||||
<motion.tr
|
||||
key={inv.id}
|
||||
initial={{ opacity: 0, x: 20 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ delay: idx * 0.05 }}
|
||||
className="hover:bg-slate-50/50 transition-colors group cursor-pointer"
|
||||
>
|
||||
<td className="px-6 py-4 font-bold text-slate-900">{inv.number}</td>
|
||||
<td className="px-6 py-4 text-slate-600 font-medium">{inv.company}</td>
|
||||
<td className="px-6 py-4 text-slate-500 text-sm">{inv.date}</td>
|
||||
<td className="px-6 py-4">
|
||||
<span className={`text-[11px] font-bold px-2 py-0.5 rounded uppercase tracking-wider ${inv.type === 'cash' ? 'bg-indigo-50 text-indigo-600' : 'bg-orange-50 text-orange-600'}`}>
|
||||
{inv.type === 'cash' ? 'نقدي' : 'ذمم'}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-4 font-mono font-bold text-slate-800">{inv.total}</td>
|
||||
<td className="px-6 py-4"><StatusBadge status={inv.status} /></td>
|
||||
<td className="px-6 py-4 text-center">
|
||||
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<button className="p-2 text-slate-400 hover:text-primary-600 hover:bg-primary-50 rounded-lg transition-all">
|
||||
<Eye className="w-4 h-4" />
|
||||
</button>
|
||||
<button className="p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-lg transition-all">
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</motion.tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* ── Empty State Mock (Hidden if data exists) ───────────── */}
|
||||
{invoices.length === 0 && (
|
||||
<div className="flex-1 flex flex-col items-center justify-center p-20 text-center">
|
||||
<div className="w-24 h-24 bg-slate-50 rounded-full flex items-center justify-center mb-6 border border-slate-100">
|
||||
<Upload className="w-10 h-10 text-slate-300" />
|
||||
</div>
|
||||
<h3 className="text-xl font-bold text-slate-900 mb-2">لا توجد فواتير بعد</h3>
|
||||
<p className="text-slate-500 max-w-sm mb-8">ابدأ برفع أول فاتورة ليقوم محرك الذكاء الاصطناعي باستخراج بياناتها ومصادقتها ضريبياً.</p>
|
||||
<button className="btn-primary py-3 px-8 rounded-2xl flex items-center gap-2">
|
||||
ارفع فاتورتك الأولى
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Pagination ───────────────────────────────────────── */}
|
||||
<footer className="px-6 py-4 bg-slate-50/50 border-t border-slate-100 flex items-center justify-between">
|
||||
<p className="text-sm text-slate-500">عرض 1-10 من أصل 1,280 فاتورة</p>
|
||||
<div className="flex gap-2">
|
||||
<button className="p-2 text-slate-400 hover:text-slate-600 disabled:opacity-30 border border-slate-200 rounded-xl bg-white shadow-sm">
|
||||
<ChevronRight className="w-5 h-5" />
|
||||
</button>
|
||||
<button className="p-2 text-slate-400 hover:text-slate-600 disabled:opacity-30 border border-slate-200 rounded-xl bg-white shadow-sm">
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user