forked from amer2004/SweetHome
fixed the support and removed the send general report no need for that also fixed the client layout
This commit is contained in:
@ -1,11 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
import { Home, Building, Calendar, Heart, Bell, Settings, CreditCard, Briefcase } from "lucide-react";
|
import { Home, Building, Calendar, Heart, Bell, Settings, CreditCard, Briefcase } from "lucide-react";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useNotifications } from "@/app/contexts/NotificationsContext";
|
import { useNotifications } from "@/app/contexts/NotificationsContext";
|
||||||
|
|
||||||
export default function BottomNav({ isOwner, isOwnerOrAgent }) {
|
export default function BottomNav({ isOwner, isOwnerOrAgent }) {
|
||||||
|
const pathname = usePathname();
|
||||||
const { unreadCount } = useNotifications();
|
const { unreadCount } = useNotifications();
|
||||||
const [isMounted, setIsMounted] = useState(false);
|
const [isMounted, setIsMounted] = useState(false);
|
||||||
const bookingsHref = isOwner ? "/owner/reservations" : "/reservations";
|
const bookingsHref = isOwner ? "/owner/reservations" : "/reservations";
|
||||||
@ -25,16 +27,22 @@ export default function BottomNav({ isOwner, isOwnerOrAgent }) {
|
|||||||
{ href: "/settings", label: "الإعدادات", icon: Settings },
|
{ href: "/settings", label: "الإعدادات", icon: Settings },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const isActive = (href) => {
|
||||||
|
if (href === "/") return pathname === "/";
|
||||||
|
return pathname.startsWith(href);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="fixed bottom-4 left-1/2 transform -translate-x-1/2 z-50">
|
<nav className="fixed bottom-4 left-1/2 transform -translate-x-1/2 z-50">
|
||||||
<div className="bg-white/95 backdrop-blur-sm border border-gray-200 rounded-3xl shadow-lg px-2 py-2 flex items-center gap-3">
|
<div className="bg-white/95 backdrop-blur-sm border border-gray-200 rounded-3xl shadow-lg px-2 py-2 flex items-center gap-3">
|
||||||
{items.map((it) => {
|
{items.map((it) => {
|
||||||
const Icon = it.icon;
|
const Icon = it.icon;
|
||||||
|
const active = isActive(it.href);
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={it.href}
|
key={it.href}
|
||||||
href={it.href}
|
href={it.href}
|
||||||
className="relative group flex flex-col items-center justify-center px-2.5 py-2 text-gray-700 hover:text-amber-600 transition-colors"
|
className={`relative group flex flex-col items-center justify-center px-2.5 py-2 transition-colors ${active ? "text-amber-600" : "text-gray-700 hover:text-amber-600"}`}
|
||||||
>
|
>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Icon className="w-6 h-6" />
|
<Icon className="w-6 h-6" />
|
||||||
|
|||||||
@ -276,7 +276,7 @@ import {
|
|||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast, { Toaster } from 'react-hot-toast';
|
||||||
import AuthService from '../services/AuthService';
|
import AuthService from '../services/AuthService';
|
||||||
import { changePassword, deleteMyAccount } from '../utils/api';
|
import { changePassword, deleteMyAccount, submitReport } from '../utils/api';
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -285,10 +285,10 @@ export default function SettingsPage() {
|
|||||||
const [isDeleting, setIsDeleting] = useState(false);
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
|
||||||
const [showReportDialog, setShowReportDialog] = useState(false);
|
const [showContactDialog, setShowContactDialog] = useState(false);
|
||||||
const [reportSubject, setReportSubject] = useState('');
|
const [contactSubject, setContactSubject] = useState('');
|
||||||
const [reportBody, setReportBody] = useState('');
|
const [contactBody, setContactBody] = useState('');
|
||||||
const [isSendingReport, setIsSendingReport] = useState(false);
|
const [isSendingContact, setIsSendingContact] = useState(false);
|
||||||
|
|
||||||
const handleSignOut = () => {
|
const handleSignOut = () => {
|
||||||
AuthService.deleteToken();
|
AuthService.deleteToken();
|
||||||
@ -317,66 +317,23 @@ export default function SettingsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSendGeneralReport = async () => {
|
const handleSendContact = async () => {
|
||||||
if (!reportSubject.trim() || !reportBody.trim()) {
|
if (!contactSubject.trim() || !contactBody.trim()) {
|
||||||
toast.error('الرجاء تعبئة عنوان البلاغ ونصه');
|
toast.error('الرجاء تعبئة العنوان والرسالة');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportSubject.trim().length > 300) {
|
setIsSendingContact(true);
|
||||||
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 {
|
try {
|
||||||
const res = await fetch('http://45.93.137.91/api/Reports/SendGeneralReport', {
|
await submitReport(contactSubject.trim(), contactBody.trim());
|
||||||
method: 'POST',
|
toast.success('تم إرسال رسالتك بنجاح');
|
||||||
headers: {
|
setShowContactDialog(false);
|
||||||
'Content-Type': 'application/json',
|
setContactSubject('');
|
||||||
Authorization: `Bearer ${token}`,
|
setContactBody('');
|
||||||
},
|
|
||||||
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})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
toast.success(responseText || 'تم إرسال البلاغ بنجاح');
|
|
||||||
setShowReportDialog(false);
|
|
||||||
setReportSubject('');
|
|
||||||
setReportBody('');
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Send report error:', err);
|
toast.error(err.message || 'حدث خطأ أثناء الإرسال');
|
||||||
toast.error(err.message || 'حدث خطأ أثناء إرسال البلاغ');
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsSendingReport(false);
|
setIsSendingContact(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -399,10 +356,9 @@ export default function SettingsPage() {
|
|||||||
title: 'الدعم',
|
title: 'الدعم',
|
||||||
items: [
|
items: [
|
||||||
{ icon: HelpCircle, label: 'الأسئلة الشائعة', href: '/faq', desc: 'إجابات للأسئلة المتكررة' },
|
{ icon: HelpCircle, label: 'الأسئلة الشائعة', href: '/faq', desc: 'إجابات للأسئلة المتكررة' },
|
||||||
{ icon: MessageCircle, label: 'تواصل معنا', href: '/support', desc: 'الحصول على المساعدة والدعم' },
|
{ icon: MessageCircle, label: 'تواصل معنا', desc: 'الحصول على المساعدة والدعم', action: () => setShowContactDialog(true) },
|
||||||
{ icon: FileText, label: 'الشروط والأحكام', href: '/terms', desc: 'سياسة الاستخدام والخصوصية' },
|
{ icon: FileText, label: 'الشروط والأحكام', href: '/terms', desc: 'سياسة الاستخدام والخصوصية' },
|
||||||
{ icon: Eye, label: 'سياسة الخصوصية', href: '/privacy', desc: 'كيف نحمي بياناتك' },
|
{ icon: Eye, label: 'سياسة الخصوصية', href: '/privacy', desc: 'كيف نحمي بياناتك' },
|
||||||
{ icon: AlertTriangle, label: 'إرسال بلاغ عام', desc: 'إرسال مشكلة أو ملاحظة إلى الإدارة', action: () => setShowReportDialog(true) },
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -421,7 +377,7 @@ export default function SettingsPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 py-8" dir="rtl">
|
<div className="min-h-screen bg-gray-50 py-8 pb-28" dir="rtl">
|
||||||
<Toaster position="top-center" reverseOrder={false} />
|
<Toaster position="top-center" reverseOrder={false} />
|
||||||
|
|
||||||
<div className="container mx-auto px-4 max-w-2xl">
|
<div className="container mx-auto px-4 max-w-2xl">
|
||||||
@ -586,7 +542,7 @@ export default function SettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showReportDialog && (
|
{showContactDialog && (
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50">
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50">
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, scale: 0.95 }}
|
initial={{ opacity: 0, scale: 0.95 }}
|
||||||
@ -598,14 +554,14 @@ export default function SettingsPage() {
|
|||||||
<MessageCircle className="w-5 h-5 text-amber-600" />
|
<MessageCircle className="w-5 h-5 text-amber-600" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-lg font-semibold text-gray-900">إرسال بلاغ عام</h3>
|
<h3 className="text-lg font-semibold text-gray-900">تواصل معنا</h3>
|
||||||
<p className="text-sm text-gray-500">سيتم إرسال البلاغ إلى الإدارة</p>
|
<p className="text-sm text-gray-500">سنقوم بالرد عليك في أقرب وقت</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowReportDialog(false);
|
setShowContactDialog(false);
|
||||||
setReportSubject('');
|
setContactSubject('');
|
||||||
setReportBody('');
|
setContactBody('');
|
||||||
}}
|
}}
|
||||||
className="mr-auto p-1 hover:bg-gray-100 rounded-lg transition-colors"
|
className="mr-auto p-1 hover:bg-gray-100 rounded-lg transition-colors"
|
||||||
>
|
>
|
||||||
@ -615,17 +571,17 @@ export default function SettingsPage() {
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={reportSubject}
|
value={contactSubject}
|
||||||
onChange={(e) => setReportSubject(e.target.value)}
|
onChange={(e) => setContactSubject(e.target.value)}
|
||||||
placeholder="عنوان البلاغ"
|
placeholder="الموضوع"
|
||||||
maxLength={300}
|
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"
|
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"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
value={reportBody}
|
value={contactBody}
|
||||||
onChange={(e) => setReportBody(e.target.value)}
|
onChange={(e) => setContactBody(e.target.value)}
|
||||||
placeholder="اكتب تفاصيل البلاغ هنا..."
|
placeholder="اكتب رسالتك هنا..."
|
||||||
rows={5}
|
rows={5}
|
||||||
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 resize-none"
|
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 resize-none"
|
||||||
/>
|
/>
|
||||||
@ -633,21 +589,21 @@ export default function SettingsPage() {
|
|||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowReportDialog(false);
|
setShowContactDialog(false);
|
||||||
setReportSubject('');
|
setContactSubject('');
|
||||||
setReportBody('');
|
setContactBody('');
|
||||||
}}
|
}}
|
||||||
className="flex-1 px-4 py-3 rounded-xl border border-gray-200 text-gray-700 hover:bg-gray-50 transition-colors text-sm font-medium"
|
className="flex-1 px-4 py-3 rounded-xl border border-gray-200 text-gray-700 hover:bg-gray-50 transition-colors text-sm font-medium"
|
||||||
>
|
>
|
||||||
إلغاء
|
إلغاء
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleSendGeneralReport}
|
onClick={handleSendContact}
|
||||||
disabled={isSendingReport}
|
disabled={isSendingContact}
|
||||||
className="flex-1 px-4 py-3 rounded-xl bg-amber-600 text-white hover:bg-amber-700 transition-colors text-sm font-medium disabled:opacity-50 flex items-center justify-center gap-2"
|
className="flex-1 px-4 py-3 rounded-xl bg-amber-600 text-white hover:bg-amber-700 transition-colors text-sm font-medium disabled:opacity-50 flex items-center justify-center gap-2"
|
||||||
>
|
>
|
||||||
{isSendingReport ? <Loader2 className="w-4 h-4 animate-spin" /> : <MessageCircle className="w-4 h-4" />}
|
{isSendingContact ? <Loader2 className="w-4 h-4 animate-spin" /> : <MessageCircle className="w-4 h-4" />}
|
||||||
{isSendingReport ? 'جاري الإرسال...' : 'إرسال البلاغ'}
|
{isSendingContact ? 'جاري الإرسال...' : 'إرسال'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|||||||
Reference in New Issue
Block a user