// DocumentsView.jsx — Document Analysis + Creation function useEntrance(delay = 0) { const [ready, setReady] = React.useState(false); React.useEffect(() => { const t = setTimeout(() => setReady(true), delay + 30); return () => clearTimeout(t); }, []); return { opacity: ready ? 1 : 0, transform: ready ? 'none' : 'translateY(18px)', transition: `opacity 0.45s ease, transform 0.45s ease` }; } const DOC_TYPES = [ { id: 'employment', label: 'عقد عمل', icon: '👤' }, { id: 'lease', label: 'عقد إيجار', icon: '🏢' }, { id: 'nda', label: 'اتفاقية سرية', icon: '🔒' }, { id: 'partnership', label: 'عقد شراكة', icon: '🤝' }, { id: 'poa', label: 'توكيل رسمي', icon: '📋' }, { id: 'service', label: 'عقد خدمات', icon: '⚙' }, ]; const ANALYSIS_FINDINGS = [ { level: 'error', art: 'المادة ٤٥', text: 'بند الإنهاء المبكر يفتقر لآلية تعويض واضحة' }, { level: 'error', art: 'المادة ١٢', text: 'غياب آلية فض النزاعات المحددة' }, { level: 'warning', art: 'المادة ٧', text: 'مدة الإيجار (٧ سنوات) تتجاوز الحد المعتاد' }, { level: 'warning', art: 'المادة ٢٣', text: 'بند التحكيم لا يحدد الجهة المختصة' }, { level: 'success', art: 'المادة ٣', text: 'شروط الضمان متوافقة مع اشتراطات النظام' }, { level: 'success', art: 'المادة ١٩', text: 'التوقيع الرقمي معترف به وفق نظام التقنية' }, { level: 'info', art: '', text: 'يُنصح بمراجعة بند الزيادة السنوية في الإيجار' }, ]; const LEVEL_META = { error: { dot: '#b53333', bg: '#f7e5e5', text: '#b53333', label: 'مخاطرة عالية' }, warning: { dot: '#a05e1a', bg: '#fef3e2', text: '#a05e1a', label: 'يحتاج مراجعة' }, success: { dot: '#2d7a4f', bg: '#e0f2ea', text: '#2d7a4f', label: 'متوافق' }, info: { dot: '#3898ec', bg: '#deeefb', text: '#3898ec', label: 'ملاحظة' }, }; function DocumentsView() { const [tab, setTab] = React.useState('analyze'); // 'analyze' | 'create' // Analysis state const [uploadState, setUploadState] = React.useState('idle'); // idle | analyzing | done const [progress, setProgress] = React.useState(0); // Creation state const [docType, setDocType] = React.useState(null); const [creating, setCreating] = React.useState(false); const [created, setCreated] = React.useState(false); const [form, setForm] = React.useState({ party1: '', party2: '', duration: '', notes: '' }); const entrance = useEntrance(); const startAnalysis = () => { setUploadState('analyzing'); setProgress(0); const iv = setInterval(() => { setProgress(p => { if (p >= 100) { clearInterval(iv); setUploadState('done'); return 100; } return p + 4; }); }, 90); }; const handleCreate = async () => { if (!docType) return; setCreating(true); await new Promise(r => setTimeout(r, 1800)); setCreating(false); setCreated(true); }; const counts = { error: ANALYSIS_FINDINGS.filter(f => f.level === 'error').length, warning: ANALYSIS_FINDINGS.filter(f => f.level === 'warning').length, success: ANALYSIS_FINDINGS.filter(f => f.level === 'success').length, }; return (
حلّل مستندك الحالي أو أنشئ مستنداً قانونياً جاهزاً
تم إبرام هذا العقد بين طرفين: {form.party1 || 'الطرف الأول'} (الطرف الأول) و{form.party2 || 'الطرف الثاني'} (الطرف الثاني)، وذلك للمدة المتفق عليها: {form.duration || 'حسب الاتفاق'}. يلتزم الطرفان بكافة الشروط والأحكام المنصوص عليها في هذا العقد، وبما لا يتعارض مع أحكام الشريعة الإسلامية والأنظمة المعمول بها في المملكة العربية السعودية.
... (يستمر النص القانوني الكامل في الملف المحمّل)