'use client'; import { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { FileText, Shield, CheckCircle, Languages, Loader2, AlertCircle } from 'lucide-react'; import { getARTerms, getENTerms } from '../utils/api'; const containerVariants = { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.08 }, }, }; const itemVariants = { hidden: { opacity: 0, y: 24 }, visible: { opacity: 1, y: 0 }, }; const FALLBACK_TERMS = { ar: [ { title: 'مقدمة', description: 'مرحباً بك في منصة SweetHome. باستخدامك للمنصة، فإنك توافق على الالتزام بشروط الاستخدام هذه. إذا كنت لا توافق على أي جزء من هذه الشروط، يرجى عدم استخدام المنصة.', }, { title: 'استخدام المنصة', description: 'يُسمح باستخدام المنصة للأغراض المشروعة فقط. يلتزم المستخدم بعدم استخدام المنصة في أي نشاط غير قانوني.', }, { title: 'حقوق ومسؤوليات المالك', description: 'يتحمل المالك مسؤولية دقة المعلومات المقدمة عن العقار بما في ذلك الصور والوصف والسعر والتوفر.', }, { title: 'حقوق ومسؤوليات المستأجر', description: 'يلتزم المستأجر باستخدام العقار بطريقة مسؤولة وعدم التسبب في أي ضرر للممتلكات.', }, { title: 'الدفع والعمولات', description: 'تتقاضى المنصة عمولة على كل حصة ناجحة وفقاً للنسبة المحددة في وقت الحجز.', }, { title: 'خصوصية البيانات', description: 'نحن نأخذ خصوصية بياناتك على محمل الجد. يتم جمع واستخدام البيانات الشخصية وفقاً لسياسة الخصوصية الخاصة بنا.', }, ], en: [ { title: 'Introduction', description: 'Welcome to SweetHome. By using our platform, you agree to comply with these terms. If you do not agree, please do not use the platform.', }, { title: 'Platform Usage', description: 'The platform may only be used for lawful purposes. Users must not engage in any illegal activity.', }, { title: 'Owner Rights & Responsibilities', description: 'Owners are responsible for the accuracy of property information including images, description, price, and availability.', }, { title: 'Tenant Rights & Responsibilities', description: 'Tenants must use the property responsibly and not cause any damage to the property.', }, { title: 'Payment & Commissions', description: 'The platform charges a commission on each successful booking according to the rate specified at the time of booking.', }, { title: 'Data Privacy', description: 'We take your data privacy seriously. Personal data is collected and used in accordance with our Privacy Policy.', }, ], }; export default function TermsPage() { const [terms, setTerms] = useState([]); const [language, setLanguage] = useState('ar'); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); useEffect(() => { const controller = new AbortController(); const fetchTerms = async () => { try { setLoading(true); setError(''); const fetcher = language === 'ar' ? getARTerms : getENTerms; const data = await fetcher(); if (!data) { setTerms(FALLBACK_TERMS[language]); return; } const raw = Array.isArray(data) ? data : data.terms || data.items || data.data || []; if (!Array.isArray(raw) || raw.length === 0) { setTerms(FALLBACK_TERMS[language]); return; } const mapped = raw.map((item) => ({ title: item.title || item.name || '', description: item.description || item.content || item.body || item.text || '', })); setTerms(mapped); } catch { setTerms(FALLBACK_TERMS[language]); setError(''); } finally { setLoading(false); } }; fetchTerms(); return () => controller.abort(); }, [language]); return (
{language === 'ar' ? 'يرجى قراءة شروط الاستخدام التالية بعناية قبل استخدام المنصة' : 'Please read the following terms of use carefully before using the platform'}
{language === 'ar' ? 'لا توجد شروط استخدام متاحة حالياً' : 'No terms of use available'}
{term.description}
{language === 'ar' ? 'آخر تحديث' : 'Last Updated'}
{language === 'ar' ? 'تم آخر تحديث لشروط الاستخدام في 1 مايو 2026. يرجى مراجعة هذه الصفحة بشكل دوري للاطلاع على أي تغييرات.' : 'Last updated on May 1, 2026. Please review this page periodically for any changes.'}