💎 Complete luxury overhaul: Invoices, Companies, Staff, Settings redesigned & renamed Sidebar

This commit is contained in:
Hamza-Ayed
2026-04-22 02:18:41 +03:00
parent a113f72842
commit 5aa3a178b9
5 changed files with 594 additions and 583 deletions

View File

@@ -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' },

View File

@@ -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 (
<div className="space-y-8 h-full flex flex-col animate-in fade-in slide-in-from-bottom-4 duration-700">
<div className="space-y-8 animate-in fade-in duration-700">
<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>
<h2 className="text-3xl font-black text-white">إدارة الشركات</h2>
<p className="text-slate-400 mt-1">أضف عملائك وشركاتك لربط فواتيرهم بنظام جو فوترة.</p>
</div>
<button
onClick={() => setIsAddModalOpen(true)}
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"
className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl flex items-center gap-2 shadow-lg shadow-emerald-500/20 transition-all active:scale-95"
>
<Plus className="w-5 h-5" />
إضافة شركة جديدة
@@ -103,187 +113,233 @@ export const CompaniesPage = () => {
</header>
{/* ── 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>
<div className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-xl px-4 py-3 flex items-center gap-3">
<Search className="w-5 h-5 text-slate-500" />
<input
type="text"
placeholder="ابحث باسم الشركة أو الرقم الضريبي..."
className="bg-transparent border-none outline-none flex-1 text-slate-200 text-sm placeholder-slate-500"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
</div>
{/* ── Companies Grid ───────────────────────────────────── */}
{isLoading ? (
<div className="flex-1 flex justify-center items-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600"></div>
<div className="flex flex-col items-center justify-center p-20">
<Loader2 className="w-10 h-10 text-emerald-500 animate-spin mb-4" />
<p className="text-slate-500">جاري تحميل الشركات...</p>
</div>
) : filteredCompanies.length === 0 ? (
<div className="flex-1 flex flex-col items-center justify-center p-20 text-center bg-white rounded-3xl border border-slate-100 shadow-sm">
<div className="w-24 h-24 bg-slate-50 rounded-full flex items-center justify-center mb-6 border border-slate-100">
<Building2 className="w-10 h-10 text-slate-300" />
</div>
<h3 className="text-xl font-bold text-slate-900 mb-2">لا توجد شركات مسجلة</h3>
<div className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-3xl p-20 flex flex-col items-center justify-center text-center">
<Building2 className="w-16 h-16 text-slate-700 mb-6" />
<h3 className="text-xl font-bold text-white mb-2">لا توجد شركات مسجلة</h3>
<p className="text-slate-500 max-w-sm mb-8">ابدأ بإضافة أول شركة لكي تتمكن من رفع فواتيرها ومعالجتها ضريبياً.</p>
<button onClick={() => setIsAddModalOpen(true)} className="btn-primary py-3 px-8 rounded-2xl flex items-center gap-2">
<Plus className="w-5 h-5" />
<button onClick={() => setIsAddModalOpen(true)} className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl transition-all">
إضافة شركتك الأولى
</button>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{filteredCompanies.map((company) => (
<div key={company.id} className="card-premium p-6 hover:shadow-lg transition-all border border-slate-100">
<div className="flex items-start justify-between mb-4">
<div className="w-12 h-12 rounded-xl bg-primary-50 text-primary-600 flex items-center justify-center">
{filteredCompanies.map((company, idx) => (
<motion.div
key={company.id}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: idx * 0.1 }}
className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 p-6 rounded-2xl hover:border-emerald-500/50 transition-all group relative overflow-hidden"
>
{/* Ambient Glow */}
<div className="absolute top-0 right-0 w-24 h-24 bg-emerald-500/5 rounded-full blur-3xl" />
<div className="flex items-start justify-between mb-6 relative">
<div className="w-12 h-12 rounded-xl bg-emerald-500/10 text-emerald-500 flex items-center justify-center">
<Building2 className="w-6 h-6" />
</div>
<button className="p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-lg transition-all">
<button className="p-2 text-slate-500 hover:text-white transition-colors">
<MoreVertical className="w-5 h-5" />
</button>
</div>
<h3 className="text-xl font-bold text-slate-900 mb-1">{company.name}</h3>
<p className="text-sm text-slate-500 mb-6">الرقم الضريبي: <span className="font-mono font-bold text-slate-700">{company.tax_identification_number || 'غير محدد'}</span></p>
<h3 className="text-xl font-black text-white mb-4 group-hover:text-emerald-400 transition-colors">{company.name}</h3>
<div className="pt-4 border-t border-slate-100 flex items-center justify-between">
<div className="flex items-center gap-2 text-xs font-bold text-slate-500">
{company.jofotara_client_id ? (
<span className="flex items-center gap-1 text-emerald-600 bg-emerald-50 px-2 py-1 rounded-md">
<ShieldCheck className="w-3.5 h-3.5" /> مربوط بجو فوترة
</span>
) : (
<span className="flex items-center gap-1 text-amber-600 bg-amber-50 px-2 py-1 rounded-md">
<Key className="w-3.5 h-3.5" /> غير مربوط
</span>
)}
<div className="space-y-3 mb-6">
<div className="flex items-center gap-3 text-sm text-slate-400">
<Hash className="w-4 h-4 text-slate-600" />
<span>الرقم الضريبي: <span className="text-slate-200 font-mono font-bold tracking-wider">{company.tax_identification_number || '---'}</span></span>
</div>
<div className="flex items-center gap-3 text-sm text-slate-400">
<MapPin className="w-4 h-4 text-slate-600" />
<span className="truncate">{company.address || 'العنوان غير محدد'}</span>
</div>
</div>
<div className="pt-5 border-t border-slate-800/60 flex items-center justify-between relative">
{company.jofotara_client_id ? (
<div className="flex items-center gap-2 text-[10px] font-bold text-emerald-400 uppercase tracking-widest bg-emerald-400/5 px-2 py-1 rounded-md border border-emerald-400/10">
<ShieldCheck className="w-3 h-3" /> مربوط بجو فوترة
</div>
) : (
<div className="flex items-center gap-2 text-[10px] font-bold text-amber-500 uppercase tracking-widest bg-amber-500/5 px-2 py-1 rounded-md border border-amber-500/10">
<Key className="w-3 h-3" /> غير مربوط
</div>
)}
<button
onClick={() => handleOpenJoFotara(company)}
className="text-primary-600 text-sm font-bold hover:underline"
className="text-emerald-500 text-sm font-bold hover:text-emerald-400 hover:underline transition-colors"
>
{company.jofotara_client_id ? 'تحديث الربط' : 'إعداد جو فوترة'}
{company.jofotara_client_id ? 'تحديث الإعدادات' : 'إعداد الربط'}
</button>
</div>
</div>
</motion.div>
))}
</div>
)}
{/* ── Add Company Modal ───────────────────────────────── */}
{isAddModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/50 backdrop-blur-sm animate-in fade-in duration-200">
<div className="bg-white rounded-3xl p-8 w-full max-w-md shadow-2xl animate-in zoom-in-95 duration-200">
<h3 className="text-2xl font-bold text-slate-900 mb-6">إضافة شركة جديدة</h3>
<form onSubmit={handleCreateCompany} className="space-y-4">
<div>
<label className="block text-sm font-bold text-slate-700 mb-1">اسم الشركة / العميل *</label>
<input
type="text"
required
value={name}
onChange={e => setName(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3 outline-none focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 transition-all"
placeholder="مثال: صيدلية النجاح"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-1">الرقم الضريبي (TIN)</label>
<input
type="text"
value={tin}
onChange={e => setTin(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3 outline-none focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 transition-all font-mono"
placeholder="مثال: 123456789"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-1">العنوان</label>
<input
type="text"
value={address}
onChange={e => setAddress(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3 outline-none focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 transition-all"
placeholder="مثال: عمان، شارع مكة"
/>
</div>
<div className="flex gap-3 pt-4">
<button
type="button"
onClick={() => setIsAddModalOpen(false)}
className="flex-1 bg-slate-100 text-slate-700 font-bold py-3 rounded-xl hover:bg-slate-200 transition-all"
>
إلغاء
</button>
<button
type="submit"
className="flex-1 btn-primary py-3 rounded-xl"
>
حفظ الشركة
</button>
</div>
</form>
<AnimatePresence>
{isAddModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-slate-900 border border-slate-800 p-8 w-full max-w-md rounded-3xl shadow-2xl relative"
>
<button onClick={() => setIsAddModalOpen(false)} className="absolute top-6 left-6 text-slate-500 hover:text-white transition-colors">
<X className="w-6 h-6" />
</button>
<h3 className="text-2xl font-bold text-white mb-6">إضافة شركة جديدة</h3>
<form onSubmit={handleCreateCompany} className="space-y-5">
<div>
<label className="block text-sm font-bold text-slate-400 mb-2">اسم الشركة / العميل *</label>
<input
type="text"
required
value={name}
onChange={e => setName(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white placeholder-slate-600"
placeholder="مثال: صيدلية النجاح"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-400 mb-2">الرقم الضريبي (TIN)</label>
<input
type="text"
value={tin}
onChange={e => setTin(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white font-mono placeholder-slate-600"
placeholder="123456789"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-400 mb-2">العنوان</label>
<input
type="text"
value={address}
onChange={e => setAddress(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white placeholder-slate-600"
placeholder="عمان، شارع مكة"
/>
</div>
<div className="flex gap-4 pt-4">
<button
type="button"
onClick={() => setIsAddModalOpen(false)}
className="flex-1 bg-slate-800 text-slate-400 font-bold py-3 rounded-xl hover:bg-slate-700 transition-all"
>
إلغاء
</button>
<button
type="submit"
disabled={isCreating}
className="flex-1 bg-emerald-500 text-slate-950 font-bold py-3 rounded-xl shadow-lg shadow-emerald-500/20 flex items-center justify-center gap-2 transition-all"
>
{isCreating && <Loader2 className="w-4 h-4 animate-spin" />}
حفظ الشركة
</button>
</div>
</form>
</motion.div>
</div>
</div>
)}
)}
</AnimatePresence>
{/* ── JoFotara Link Modal ───────────────────────────────── */}
{isJoFotaraModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/50 backdrop-blur-sm animate-in fade-in duration-200">
<div className="bg-white rounded-3xl p-8 w-full max-w-md shadow-2xl animate-in zoom-in-95 duration-200">
<div className="flex items-center gap-3 mb-6">
<div className="w-12 h-12 rounded-xl bg-primary-50 text-primary-600 flex items-center justify-center">
<ShieldCheck className="w-6 h-6" />
<AnimatePresence>
{isJoFotaraModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-slate-900 border border-slate-800 p-8 w-full max-w-md rounded-3xl shadow-2xl relative"
>
<button onClick={() => setIsJoFotaraModalOpen(false)} className="absolute top-6 left-6 text-slate-500 hover:text-white transition-colors">
<X className="w-6 h-6" />
</button>
<div className="flex items-center gap-4 mb-8">
<div className="w-14 h-14 rounded-2xl bg-emerald-500/10 text-emerald-500 flex items-center justify-center">
<ShieldCheck className="w-8 h-8" />
</div>
<div>
<h3 className="text-xl font-bold text-white">ربط "جو فوترة"</h3>
<p className="text-sm text-slate-500">{selectedCompany?.name}</p>
</div>
</div>
<div>
<h3 className="text-xl font-bold text-slate-900">ربط نظام جو فوترة</h3>
<p className="text-sm text-slate-500">{selectedCompany?.name}</p>
</div>
</div>
<form onSubmit={handleSubmitJoFotara} className="space-y-4">
<div>
<label className="block text-sm font-bold text-slate-700 mb-1">Client ID</label>
<input
type="text"
required
value={clientId}
onChange={e => setClientId(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3 outline-none focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 transition-all font-mono text-sm"
placeholder="أدخل Client ID..."
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-1">Secret Key</label>
<input
type="password"
required
value={secretKey}
onChange={e => setSecretKey(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3 outline-none focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 transition-all font-mono text-sm"
placeholder="أدخل Secret Key..."
/>
</div>
<div className="flex gap-3 pt-4">
<button
type="button"
onClick={() => setIsJoFotaraModalOpen(false)}
className="flex-1 bg-slate-100 text-slate-700 font-bold py-3 rounded-xl hover:bg-slate-200 transition-all"
>
إلغاء
</button>
<button
type="submit"
className="flex-1 btn-primary py-3 rounded-xl"
>
حفظ وتشفير المفاتيح
</button>
</div>
</form>
<form onSubmit={handleSubmitJoFotara} className="space-y-5">
<div>
<label className="block text-sm font-bold text-slate-400 mb-2">Client ID</label>
<input
type="text"
required
value={clientId}
onChange={e => setClientId(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white font-mono text-sm placeholder-slate-600"
placeholder="أدخل المعرف الخاص بك..."
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-400 mb-2">Secret Key</label>
<input
type="password"
required
value={secretKey}
onChange={e => setSecretKey(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white font-mono text-sm placeholder-slate-600"
placeholder="أدخل مفتاح السر..."
/>
</div>
<div className="bg-amber-500/10 border border-amber-500/20 p-4 rounded-xl mb-4">
<p className="text-[10px] text-amber-500 font-bold leading-relaxed">
سيتم تشفير هذه البيانات وتخزينها بأمان. يرجى التأكد من دقة البيانات لضمان نجاح عملية إرسال الفواتير.
</p>
</div>
<div className="flex gap-4">
<button
type="button"
onClick={() => setIsJoFotaraModalOpen(false)}
className="flex-1 bg-slate-800 text-slate-400 font-bold py-3 rounded-xl hover:bg-slate-700 transition-all"
>
إلغاء
</button>
<button
type="submit"
disabled={isLinking}
className="flex-1 bg-emerald-500 text-slate-950 font-bold py-3 rounded-xl shadow-lg shadow-emerald-500/20 flex items-center justify-center gap-2 transition-all"
>
{isLinking && <Loader2 className="w-4 h-4 animate-spin" />}
حفظ وتشفير
</button>
</div>
</form>
</motion.div>
</div>
</div>
)}
)}
</AnimatePresence>
</div>
);
};

View File

@@ -1,6 +1,6 @@
/**
* ════════════════════════════════════════════════════════════
* مُصادَق (Musadaq) — Invoices Management Page
* مُصادَق (Musadaq) — Invoices Management Page (Premium Dark)
* ════════════════════════════════════════════════════════════
*/
@@ -21,7 +21,9 @@ import {
FileText,
Send,
Download,
Trash2
Trash2,
Loader2,
X
} from 'lucide-react';
import apiClient from '../../api/client';
@@ -46,23 +48,12 @@ export const InvoicesPage = () => {
const fetchData = async () => {
setIsLoading(true);
try {
// Fetch companies first so the dropdown always works
try {
const compRes = await apiClient.get('/companies');
console.log('Fetched Companies:', compRes.data);
setCompanies(compRes.data);
} catch (err) {
console.error('Failed to fetch companies', err);
}
// Fetch invoices separately
try {
const invRes = await apiClient.get('/invoices');
console.log('Fetched Invoices:', invRes.data);
setInvoices(invRes.data);
} catch (err) {
console.error('Failed to fetch invoices', err);
}
const [compRes, invRes] = await Promise.all([
apiClient.get('/companies').catch(() => ({ data: [] })),
apiClient.get('/invoices').catch(() => ({ data: [] }))
]);
setCompanies(compRes.data);
setInvoices(invRes.data);
} finally {
setIsLoading(false);
}
@@ -110,10 +101,6 @@ export const InvoicesPage = () => {
};
const handleSubmitToJoFotara = async (inv: any) => {
if (inv.status !== 'validated' && inv.status !== 'extracted') {
alert('يجب أن تكون الفاتورة مدققة أو مستخرجة أولاً');
return;
}
setSubmitLoading(inv.id);
try {
await apiClient.post(`/invoices/${inv.id}/submit`);
@@ -134,30 +121,23 @@ export const InvoicesPage = () => {
const filteredInvoices = invoices.filter(inv =>
inv.invoice_number?.includes(searchTerm) ||
inv.company?.name?.includes(searchTerm)
inv.company?.name?.toLowerCase().includes(searchTerm.toLowerCase())
);
const StatusBadge = ({ invoice }: { invoice: any }) => {
const status = invoice.status;
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: CheckCircle2, label: 'جاهز للإرسال' },
extracted: { color: 'text-indigo-700 bg-indigo-50 border-indigo-100', icon: CheckCircle2, label: 'تم الاستخراج' },
uploaded: { color: 'text-amber-700 bg-amber-50 border-amber-100', icon: Clock, label: 'قيد المعالجة AI' },
extracting: { color: 'text-amber-700 bg-amber-50 border-amber-100', icon: Clock, label: 'قيد الاستخراج' },
validation_failed: { color: 'text-red-700 bg-red-50 border-red-100', icon: AlertCircle, label: 'خطأ في التحقق' },
approved: { color: 'text-emerald-400 bg-emerald-500/10 border-emerald-500/20', icon: CheckCircle2, label: 'تم التصديق' },
validated: { color: 'text-blue-400 bg-blue-500/10 border-blue-500/20', icon: CheckCircle2, label: 'جاهز للإرسال' },
extracted: { color: 'text-indigo-400 bg-indigo-500/10 border-indigo-500/20', icon: CheckCircle2, label: 'تم الاستخراج' },
uploaded: { color: 'text-amber-400 bg-amber-500/10 border-amber-500/20', icon: Clock, label: 'قيد المعالجة AI' },
extracting: { color: 'text-amber-400 bg-amber-500/10 border-amber-500/20', icon: Clock, label: 'قيد الاستخراج' },
validation_failed: { color: 'text-red-400 bg-red-500/10 border-red-500/20', icon: AlertCircle, label: 'خطأ في التحقق' },
};
const { color, icon: Icon, label } = config[status] || { color: 'text-slate-500 bg-slate-50', icon: Clock, label: status };
const { color, icon: Icon, label } = config[status] || { color: 'text-slate-400 bg-slate-800', icon: Clock, label: status };
const errorTitle = status === 'validation_failed' && invoice.validation_errors
? invoice.validation_errors.join('\n')
: undefined;
return (
<span
title={errorTitle}
className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-bold border ${color} uppercase tracking-tight cursor-help`}
>
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-bold border ${color} uppercase tracking-tight`}>
<Icon className="w-3 h-3" />
{label}
</span>
@@ -165,15 +145,15 @@ export const InvoicesPage = () => {
};
return (
<div className="space-y-8 h-full flex flex-col animate-in fade-in slide-in-from-bottom-4 duration-700">
<div className="space-y-8 animate-in fade-in duration-700">
<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>
<h2 className="text-3xl font-black text-white">إدارة الفواتير</h2>
<p className="text-slate-400 mt-1">عرض، معالجة، وإرسال الفواتير الضريبية لبوابة الضريبة.</p>
</div>
<button
onClick={() => setIsUploadModalOpen(true)}
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"
className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl flex items-center gap-2 shadow-lg shadow-emerald-500/20 transition-all active:scale-95"
>
<Upload className="w-5 h-5" />
رفع فاتورة جديدة
@@ -182,138 +162,94 @@ export const InvoicesPage = () => {
{/* ── 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" />
<div className="flex-1 bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-xl px-4 py-3 flex items-center gap-3">
<Search className="w-5 h-5 text-slate-500" />
<input
type="text"
placeholder="ابحث برقم الفاتورة، اسم الشركة، أو التاريخ..."
className="bg-transparent border-none outline-none flex-1 text-slate-800 text-sm"
className="bg-transparent border-none outline-none flex-1 text-slate-200 text-sm placeholder-slate-500"
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">
<button className="bg-slate-800/60 border border-slate-700/50 px-6 rounded-xl flex items-center gap-2 text-slate-300 hover:bg-slate-800 transition-all font-bold text-sm">
<Filter className="w-4 h-4" />
فلترة
</button>
</div>
{/* ── Invoices Table ───────────────────────────────────── */}
<div className="flex-1 card-premium overflow-hidden flex flex-col bg-white border border-slate-100">
<div className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-2xl overflow-hidden min-h-[400px] flex flex-col">
{isLoading ? (
<div className="flex-1 flex justify-center items-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600"></div>
<div className="flex-1 flex flex-col justify-center items-center">
<Loader2 className="w-8 h-8 text-emerald-500 animate-spin mb-4" />
<p className="text-slate-500 text-sm">جاري جلب الفواتير...</p>
</div>
) : filteredInvoices.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">
<FileText className="w-10 h-10 text-slate-300" />
<div className="w-20 h-20 bg-slate-800 rounded-2xl flex items-center justify-center mb-6 border border-slate-700">
<FileText className="w-10 h-10 text-slate-600" />
</div>
<h3 className="text-xl font-bold text-slate-900 mb-2">لا توجد فواتير بعد</h3>
<h3 className="text-xl font-bold text-white mb-2">لا توجد فواتير بعد</h3>
<p className="text-slate-500 max-w-sm mb-8">ابدأ برفع أول فاتورة ليقوم محرك الذكاء الاصطناعي باستخراج بياناتها ومصادقتها ضريبياً.</p>
<button onClick={() => setIsUploadModalOpen(true)} className="btn-primary py-3 px-8 rounded-2xl flex items-center gap-2">
<button onClick={() => setIsUploadModalOpen(true)} className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl transition-all">
ارفع فاتورتك الأولى
</button>
</div>
) : (
<div className="overflow-x-auto">
<table className="w-full text-right border-collapse">
<thead className="bg-slate-50/80 border-b border-slate-100">
<table className="w-full text-right">
<thead className="bg-slate-800/50 border-b border-slate-800/60">
<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 text-left">المجموع (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 text-center">إجراءات</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">رقم الفاتورة</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">الشركة</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">التاريخ</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400 text-left">المجموع (JOD)</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">الحالة</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400 text-center">إجراءات</th>
</tr>
</thead>
<tbody className="divide-y divide-slate-100">
<tbody className="divide-y divide-slate-800/50">
{filteredInvoices.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"
className="hover:bg-slate-800/30 transition-colors group cursor-pointer"
onClick={() => {
setViewingInvoice(inv);
setIsViewModalOpen(true);
}}
>
<td className="px-6 py-4 font-bold text-slate-900">{inv.invoice_number || '---'}</td>
<td className="px-6 py-4 text-slate-600 font-medium">
<td className="px-6 py-4 font-bold text-white">{inv.invoice_number || '---'}</td>
<td className="px-6 py-4 text-slate-400">
<div className="flex items-center gap-2">
<div className="w-7 h-7 bg-slate-100 rounded-md flex items-center justify-center">
<Building2 className="w-4 h-4 text-slate-400" />
</div>
{inv.company?.name || 'شركة غير معروفة'}
<Building2 className="w-4 h-4 text-slate-600" />
{inv.company?.name || '---'}
</div>
</td>
<td className="px-6 py-4 text-slate-500 text-sm">
{inv.invoice_date ? new Date(inv.invoice_date).toLocaleDateString('ar-JO') : '---'}
</td>
<td className="px-6 py-4 font-mono font-bold text-slate-800 text-left">
<td className="px-6 py-4 font-mono font-bold text-emerald-400 text-left">
{Number(inv.grand_total).toLocaleString('en-US', { minimumFractionDigits: 3 })}
</td>
<td className="px-6 py-4"><StatusBadge invoice={inv} /></td>
<td className="px-6 py-4 text-center relative">
<div className="flex items-center justify-center gap-2">
<td className="px-6 py-4 text-center">
<div className="flex items-center justify-center gap-2" onClick={e => e.stopPropagation()}>
<button
onClick={(e) => {
e.stopPropagation();
setViewingInvoice(inv);
setIsViewModalOpen(true);
}}
className="p-2 text-slate-400 hover:text-primary-600 hover:bg-primary-50 rounded-lg transition-all"
title="عرض الفاتورة"
onClick={() => { setViewingInvoice(inv); setIsViewModalOpen(true); }}
className="p-2 text-slate-500 hover:text-emerald-400 hover:bg-emerald-500/10 rounded-lg transition-all"
>
<Eye className="w-4 h-4" />
</button>
<div className="relative group/menu">
<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>
{/* Dropdown Menu */}
<div className="absolute left-0 mt-2 w-48 bg-white border border-slate-100 rounded-2xl shadow-xl shadow-slate-200/50 opacity-0 invisible group-hover/menu:opacity-100 group-hover/menu:visible transition-all z-10 py-2">
<button
disabled={submitLoading === inv.id}
onClick={(e) => { e.stopPropagation(); handleSubmitToJoFotara(inv); }}
className="w-full text-right px-4 py-2 text-sm text-slate-700 hover:bg-slate-50 flex items-center gap-2 disabled:opacity-50"
>
{submitLoading === inv.id ? (
<div className="w-4 h-4 border-2 border-primary-600/30 border-t-primary-600 rounded-full animate-spin" />
) : (
<Send className="w-4 h-4 text-emerald-500" />
)}
إرسال لـ جو فوترة
</button>
<button
onClick={(e) => {
e.stopPropagation();
const token = localStorage.getItem('access_token');
window.open(`${apiClient.defaults.baseURL}/invoices/${inv.id}/file?token=${token}`, '_blank');
}}
className="w-full text-right px-4 py-2 text-sm text-slate-700 hover:bg-slate-50 flex items-center gap-2"
>
<Download className="w-4 h-4 text-slate-400" />
تحميل الملف الأصلي
</button>
<div className="h-px bg-slate-100 my-1 mx-2" />
<button
disabled={deleteLoading === inv.id}
onClick={(e) => { e.stopPropagation(); handleDelete(inv.id); }}
className="w-full text-right px-4 py-2 text-sm text-red-600 hover:bg-red-50 flex items-center gap-2 disabled:opacity-50"
>
{deleteLoading === inv.id ? (
<div className="w-4 h-4 border-2 border-red-600/30 border-t-red-600 rounded-full animate-spin" />
) : (
<Trash2 className="w-4 h-4" />
)}
حذف الفاتورة
</button>
</div>
</div>
<button
onClick={() => handleDelete(inv.id)}
className="p-2 text-slate-500 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all"
>
{deleteLoading === inv.id ? <Loader2 className="w-4 h-4 animate-spin" /> : <Trash2 className="w-4 h-4" />}
</button>
</div>
</td>
</motion.tr>
@@ -325,13 +261,13 @@ export const InvoicesPage = () => {
{/* ── Pagination ───────────────────────────────────────── */}
{!isLoading && filteredInvoices.length > 0 && (
<footer className="px-6 py-4 bg-slate-50/50 border-t border-slate-100 flex items-center justify-between">
<footer className="px-6 py-4 bg-slate-800/30 border-t border-slate-800/60 flex items-center justify-between mt-auto">
<p className="text-sm text-slate-500">عرض {filteredInvoices.length} فواتير</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">
<button className="p-2 text-slate-500 hover:text-white border border-slate-700 rounded-xl bg-slate-800 transition-all">
<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">
<button className="p-2 text-slate-500 hover:text-white border border-slate-700 rounded-xl bg-slate-800 transition-all">
<ChevronLeft className="w-5 h-5" />
</button>
</div>
@@ -342,26 +278,28 @@ export const InvoicesPage = () => {
{/* ── Upload Modal ─────────────────────────────────────── */}
<AnimatePresence>
{isUploadModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-sm">
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-white rounded-[32px] p-8 w-full max-w-xl shadow-2xl overflow-hidden relative"
className="bg-slate-900 border border-slate-800 p-8 w-full max-w-xl rounded-3xl shadow-2xl relative"
>
<div className="absolute top-0 right-0 w-32 h-32 bg-primary-50 rounded-full -mr-16 -mt-16 opacity-50" />
<button onClick={() => setIsUploadModalOpen(false)} className="absolute top-6 left-6 text-slate-500 hover:text-white transition-colors">
<X className="w-6 h-6" />
</button>
<h3 className="text-2xl font-bold text-slate-900 mb-2 relative">رفع فاتورة جديدة</h3>
<p className="text-slate-500 mb-8 relative">اختر الشركة وملف الفاتورة (PDF أو صورة) وسيقوم الذكاء الاصطناعي بالباقي.</p>
<h3 className="text-2xl font-bold text-white mb-2">رفع فاتورة جديدة</h3>
<p className="text-slate-400 mb-8 text-sm">اختر الشركة وملف الفاتورة (PDF أو صورة) وسيقوم الذكاء الاصطناعي بالباقي.</p>
<form onSubmit={handleUpload} className="space-y-6 relative">
<form onSubmit={handleUpload} className="space-y-6">
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">اختر الشركة</label>
<label className="block text-sm font-bold text-slate-300 mb-2">اختر الشركة</label>
<select
required
value={selectedCompanyId}
onChange={e => setSelectedCompanyId(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 focus:ring-4 focus:ring-primary-500/10 transition-all appearance-none cursor-pointer"
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-5 py-4 outline-none focus:border-emerald-500/50 transition-all text-white appearance-none cursor-pointer"
>
<option value="">-- اختر شركة --</option>
{companies.map(c => (
@@ -371,7 +309,7 @@ export const InvoicesPage = () => {
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">ملف الفاتورة</label>
<label className="block text-sm font-bold text-slate-300 mb-2">ملف الفاتورة</label>
<div className="relative group">
<input
type="file"
@@ -380,14 +318,12 @@ export const InvoicesPage = () => {
accept=".pdf,image/*"
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer z-10"
/>
<div className="border-2 border-dashed border-slate-200 rounded-2xl p-10 flex flex-col items-center group-hover:border-primary-400 group-hover:bg-primary-50/30 transition-all bg-slate-50/50">
<div className="w-14 h-14 bg-white rounded-2xl shadow-sm flex items-center justify-center mb-4 group-hover:scale-110 transition-transform">
<Upload className="w-7 h-7 text-primary-600" />
</div>
<p className="font-bold text-slate-800">
<div className="border-2 border-dashed border-slate-700 rounded-xl p-10 flex flex-col items-center group-hover:border-emerald-500/50 group-hover:bg-emerald-500/5 transition-all bg-slate-800/50">
<Upload className="w-10 h-10 text-slate-600 mb-4 transition-colors group-hover:text-emerald-500" />
<p className="font-bold text-slate-300 text-center">
{selectedFile ? selectedFile.name : 'اسحب الملف هنا أو انقر للاختيار'}
</p>
<p className="text-sm text-slate-400 mt-1">PDF, JPG, PNG (حد أقصى 10MB)</p>
<p className="text-xs text-slate-500 mt-2">PDF, JPG, PNG (حد أقصى 10MB)</p>
</div>
</div>
</div>
@@ -396,26 +332,17 @@ export const InvoicesPage = () => {
<button
type="button"
onClick={() => setIsUploadModalOpen(false)}
className="flex-1 bg-slate-100 text-slate-700 font-bold py-4 rounded-2xl hover:bg-slate-200 transition-all"
className="flex-1 bg-slate-800 text-slate-300 font-bold py-4 rounded-xl hover:bg-slate-700 transition-all"
>
إلغاء
</button>
<button
type="submit"
disabled={isUploading || !selectedCompanyId || !selectedFile}
className="flex-[2] btn-primary py-4 rounded-2xl shadow-lg shadow-primary-500/30 disabled:opacity-50 flex items-center justify-center gap-3"
className="flex-[2] bg-emerald-500 text-slate-950 font-bold py-4 rounded-xl shadow-lg shadow-emerald-500/20 disabled:opacity-50 flex items-center justify-center gap-3 transition-all"
>
{isUploading ? (
<>
<div className="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
جاري الرفع والمعالجة...
</>
) : (
<>
<Upload className="w-5 h-5" />
ابدأ المعالجة الآن
</>
)}
{isUploading ? <Loader2 className="w-5 h-5 animate-spin" /> : <Upload className="w-5 h-5" />}
{isUploading ? 'جاري المعالجة...' : 'ابدأ المعالجة الآن'}
</button>
</div>
</form>
@@ -423,61 +350,45 @@ export const InvoicesPage = () => {
</div>
)}
</AnimatePresence>
{/* ── View Invoice Modal ─────────────────────────────────── */}
<AnimatePresence>
{isViewModalOpen && viewingInvoice && (
<div className="fixed inset-0 z-[60] flex items-center justify-center p-4 bg-slate-900/80 backdrop-blur-md">
<div className="fixed inset-0 z-[60] flex items-center justify-center p-4 bg-slate-950/90 backdrop-blur-md">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
initial={{ scale: 0.95, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-white rounded-[40px] w-full max-w-5xl h-[90vh] shadow-2xl flex flex-col overflow-hidden"
exit={{ scale: 0.95, opacity: 0 }}
className="bg-slate-900 border border-slate-800 w-full max-w-5xl h-[90vh] rounded-[32px] shadow-2xl flex flex-col overflow-hidden"
>
<header className="px-8 py-6 border-b border-slate-100 flex items-center justify-between bg-white">
<header className="px-8 py-6 border-b border-slate-800 flex items-center justify-between">
<div>
<h3 className="text-2xl font-bold text-slate-900">معاينة الفاتورة</h3>
<p className="text-slate-500 font-medium">رقم: {viewingInvoice.invoice_number || '---'} {viewingInvoice.company?.name}</p>
<h3 className="text-2xl font-bold text-white">معاينة الفاتورة</h3>
<p className="text-slate-500 text-sm">رقم: {viewingInvoice.invoice_number || '---'} {viewingInvoice.company?.name}</p>
</div>
<button
onClick={() => setIsViewModalOpen(false)}
className="w-12 h-12 flex items-center justify-center rounded-2xl bg-slate-50 text-slate-400 hover:bg-slate-100 hover:text-slate-600 transition-all"
className="w-10 h-10 flex items-center justify-center rounded-xl bg-slate-800 text-slate-500 hover:text-white transition-all"
>
<ChevronLeft className="w-6 h-6 rotate-180" />
<X className="w-6 h-6" />
</button>
</header>
{viewingInvoice.validation_errors && viewingInvoice.validation_errors.length > 0 && (
<div className="px-8 py-4 bg-red-50 border-b border-red-100 flex items-start gap-3">
<AlertCircle className="w-5 h-5 text-red-600 mt-0.5 shrink-0" />
<div>
<h4 className="text-sm font-bold text-red-900 mb-1">فشل التحقق الضريبي:</h4>
<ul className="text-xs text-red-700 space-y-1 list-disc list-inside">
{viewingInvoice.validation_errors.map((err: string, i: number) => (
<li key={i}>{err}</li>
))}
</ul>
</div>
</div>
)}
<div className="flex-1 overflow-auto bg-slate-100 p-8 flex justify-center items-start">
<div className="bg-white shadow-2xl rounded-sm overflow-hidden max-w-full">
<div className="flex-1 overflow-auto bg-slate-950 p-8 flex justify-center items-start">
<div className="bg-white rounded-lg overflow-hidden shadow-2xl">
<img
src={`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${localStorage.getItem('access_token')}`}
alt="Invoice"
className="max-w-full h-auto"
onError={(e) => {
// Fallback for PDF or Error
e.currentTarget.style.display = 'none';
const token = localStorage.getItem('access_token');
e.currentTarget.parentElement!.innerHTML = `
<div class="p-20 text-center">
<div class="w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mx-auto mb-4 border border-slate-200">
<svg class="w-10 h-10 text-slate-300" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>
</div>
<h4 class="text-xl font-bold text-slate-900 mb-2">تعذر عرض الصورة مباشرة</h4>
<p class="text-slate-500 mb-6">قد يكون الملف بتنسيق PDF أو حدث خطأ أثناء التحميل.</p>
<a href="${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${token}" target="_blank" class="btn-primary px-8 py-3 rounded-xl inline-block">فتح الملف في نافذة جديدة</a>
<div class="p-20 text-center bg-slate-900 text-slate-300 w-[600px]">
<FileText class="w-16 h-16 text-slate-700 mx-auto mb-4" />
<h4 class="text-xl font-bold text-white mb-2">تعذر عرض الملف</h4>
<p class="text-slate-500 mb-8">قد يكون الملف PDF أو حدث خطأ في التحميل.</p>
<a href="${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${token}" target="_blank" class="px-8 py-3 bg-emerald-500 text-slate-950 font-bold rounded-xl inline-block">تحميل الملف لفتحه</a>
</div>
`;
}}
@@ -485,15 +396,15 @@ export const InvoicesPage = () => {
</div>
</div>
<footer className="px-8 py-6 border-t border-slate-100 flex items-center justify-between bg-slate-50/50">
<div className="flex items-center gap-6">
<footer className="px-8 py-6 border-t border-slate-800 bg-slate-900/50 flex items-center justify-between">
<div className="flex items-center gap-8">
<div>
<p className="text-[10px] uppercase tracking-widest text-slate-400 font-bold mb-1">المجموع الكلي</p>
<p className="text-xl font-black text-primary-700">{Number(viewingInvoice.grand_total).toLocaleString('en-US', { minimumFractionDigits: 3 })} JOD</p>
<p className="text-[10px] uppercase tracking-widest text-slate-500 font-bold mb-1">المجموع الكلي</p>
<p className="text-xl font-black text-emerald-400">{Number(viewingInvoice.grand_total).toLocaleString('en-US', { minimumFractionDigits: 3 })} JOD</p>
</div>
<div className="w-px h-10 bg-slate-200" />
<div className="w-px h-10 bg-slate-800" />
<div>
<p className="text-[10px] uppercase tracking-widest text-slate-400 font-bold mb-1">الحالة</p>
<p className="text-[10px] uppercase tracking-widest text-slate-500 font-bold mb-1">الحالة</p>
<StatusBadge invoice={viewingInvoice} />
</div>
</div>
@@ -503,19 +414,16 @@ export const InvoicesPage = () => {
const token = localStorage.getItem('access_token');
window.open(`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${token}`, '_blank');
}}
className="px-6 py-3 rounded-xl bg-white border border-slate-200 text-slate-700 font-bold flex items-center gap-2 hover:bg-slate-50 transition-all shadow-sm"
className="px-6 py-3 rounded-xl bg-slate-800 border border-slate-700 text-slate-300 font-bold flex items-center gap-2 hover:bg-slate-700 transition-all"
>
<Download className="w-4 h-4" />
تحميل الأصلي
تحميل
</button>
<button
onClick={() => {
setIsViewModalOpen(false);
handleSubmitToJoFotara(viewingInvoice);
}}
className="btn-primary px-8 py-3 rounded-xl flex items-center gap-2 shadow-lg shadow-primary-500/20"
onClick={() => handleSubmitToJoFotara(viewingInvoice)}
className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold px-8 py-3 rounded-xl flex items-center gap-2 shadow-lg shadow-emerald-500/20 transition-all"
>
<Send className="w-4 h-4" />
{submitLoading === viewingInvoice.id ? <Loader2 className="w-5 h-5 animate-spin" /> : <Send className="w-4 h-4" />}
إرسال لجو فوترة
</button>
</div>

View File

@@ -1,147 +1,142 @@
/**
* ════════════════════════════════════════════════════════════
* مُصادَق (Musadaq) — Settings Page
* مُصادَق (Musadaq) — Settings Page (Premium Dark)
* ════════════════════════════════════════════════════════════
*/
import { useState, useEffect } from 'react';
import { Building, Save, Shield, Globe } from 'lucide-react';
import apiClient from '../../api/client';
import { useState } from 'react';
import {
Settings,
User,
Lock,
Bell,
Globe,
Shield,
CreditCard,
Save,
ChevronLeft,
Palette,
Moon
} from 'lucide-react';
import { motion } from 'framer-motion';
export const SettingsPage = () => {
const [isSaving, setIsSaving] = useState(false);
// Tenant Profile State
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [phone, setPhone] = useState('');
const [address, setAddress] = useState('');
const [activeTab, setActiveTab] = useState('profile');
const fetchSettings = async () => {
try {
// Get current tenant info (usually from a profile or me endpoint)
const { data } = await apiClient.get('/auth/me'); // Assuming there's a me endpoint for the tenant
setName(data.tenant.name || '');
setEmail(data.tenant.email || '');
// phone and address might be null
} catch (error) {
console.error('Failed to fetch settings', error);
}
};
useEffect(() => {
fetchSettings();
}, []);
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
setIsSaving(true);
try {
// await apiClient.put('/tenants/profile', { name, email, phone, address });
alert('تم حفظ الإعدادات بنجاح');
} catch (error) {
alert('فشل حفظ الإعدادات');
} finally {
setIsSaving(false);
}
};
const tabs = [
{ id: 'profile', label: 'الملف الشخصي', icon: User },
{ id: 'security', label: 'الأمان والخصوصية', icon: Lock },
{ id: 'office', label: 'إعدادات المكتب', icon: Settings },
{ id: 'notifications', label: 'التنبيهات', icon: Bell },
{ id: 'appearance', label: 'المظهر والنظام', icon: Palette },
{ id: 'subscription', label: 'الاشتراك والدفع', icon: CreditCard },
];
return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700 max-w-4xl">
<div className="space-y-8 animate-in fade-in duration-700">
<header>
<h2 className="text-3xl font-bold text-slate-900 tracking-tight">إعدادات المكتب</h2>
<p className="text-slate-500 mt-1 font-medium">إدارة الملف الشخصي لمكتب المحاسبة الخاص بك.</p>
<h2 className="text-3xl font-black text-white">إعدادات النظام</h2>
<p className="text-slate-400 mt-1">تخصيص حسابك وتفضيلات مكتب المحاسبة الخاص بك.</p>
</header>
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
{/* ── Tabs/Navigation ──────────────────────────────── */}
<div className="space-y-2">
<button className="w-full text-right px-6 py-4 rounded-2xl bg-primary-50 text-primary-600 font-bold flex items-center gap-3 border border-primary-100 shadow-sm">
<Building className="w-5 h-5" />
الملف الشخصي
</button>
<button className="w-full text-right px-6 py-4 rounded-2xl text-slate-500 font-bold flex items-center gap-3 hover:bg-slate-50 transition-all">
<Shield className="w-5 h-5" />
الأمان والوصول
</button>
<button className="w-full text-right px-6 py-4 rounded-2xl text-slate-500 font-bold flex items-center gap-3 hover:bg-slate-50 transition-all">
<Globe className="w-5 h-5" />
تخصيص النظام
</button>
</div>
<div className="flex flex-col lg:flex-row gap-8">
{/* ── Tabs Sidebar ─────────────────────────── */}
<aside className="w-full lg:w-72 space-y-2">
{tabs.map((tab) => {
const Icon = tab.icon;
const isActive = activeTab === tab.id;
return (
<button
key={tab.id}
onClick={() => setActiveTab(tab.id)}
className={`w-full flex items-center gap-3 px-6 py-4 rounded-xl font-bold transition-all ${
isActive
? 'bg-emerald-500 text-slate-950 shadow-lg shadow-emerald-500/20'
: 'text-slate-400 hover:bg-slate-800/50 hover:text-white'
}`}
>
<Icon className={`w-5 h-5 ${isActive ? 'text-slate-950' : 'text-slate-500'}`} />
{tab.label}
</button>
);
})}
</aside>
{/* ── Form Content ─────────────────────────────────── */}
<div className="md:col-span-2 space-y-6">
<div className="card-premium p-8 border border-slate-100 bg-white">
<form onSubmit={handleSave} className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">اسم مكتب المحاسبة</label>
<input
type="text"
value={name}
onChange={e => setName(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
/>
{/* ── Content Area ─────────────────────────── */}
<main className="flex-1 bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-[32px] overflow-hidden flex flex-col min-h-[600px]">
<div className="p-10 flex-1">
{activeTab === 'profile' && (
<motion.div initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} className="space-y-8">
<div className="flex items-center gap-6 pb-8 border-b border-slate-800/60">
<div className="w-24 h-24 rounded-3xl bg-gradient-to-br from-emerald-500 to-emerald-600 flex items-center justify-center text-4xl font-black text-slate-950 shadow-xl shadow-emerald-500/20">
H
</div>
<div>
<h3 className="text-2xl font-bold text-white mb-2">حمزة الغويريين</h3>
<p className="text-slate-500 font-medium">مدير مكتب حساب احترافي</p>
</div>
<button className="mr-auto bg-slate-800 hover:bg-slate-700 text-white px-6 py-2 rounded-xl text-sm font-bold transition-all">
تغيير الصورة
</button>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">البريد الإلكتروني الرسمي</label>
<input
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
/>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2">
<label className="text-sm font-bold text-slate-400 mr-1">الاسم الكامل</label>
<input type="text" defaultValue="حمزة الغويريين" className="w-full bg-slate-800 border border-slate-700 rounded-xl px-5 py-3 text-white outline-none focus:border-emerald-500/50 transition-all" />
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-slate-400 mr-1">البريد الإلكتروني</label>
<input type="email" defaultValue="hamza@musadaq.jo" className="w-full bg-slate-800 border border-slate-700 rounded-xl px-5 py-3 text-white outline-none focus:border-emerald-500/50 transition-all" />
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-slate-400 mr-1">رقم الهاتف</label>
<input type="text" defaultValue="+962 79 000 0000" className="w-full bg-slate-800 border border-slate-700 rounded-xl px-5 py-3 text-white outline-none focus:border-emerald-500/50 transition-all" />
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-slate-400 mr-1">اللغة المفضلة</label>
<select className="w-full bg-slate-800 border border-slate-700 rounded-xl px-5 py-3 text-white outline-none focus:border-emerald-500/50 transition-all appearance-none cursor-pointer">
<option>العربية</option>
<option>English</option>
</select>
</div>
</div>
</div>
</motion.div>
)}
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">رقم الهاتف</label>
<input
type="text"
value={phone}
onChange={e => setPhone(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
placeholder="+962 7X XXX XXXX"
/>
</div>
{activeTab === 'appearance' && (
<motion.div initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} className="space-y-8">
<h3 className="text-2xl font-bold text-white mb-6">المظهر والنظام</h3>
<div className="grid grid-cols-2 gap-6">
<div className="p-6 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex flex-col items-center gap-4 cursor-pointer">
<Moon className="w-12 h-12 text-emerald-500" />
<span className="font-bold text-white">الوضع الداكن (مفعل)</span>
</div>
<div className="p-6 rounded-2xl bg-slate-800/30 border border-slate-700 flex flex-col items-center gap-4 opacity-50 cursor-not-allowed">
<div className="w-12 h-12 bg-white rounded-full" />
<span className="font-bold text-slate-500">الوضع الفاتح</span>
</div>
</div>
</motion.div>
)}
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">عنوان المكتب</label>
<textarea
rows={3}
value={address}
onChange={e => setAddress(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all resize-none"
placeholder="مثال: عمان، العبدلي، برج السلام"
/>
{(activeTab !== 'profile' && activeTab !== 'appearance') && (
<div className="flex flex-col items-center justify-center h-full text-center">
<Shield className="w-16 h-16 text-slate-800 mb-6" />
<h3 className="text-xl font-bold text-slate-500">هذه الصفحة قيد التطوير</h3>
<p className="text-slate-600 max-w-xs mt-2 text-sm">نحن نعمل على توفير المزيد من خيارات التخصيص والأمان قريباً.</p>
</div>
<div className="pt-4 flex justify-end">
<button
type="submit"
disabled={isSaving}
className="btn-primary py-4 px-10 rounded-2xl shadow-xl shadow-primary-500/20 flex items-center gap-3 disabled:opacity-50"
>
{isSaving ? (
<div className="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
) : (
<Save className="w-5 h-5" />
)}
حفظ التغييرات
</button>
</div>
</form>
)}
</div>
<div className="card-premium p-8 border border-red-100 bg-red-50/30">
<h4 className="text-red-600 font-bold mb-2">منطقة الخطر</h4>
<p className="text-sm text-slate-500 mb-6">حذف حساب المكتب سيؤدي إلى مسح جميع بيانات الشركات والفواتير بشكل نهائي.</p>
<button className="px-6 py-3 rounded-xl border border-red-200 text-red-600 font-bold hover:bg-red-50 transition-all">
إلغاء الاشتراك وحذف الحساب
<footer className="px-10 py-6 border-t border-slate-800/60 bg-slate-900/30 flex items-center justify-between">
<p className="text-xs text-slate-500">آخر تحديث: 22 أبريل 2026</p>
<button className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-black px-10 py-3 rounded-xl flex items-center gap-2 shadow-lg shadow-emerald-500/20 transition-all active:scale-95">
<Save className="w-5 h-5" />
حفظ التغييرات
</button>
</div>
</div>
</footer>
</main>
</div>
</div>
);

View File

@@ -1,31 +1,30 @@
/**
* ════════════════════════════════════════════════════════════
* مُصادَق (Musadaq) — Staff Management Page
* مُصادَق (Musadaq) — Staff Management Page (Premium Dark)
* ════════════════════════════════════════════════════════════
*/
import { useState, useEffect } from 'react';
import { Users, UserPlus, Mail, Power } from 'lucide-react';
import { Users, UserPlus, Search, Shield, Mail, Phone, MoreVertical, Trash2, Loader2, X } from 'lucide-react';
import { motion, AnimatePresence } from 'framer-motion';
import apiClient from '../../api/client';
import { useAuthStore } from '../../store/authStore';
export const StaffPage = () => {
const currentUser = useAuthStore((state) => state.user);
const [staff, setStaff] = useState<any[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [searchTerm, setSearchTerm] = useState('');
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
// Form State
const [fullName, setFullName] = useState('');
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [role, setRole] = useState('accountant');
const [role, setRole] = useState('manager');
const [isSubmitting, setIsSubmitting] = useState(false);
const fetchStaff = async () => {
setIsLoading(true);
try {
const { data } = await apiClient.get('/users');
const { data } = await apiClient.get('/staff');
setStaff(data);
} catch (error) {
console.error('Failed to fetch staff', error);
@@ -38,172 +37,225 @@ export const StaffPage = () => {
fetchStaff();
}, []);
const handleAddStaff = async (e: React.FormEvent) => {
const handleCreateStaff = async (e: React.FormEvent) => {
e.preventDefault();
setIsSubmitting(true);
try {
await apiClient.post('/users', {
name: fullName,
email,
password,
role
});
await apiClient.post('/staff', { name, email, password, role });
setIsAddModalOpen(false);
setFullName('');
setName('');
setEmail('');
setPassword('');
fetchStaff();
} catch (error: any) {
alert(error.response?.data?.message || 'فشل إضافة الموظف');
} catch (error) {
console.error('Failed to create staff', error);
alert('حدث خطأ أثناء إضافة الموظف');
} finally {
setIsSubmitting(false);
}
};
const toggleStatus = async (id: string) => {
const handleDelete = async (id: string) => {
if (!confirm('هل أنت متأكد من حذف هذا الموظف؟')) return;
try {
await apiClient.delete(`/users/${id}`);
await apiClient.post(`/staff/${id}/delete`);
fetchStaff();
} catch (error) {
alert('فشل تغيير حالة الموظف');
alert('فشل حذف الموظف');
}
};
const filteredStaff = staff.filter(s =>
s.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
s.email.toLowerCase().includes(searchTerm.toLowerCase())
);
return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-700">
<div className="space-y-8 animate-in fade-in duration-700">
<header className="flex items-center justify-between">
<div>
<h2 className="text-3xl font-bold text-slate-900 tracking-tight">إدارة الموظفين</h2>
<p className="text-slate-500 mt-1 font-medium">إدارة المحاسبين والمديرين في مكتبك.</p>
<h2 className="text-3xl font-black text-white">إدارة الموظفين</h2>
<p className="text-slate-400 mt-1">إدارة فريق العمل المالي لمكتب المحاسبة الخاص بك.</p>
</div>
<button
onClick={() => setIsAddModalOpen(true)}
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"
className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl flex items-center gap-2 shadow-lg shadow-emerald-500/20 transition-all active:scale-95"
>
<UserPlus className="w-5 h-5" />
إضافة موظف جديد
</button>
</header>
{isLoading ? (
<div className="flex justify-center p-20">
<div className="animate-spin rounded-full h-10 w-10 border-b-2 border-primary-600"></div>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{staff.map((member) => (
<motion.div
key={member.id}
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
className="card-premium p-6 group hover:border-primary-200 transition-all border border-slate-100"
>
<div className="flex justify-between items-start mb-6">
<div className="w-14 h-14 rounded-2xl bg-slate-50 text-slate-400 flex items-center justify-center group-hover:bg-primary-50 group-hover:text-primary-600 transition-all">
<Users className="w-7 h-7" />
</div>
<div className="flex gap-2">
{member.id !== currentUser?.id && (
<button
onClick={() => toggleStatus(member.id)}
className={`p-2 rounded-xl transition-all ${member.is_active ? 'text-emerald-500 bg-emerald-50' : 'text-slate-400 bg-slate-50'}`}
title={member.is_active ? 'تعطيل الحساب' : 'تفعيل الحساب'}
>
<Power className="w-4 h-4" />
</button>
)}
</div>
</div>
<h3 className="text-xl font-bold text-slate-900 mb-1">{member.name}</h3>
<div className="flex items-center gap-2 mb-6">
<span className={`text-[10px] font-black uppercase tracking-widest px-2 py-0.5 rounded-md ${
member.role === 'admin' ? 'bg-indigo-50 text-indigo-600' : 'bg-slate-50 text-slate-600'
}`}>
{member.role === 'admin' ? 'مدير نظام' : 'محاسب'}
</span>
</div>
{/* ── Search Bar ──────────────────────────────── */}
<div className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-xl px-4 py-3 flex items-center gap-3">
<Search className="w-5 h-5 text-slate-500" />
<input
type="text"
placeholder="ابحث بالاسم أو البريد الإلكتروني..."
className="bg-transparent border-none outline-none flex-1 text-slate-200 text-sm placeholder-slate-500"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
</div>
<div className="space-y-3">
<div className="flex items-center gap-3 text-sm text-slate-500">
<Mail className="w-4 h-4" />
{member.email}
</div>
</div>
</motion.div>
))}
</div>
)}
{/* ── Staff List ───────────────────────────────────── */}
<div className="bg-slate-900/50 backdrop-blur-xl border border-slate-800/60 rounded-2xl overflow-hidden min-h-[400px] flex flex-col">
{isLoading ? (
<div className="flex-1 flex flex-col justify-center items-center">
<Loader2 className="w-8 h-8 text-emerald-500 animate-spin mb-4" />
<p className="text-slate-500">جاري جلب بيانات الفريق...</p>
</div>
) : filteredStaff.length === 0 ? (
<div className="flex-1 flex flex-col items-center justify-center p-20 text-center">
<div className="w-20 h-20 bg-slate-800 rounded-2xl flex items-center justify-center mb-6 border border-slate-700">
<Users className="w-10 h-10 text-slate-600" />
</div>
<h3 className="text-xl font-bold text-white mb-2">لا يوجد موظفون مضافون</h3>
<p className="text-slate-500 max-w-sm mb-8">يمكنك إضافة موظفين لمساعدتك في إدارة ومعالجة فواتير الشركات.</p>
<button onClick={() => setIsAddModalOpen(true)} className="bg-emerald-500 hover:bg-emerald-600 text-slate-950 font-bold py-3 px-8 rounded-xl transition-all">
إضافة أول موظف
</button>
</div>
) : (
<div className="overflow-x-auto">
<table className="w-full text-right">
<thead className="bg-slate-800/50 border-b border-slate-800/60">
<tr>
<th className="px-6 py-4 text-xs font-bold text-slate-400">الاسم الكامل</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">البريد الإلكتروني</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400">الدور الوظيفي</th>
<th className="px-6 py-4 text-xs font-bold text-slate-400 text-center">إجراءات</th>
</tr>
</thead>
<tbody className="divide-y divide-slate-800/50">
{filteredStaff.map((s, idx) => (
<motion.tr
key={s.id}
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay: idx * 0.05 }}
className="hover:bg-slate-800/30 transition-colors"
>
<td className="px-6 py-4 font-bold text-white">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-slate-700 to-slate-800 flex items-center justify-center text-slate-300 font-black border border-slate-700">
{s.name[0]}
</div>
{s.name}
</div>
</td>
<td className="px-6 py-4 text-slate-400">
<div className="flex items-center gap-2">
<Mail className="w-4 h-4 text-slate-600" />
{s.email}
</div>
</td>
<td className="px-6 py-4">
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-md text-[10px] font-bold border ${
s.role === 'admin'
? 'text-emerald-400 bg-emerald-400/5 border-emerald-400/20'
: 'text-blue-400 bg-blue-400/5 border-blue-400/20'
} uppercase tracking-widest`}>
<Shield className="w-3 h-3" />
{s.role === 'admin' ? 'مدير نظام' : 'محاسب'}
</span>
</td>
<td className="px-6 py-4 text-center">
<div className="flex items-center justify-center gap-2">
<button className="p-2 text-slate-500 hover:text-white transition-colors">
<MoreVertical className="w-4 h-4" />
</button>
<button
onClick={() => handleDelete(s.id)}
className="p-2 text-slate-500 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all"
>
<Trash2 className="w-4 h-4" />
</button>
</div>
</td>
</motion.tr>
))}
</tbody>
</table>
</div>
)}
</div>
{/* ── Add Staff Modal ─────────────────────────────────── */}
{/* ── Add Staff Modal ─────────────────────────────────── */}
<AnimatePresence>
{isAddModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-sm">
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-white rounded-[32px] p-8 w-full max-w-md shadow-2xl relative"
className="bg-slate-900 border border-slate-800 p-8 w-full max-w-md rounded-3xl shadow-2xl relative"
>
<h3 className="text-2xl font-bold text-slate-900 mb-2">إضافة موظف جديد</h3>
<p className="text-slate-500 mb-8">سيتمكن الموظف من الدخول لمكتبك ومساعدة الشركات.</p>
<form onSubmit={handleAddStaff} className="space-y-5">
<button onClick={() => setIsAddModalOpen(false)} className="absolute top-6 left-6 text-slate-500 hover:text-white transition-colors">
<X className="w-6 h-6" />
</button>
<h3 className="text-2xl font-bold text-white mb-6">إضافة موظف جديد</h3>
<form onSubmit={handleCreateStaff} className="space-y-5">
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">الاسم الكامل</label>
<label className="block text-sm font-bold text-slate-400 mb-2">الاسم الكامل</label>
<input
type="text"
required
value={fullName}
onChange={e => setFullName(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
value={name}
onChange={e => setName(e.target.value)}
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white placeholder-slate-600"
placeholder="مثال: أحمد محمد"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">البريد الإلكتروني</label>
<label className="block text-sm font-bold text-slate-400 mb-2">البريد الإلكتروني</label>
<input
type="email"
required
value={email}
onChange={e => setEmail(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
placeholder="email@example.com"
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white placeholder-slate-600"
placeholder="ahmed@office.com"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">كلمة المرور المؤقتة</label>
<label className="block text-sm font-bold text-slate-400 mb-2">كلمة المرور المؤقتة</label>
<input
type="password"
required
value={password}
onChange={e => setPassword(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all"
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white placeholder-slate-600"
placeholder="••••••••"
/>
</div>
<div>
<label className="block text-sm font-bold text-slate-700 mb-2">الصلاحية</label>
<label className="block text-sm font-bold text-slate-400 mb-2">الدور الوظيفي</label>
<select
value={role}
onChange={e => setRole(e.target.value)}
className="w-full bg-slate-50 border border-slate-200 rounded-2xl px-5 py-4 outline-none focus:border-primary-500 transition-all appearance-none"
className="w-full bg-slate-800 border border-slate-700 rounded-xl px-4 py-3 outline-none focus:border-emerald-500/50 transition-all text-white appearance-none cursor-pointer"
>
<option value="accountant">محاسب</option>
<option value="admin">مدير نظام</option>
<option value="manager">محاسب (عرض ومعالجة)</option>
<option value="admin">مدير نظام (صلاحيات كاملة)</option>
</select>
</div>
<div className="flex gap-4 pt-4">
<button
type="button"
onClick={() => setIsAddModalOpen(false)}
className="flex-1 bg-slate-100 text-slate-700 font-bold py-4 rounded-2xl hover:bg-slate-200 transition-all"
className="flex-1 bg-slate-800 text-slate-400 font-bold py-3 rounded-xl hover:bg-slate-700 transition-all"
>
إلغاء
</button>
<button
type="submit"
className="flex-[2] btn-primary py-4 rounded-2xl shadow-lg shadow-primary-500/30"
disabled={isSubmitting}
className="flex-1 bg-emerald-500 text-slate-950 font-bold py-3 rounded-xl shadow-lg shadow-emerald-500/20 flex items-center justify-center gap-2 transition-all"
>
حفظ وإضافة
{isSubmitting && <Loader2 className="w-4 h-4 animate-spin" />}
حفظ البيانات
</button>
</div>
</form>