diff --git a/app/settings/page.js b/app/settings/page.js
index ef76b5f..c55b4dd 100644
--- a/app/settings/page.js
+++ b/app/settings/page.js
@@ -1,3 +1,260 @@
+// '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';
@@ -31,6 +288,11 @@ export default function SettingsPage() {
const [isDeleting, setIsDeleting] = useState(false);
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
+ const [showReportDialog, setShowReportDialog] = useState(false);
+ const [reportSubject, setReportSubject] = useState('');
+ const [reportBody, setReportBody] = useState('');
+ const [isSendingReport, setIsSendingReport] = useState(false);
+
const handleSignOut = () => {
AuthService.deleteToken();
toast.success('تم تسجيل الخروج بنجاح');
@@ -49,6 +311,7 @@ export default function SettingsPage() {
toast.success('تم حذف الحساب بنجاح');
router.push('/');
} catch (err) {
+ console.error('Delete account error:', err);
toast.error(err.message || 'فشل حذف الحساب');
} finally {
setIsDeleting(false);
@@ -57,6 +320,70 @@ export default function SettingsPage() {
}
};
+ const handleSendGeneralReport = async () => {
+ if (!reportSubject.trim() || !reportBody.trim()) {
+ toast.error('الرجاء تعبئة عنوان البلاغ ونصه');
+ return;
+ }
+
+ if (reportSubject.trim().length > 300) {
+ toast.error('عنوان البلاغ يجب ألا يتجاوز 300 حرف');
+ return;
+ }
+
+ const token =
+ AuthService.getToken?.() ||
+ (typeof window !== 'undefined'
+ ? localStorage.getItem('token') ||
+ localStorage.getItem('accessToken') ||
+ localStorage.getItem('authToken')
+ : null);
+
+ if (!token) {
+ console.error('No token found. Checked AuthService.getToken and localStorage keys: token, accessToken, authToken');
+ toast.error('لم يتم العثور على التوكن');
+ return;
+ }
+
+ setIsSendingReport(true);
+
+ try {
+ const res = await fetch('http://45.93.137.91/api/Reports/SendGeneralReport', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ subject: reportSubject.trim(),
+ body: reportBody.trim(),
+ }),
+ });
+
+ const responseText = await res.text();
+
+ if (!res.ok) {
+ console.error('Send report failed:', {
+ status: res.status,
+ statusText: res.statusText,
+ responseText,
+ });
+ throw new Error(responseText || `فشل إرسال البلاغ (HTTP ${res.status})`);
+ }
+
+ console.log('Send report success:', responseText);
+ toast.success(responseText || 'تم إرسال البلاغ بنجاح');
+ setShowReportDialog(false);
+ setReportSubject('');
+ setReportBody('');
+ } catch (err) {
+ console.error('Send report error:', err);
+ toast.error(err.message || 'حدث خطأ أثناء إرسال البلاغ');
+ } finally {
+ setIsSendingReport(false);
+ }
+ };
+
const sections = [
{
title: 'الحساب',
@@ -79,6 +406,7 @@ export default function SettingsPage() {
{ icon: MessageCircle, label: 'تواصل معنا', href: '/support', desc: 'الحصول على المساعدة والدعم' },
{ icon: FileText, label: 'الشروط والأحكام', href: '/terms', desc: 'سياسة الاستخدام والخصوصية' },
{ icon: Eye, label: 'سياسة الخصوصية', href: '/privacy', desc: 'كيف نحمي بياناتك' },
+ { icon: AlertTriangle, label: 'إرسال بلاغ عام', desc: 'إرسال مشكلة أو ملاحظة إلى الإدارة', action: () => setShowReportDialog(true) },
]
},
];
@@ -133,12 +461,9 @@ export default function SettingsPage() {
{section.items.map((item) => {
const Icon = item.icon;
- return (
-
+
+ const content = (
+ <>
@@ -147,6 +472,28 @@ export default function SettingsPage() {
{item.desc}
+ >
+ );
+
+ if (item.action) {
+ return (
+
+ );
+ }
+
+ return (
+
+ {content}
);
})}
@@ -242,6 +589,74 @@ export default function SettingsPage() {
)}
+
+ {showReportDialog && (
+
+
+
+
+
+
+
+
إرسال بلاغ عام
+
سيتم إرسال البلاغ إلى الإدارة
+
+
+
+
+ setReportSubject(e.target.value)}
+ placeholder="عنوان البلاغ"
+ maxLength={300}
+ className="w-full px-4 py-3 border border-gray-300 rounded-xl mb-4 focus:ring-2 focus:ring-amber-500 focus:border-transparent outline-none"
+ />
+
+
+
+ )}
);
-}
+}
\ No newline at end of file