// 'use client';
// import { useState } from 'react';
// import { useRouter } from 'next/navigation';
// import Link from 'next/link';
// import { motion } from 'framer-motion';
// import {
// User,
// Shield,
// Trash2,
// LogOut,
// ChevronLeft,
// Bell,
// Lock,
// Eye,
// FileText,
// HelpCircle,
// MessageCircle,
// Loader2,
// AlertTriangle,
// X
// } from 'lucide-react';
// import toast, { Toaster } from 'react-hot-toast';
// import AuthService from '../services/AuthService';
// import { changePassword, deleteMyAccount } from '../utils/api';
// export default function SettingsPage() {
// const router = useRouter();
// const [showDeleteDialog, setShowDeleteDialog] = useState(false);
// const [deletePassword, setDeletePassword] = useState('');
// const [isDeleting, setIsDeleting] = useState(false);
// const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
// const handleSignOut = () => {
// AuthService.deleteToken();
// toast.success('تم تسجيل الخروج بنجاح');
// router.push('/');
// };
// const handleDeleteAccount = async () => {
// if (!deletePassword) {
// toast.error('الرجاء إدخال كلمة المرور');
// return;
// }
// setIsDeleting(true);
// try {
// await deleteMyAccount(deletePassword);
// AuthService.deleteToken();
// toast.success('تم حذف الحساب بنجاح');
// router.push('/');
// } catch (err) {
// toast.error(err.message || 'فشل حذف الحساب');
// } finally {
// setIsDeleting(false);
// setShowDeleteDialog(false);
// setDeletePassword('');
// }
// };
// const sections = [
// {
// title: 'الحساب',
// items: [
// { icon: User, label: 'الملف الشخصي', href: '/profile', desc: 'عرض وتعديل معلوماتك الشخصية' },
// { icon: Lock, label: 'تغيير كلمة المرور', href: '/change-password', desc: 'تحديث كلمة المرور الخاصة بك' },
// { icon: Shield, label: 'التحقق من الحساب', href: '/account-verification', desc: 'تأكيد البريد الإلكتروني ورقم الهاتف' },
// ]
// },
// {
// title: 'الإشعارات',
// items: [
// { icon: Bell, label: 'الإشعارات', href: '/notifications', desc: 'إدارة تفضيلات الإشعارات' },
// ]
// },
// {
// title: 'الدعم',
// items: [
// { icon: HelpCircle, label: 'الأسئلة الشائعة', href: '/faq', desc: 'إجابات للأسئلة المتكررة' },
// { icon: MessageCircle, label: 'تواصل معنا', href: '/support', desc: 'الحصول على المساعدة والدعم' },
// { icon: FileText, label: 'الشروط والأحكام', href: '/terms', desc: 'سياسة الاستخدام والخصوصية' },
// { icon: Eye, label: 'سياسة الخصوصية', href: '/privacy', desc: 'كيف نحمي بياناتك' },
// ]
// },
// ];
// const containerVariants = {
// hidden: { opacity: 0 },
// visible: {
// opacity: 1,
// transition: { staggerChildren: 0.08 }
// }
// };
// const itemVariants = {
// hidden: { opacity: 0, y: 20 },
// visible: { opacity: 1, y: 0 }
// };
// return (
//
//
//
//
//
//
//
// الإعدادات
//
//
// {sections.map((section) => (
//
//
//
{section.title}
//
//
// {section.items.map((item) => {
// const Icon = item.icon;
// return (
//
//
//
//
//
//
{item.label}
//
{item.desc}
//
//
//
// );
// })}
//
//
// ))}
//
//
//
//
الأمان
//
//
//
//
// سيتم حذف جميع بياناتك بشكل دائم ولا يمكن التراجع عن هذا الإجراء
//
//
//
//
//
//
//
//
//
//
//
// {showDeleteDialog && (
//
//
//
//
//
//
حذف الحساب
//
هذا الإجراء لا يمكن التراجع عنه
//
//
//
//
// أدخل كلمة المرور لتأكيد حذف حسابك نهائياً. سيتم حذف جميع بياناتك وملفاتك بشكل دائم.
//
// setDeletePassword(e.target.value)}
// placeholder="كلمة المرور"
// className="w-full px-4 py-3 border border-gray-300 rounded-xl mb-4 focus:ring-2 focus:ring-red-500 focus:border-transparent outline-none"
// />
//
//
//
//
//
//
// )}
//
// );
// }
'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { motion } from 'framer-motion';
import {
User,
Shield,
Trash2,
LogOut,
ChevronLeft,
Bell,
Lock,
Eye,
FileText,
HelpCircle,
MessageCircle,
Loader2,
AlertTriangle,
X
} from 'lucide-react';
import toast, { Toaster } from 'react-hot-toast';
import AuthService from '../services/AuthService';
import { changePassword, deleteMyAccount, submitReport } from '../utils/api';
export default function SettingsPage() {
const router = useRouter();
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const [deletePassword, setDeletePassword] = useState('');
const [isDeleting, setIsDeleting] = useState(false);
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
const [showContactDialog, setShowContactDialog] = useState(false);
const [contactSubject, setContactSubject] = useState('');
const [contactBody, setContactBody] = useState('');
const [isSendingContact, setIsSendingContact] = useState(false);
const handleSignOut = () => {
AuthService.deleteToken();
toast.success('تم تسجيل الخروج بنجاح');
router.push('/');
};
const handleDeleteAccount = async () => {
if (!deletePassword) {
toast.error('الرجاء إدخال كلمة المرور');
return;
}
setIsDeleting(true);
try {
await deleteMyAccount(deletePassword);
AuthService.deleteToken();
toast.success('تم حذف الحساب بنجاح');
router.push('/');
} catch (err) {
console.error('Delete account error:', err);
toast.error(err.message || 'فشل حذف الحساب');
} finally {
setIsDeleting(false);
setShowDeleteDialog(false);
setDeletePassword('');
}
};
const handleSendContact = async () => {
if (!contactSubject.trim() || !contactBody.trim()) {
toast.error('الرجاء تعبئة العنوان والرسالة');
return;
}
setIsSendingContact(true);
try {
await submitReport(contactSubject.trim(), contactBody.trim());
toast.success('تم إرسال رسالتك بنجاح');
setShowContactDialog(false);
setContactSubject('');
setContactBody('');
} catch (err) {
toast.error(err.message || 'حدث خطأ أثناء الإرسال');
} finally {
setIsSendingContact(false);
}
};
const sections = [
{
title: 'الحساب',
items: [
{ icon: User, label: 'الملف الشخصي', href: '/profile', desc: 'عرض وتعديل معلوماتك الشخصية' },
{ icon: Lock, label: 'تغيير كلمة المرور', href: '/change-password', desc: 'تحديث كلمة المرور الخاصة بك' },
{ icon: Shield, label: 'التحقق من الحساب', href: '/account-verification', desc: 'تأكيد البريد الإلكتروني ورقم الهاتف' },
]
},
{
title: 'الإشعارات',
items: [
{ icon: Bell, label: 'الإشعارات', href: '/notifications', desc: 'إدارة تفضيلات الإشعارات' },
]
},
{
title: 'الدعم',
items: [
{ icon: HelpCircle, label: 'الأسئلة الشائعة', href: '/faq', desc: 'إجابات للأسئلة المتكررة' },
{ icon: MessageCircle, label: 'تواصل معنا', desc: 'الحصول على المساعدة والدعم', action: () => setShowContactDialog(true) },
{ icon: FileText, label: 'الشروط والأحكام', href: '/terms', desc: 'سياسة الاستخدام والخصوصية' },
{ icon: Eye, label: 'سياسة الخصوصية', href: '/privacy', desc: 'كيف نحمي بياناتك' },
]
},
];
const containerVariants = {
hidden: { opacity: 0 },
visible: {
opacity: 1,
transition: { staggerChildren: 0.08 }
}
};
const itemVariants = {
hidden: { opacity: 0, y: 20 },
visible: { opacity: 1, y: 0 }
};
return (
الإعدادات
{sections.map((section) => (
{section.title}
{section.items.map((item) => {
const Icon = item.icon;
const content = (
<>
>
);
if (item.action) {
return (
);
}
return (
{content}
);
})}
))}
الأمان
سيتم حذف جميع بياناتك بشكل دائم ولا يمكن التراجع عن هذا الإجراء
{showDeleteDialog && (
حذف الحساب
هذا الإجراء لا يمكن التراجع عنه
أدخل كلمة المرور لتأكيد حذف حسابك نهائياً. سيتم حذف جميع بياناتك وملفاتك بشكل دائم.
setDeletePassword(e.target.value)}
placeholder="كلمة المرور"
className="w-full px-4 py-3 border border-gray-300 rounded-xl mb-4 focus:ring-2 focus:ring-red-500 focus:border-transparent outline-none"
/>
)}
{showContactDialog && (
)}
);
}