From 51850b85c2b57c9cf3749da6d84842fcaf38d2c2 Mon Sep 17 00:00:00 2001 From: Rahaf Date: Sun, 14 Jun 2026 18:04:05 +0300 Subject: [PATCH] Added blocked page with api --- app/ClientLayout.js | 1 + app/blocked/page.js | 166 ++++++++++++++++++++++++++++++++++++++++++++ app/utils/api.js | 77 +++++++++++++++++++- 3 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 app/blocked/page.js diff --git a/app/ClientLayout.js b/app/ClientLayout.js index 262d9a4..1a50712 100644 --- a/app/ClientLayout.js +++ b/app/ClientLayout.js @@ -126,6 +126,7 @@ export default function ClientLayout({ children }) { const isAuthPage = [ "/login", + "/blocked", "/register", "/forgot-password", "/auth/choose-role", diff --git a/app/blocked/page.js b/app/blocked/page.js new file mode 100644 index 0000000..2270b97 --- /dev/null +++ b/app/blocked/page.js @@ -0,0 +1,166 @@ +'use client'; + +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { motion } from 'framer-motion'; +import { ShieldAlert, LogOut, MessageSquare, Send, Loader2 } from 'lucide-react'; +import toast, { Toaster } from 'react-hot-toast'; +import AuthService from '../services/AuthService'; +import { sendGeneralReport } from '../utils/api'; + +export default function BlockedPage() { + const router = useRouter(); + const [form, setForm] = useState({ subject: '', body: '' }); + const [isSubmitting, setIsSubmitting] = useState(false); + const [isSent, setIsSent] = useState(false); + + const handleLogout = () => { + AuthService.deleteToken(); + router.replace('/'); + }; + + const updateField = (field, value) => { + setForm((current) => ({ ...current, [field]: value })); + if (isSent) setIsSent(false); + }; + + const handleSubmit = async (event) => { + event.preventDefault(); + + if (!form.subject.trim() || !form.body.trim()) { + toast.error('يرجى تعبئة الموضوع والرسالة'); + return; + } + + setIsSubmitting(true); + + try { + await sendGeneralReport(form.subject.trim(), form.body.trim()); + setIsSent(true); + setForm({ subject: '', body: '' }); + toast.success('تم إرسال طلب الدعم بنجاح'); + } catch (error) { + toast.error('حدث خطأ أثناء إرسال طلب الدعم. حاول مرة أخرى'); + } finally { + setIsSubmitting(false); + } + }; + + return ( +
+ + + +
+ + + +

الحساب محظور

+

+ تم تقييد وصولك إلى التطبيق. يمكنك تسجيل الخروج أو مراسلة دعم العملاء للمساعدة في حل المشكلة. +

+
+ +
+ +
+
+ +
+

تسجيل الخروج

+

+ إنهاء الجلسة الحالية وإزالة بيانات الدخول من هذا الجهاز. +

+
+ + +
+ + +
+
+ +
+
+

مراسلة دعم العملاء

+

أرسل تفاصيل المشكلة وسنقوم بمراجعتها.

+
+
+ +
+
+ + updateField('subject', event.target.value)} + placeholder="اكتب موضوع الرسالة" + className="w-full px-4 py-3 bg-white border border-gray-200 rounded-2xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-gray-900 placeholder-gray-400" + /> +
+ +
+ +