diff --git a/app/profile/page.js b/app/profile/page.js index 992e139..883fd1c 100644 --- a/app/profile/page.js +++ b/app/profile/page.js @@ -1,9 +1,9 @@ -'use client'; +"use client"; -import { useState, useEffect } from 'react'; -import { motion } from 'framer-motion'; -import { useRouter } from 'next/navigation'; -import Link from 'next/link'; +import { useState, useEffect } from "react"; +import { motion } from "framer-motion"; +import { useRouter } from "next/navigation"; +import Link from "next/link"; import { User, Mail, @@ -17,11 +17,11 @@ import { Calendar, MapPin, Loader2, - Pencil -} from 'lucide-react'; -import toast, { Toaster } from 'react-hot-toast'; -import AuthService from '../services/AuthService'; -import { getCustomerByUserId, getOwnerByUserId } from '../utils/api'; + Pencil, +} from "lucide-react"; +import toast, { Toaster } from "react-hot-toast"; +import AuthService from "../services/AuthService"; +import { getCustomerByUserId, getOwnerByUserId } from "../utils/api"; export default function ProfilePage() { const router = useRouter(); @@ -29,52 +29,65 @@ export default function ProfilePage() { const [isLoading, setIsLoading] = useState(true); const [editingBio, setEditingBio] = useState(false); - const [bioDraft, setBioDraft] = useState(''); + const [bioDraft, setBioDraft] = useState(""); const [formData, setFormData] = useState({ - name: '', - email: '', - phone: '', - whatsapp: '', - bio: '', - location: '', - joinedDate: '' + name: "", + email: "", + phone: "", + whatsapp: "", + bio: "", + location: "", + joinedDate: "", }); - const [avatarPreview, setAvatarPreview] = useState(''); + const [avatarPreview, setAvatarPreview] = useState(""); useEffect(() => { const authUser = AuthService.getUser(); if (authUser) { const userData = { id: authUser.id, - name: authUser.name || '', - email: authUser.email || '', - phone: authUser.phone || '', - role: AuthService.isOwner() ? 'owner' : 'customer', + name: authUser.name || "", + email: authUser.email || "", + phone: authUser.phone || "", + role: AuthService.isOwner() ? "owner" : "customer", }; setUser(userData); async function fetchProfile() { try { - const fetchFn = userData.role === 'owner' ? getOwnerByUserId : getCustomerByUserId; + const fetchFn = + userData.role === "owner" ? getOwnerByUserId : getCustomerByUserId; const profile = await fetchFn(userData.id); if (profile) { const profileData = { - name: profile.fullName || profile.name || `${profile.firstName || ''} ${profile.lastName || ''}`.trim() || userData.name || '', - email: profile.email || userData.email || '', - phone: profile.phone || profile.phoneNumber || userData.phone || '', - whatsapp: profile.whatsAppNumber || profile.whatsapp || '', - bio: profile.bio || '', - location: profile.address || profile.location || '', + name: + profile.fullName || + profile.name || + `${profile.firstName || ""} ${profile.lastName || ""}`.trim() || + userData.name || + "", + email: profile.email || userData.email || "", + phone: + profile.phone || profile.phoneNumber || userData.phone || "", + whatsapp: profile.whatsAppNumber || profile.whatsapp || "", + bio: profile.bio || "", + location: profile.address || profile.location || "", joinedDate: profile.createdAt - ? new Date(profile.createdAt).toLocaleDateString('ar-SA', { month: 'long', year: 'numeric' }) - : new Date().toLocaleDateString('ar-SA', { month: 'long', year: 'numeric' }), + ? new Date(profile.createdAt).toLocaleDateString("ar-SA", { + month: "long", + year: "numeric", + }) + : new Date().toLocaleDateString("ar-SA", { + month: "long", + year: "numeric", + }), }; setFormData(profileData); setBioDraft(profileData.bio); - localStorage.setItem('userProfile', JSON.stringify(profileData)); + localStorage.setItem("userProfile", JSON.stringify(profileData)); setIsLoading(false); return; } @@ -82,59 +95,62 @@ export default function ProfilePage() { // Ignore API errors and fall back to local data. } - const savedProfile = localStorage.getItem('userProfile'); + const savedProfile = localStorage.getItem("userProfile"); let profileData; if (savedProfile) { profileData = JSON.parse(savedProfile); } else { profileData = { - name: userData.name || '', - email: userData.email || '', - phone: '', - whatsapp: '', - bio: '', - location: '', - joinedDate: new Date().toLocaleDateString('ar-SA', { month: 'long', year: 'numeric' }) + name: userData.name || "", + email: userData.email || "", + phone: "", + whatsapp: "", + bio: "", + location: "", + joinedDate: new Date().toLocaleDateString("ar-SA", { + month: "long", + year: "numeric", + }), }; } setFormData(profileData); - setBioDraft(profileData.bio || ''); + setBioDraft(profileData.bio || ""); setIsLoading(false); } - const savedAvatar = localStorage.getItem('userAvatar'); + const savedAvatar = localStorage.getItem("userAvatar"); if (savedAvatar) { setAvatarPreview(savedAvatar); } fetchProfile(); } else { - router.push('/login'); + router.push("/login"); } }, [router]); const startBioEditing = () => { - setBioDraft(formData.bio || ''); + setBioDraft(formData.bio || ""); setEditingBio(true); }; const cancelBioEditing = () => { - setBioDraft(formData.bio || ''); + setBioDraft(formData.bio || ""); setEditingBio(false); }; const saveBio = () => { const updatedData = { ...formData, bio: bioDraft }; setFormData(updatedData); - localStorage.setItem('userProfile', JSON.stringify(updatedData)); + localStorage.setItem("userProfile", JSON.stringify(updatedData)); setEditingBio(false); - toast.success('تم تحديث نبذة عني بنجاح'); + toast.success("تم تحديث نبذة عني بنجاح"); }; const fadeInUp = { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, - transition: { duration: 0.5 } + transition: { duration: 0.5 }, }; if (isLoading) { @@ -177,12 +193,12 @@ export default function ProfilePage() { @@ -198,7 +214,7 @@ export default function ProfilePage() { className="w-full h-full object-cover" /> ) : ( - formData.name?.charAt(0).toUpperCase() || 'U' + formData.name?.charAt(0).toUpperCase() || "U" )} @@ -206,12 +222,14 @@ export default function ProfilePage() {
-

{formData.name}

+

+ {formData.name} +

- {formData.location || 'الموقع غير محدد'} + {formData.location || "الموقع غير محدد"}
@@ -241,7 +259,7 @@ export default function ProfilePage() {
- {formData.phone || 'غير محدد'} + {formData.phone || "غير محدد"}
@@ -253,7 +271,7 @@ export default function ProfilePage() {
- {formData.whatsapp || 'غير محدد'} + {formData.whatsapp || "غير محدد"}
@@ -262,7 +280,7 @@ export default function ProfilePage() { نوع الحساب
- {user?.role === 'owner' ? ( + {user?.role === "owner" ? ( <> مالك عقار @@ -276,8 +294,8 @@ export default function ProfilePage() {
- -
+ {/* noo need for the descption of me on the profile*/} + {/*
+
*/} - {user?.role === 'owner' && ( + {user?.role === "owner" && (
12
@@ -347,4 +365,4 @@ export default function ProfilePage() {
); -} \ No newline at end of file +} diff --git a/app/support/page.js b/app/support/page.js index 1c4f626..01c3ce7 100644 --- a/app/support/page.js +++ b/app/support/page.js @@ -1,44 +1,54 @@ -'use client'; +"use client"; -import { useState } from 'react'; -import { motion } from 'framer-motion'; -import { MessageCircle, Mail, Phone, MapPin, Send, Loader2 } from 'lucide-react'; -import toast, { Toaster } from 'react-hot-toast'; -import { submitReport } from '../utils/api'; -import AuthService from '../services/AuthService'; +import { useState } from "react"; +import { motion } from "framer-motion"; +import { + MessageCircle, + Mail, + Phone, + MapPin, + Send, + Loader2, +} from "lucide-react"; +import toast, { Toaster } from "react-hot-toast"; +import { submitReport } from "../utils/api"; +import AuthService from "../services/AuthService"; export default function SupportPage() { - const [subject, setSubject] = useState(''); - const [body, setBody] = useState(''); + const [subject, setSubject] = useState(""); + const [body, setBody] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); if (!subject.trim() || !body.trim()) { - toast.error('يرجى تعبئة جميع الحقول'); + toast.error("يرجى تعبئة جميع الحقول"); return; } if (!AuthService.isAuthenticated()) { - toast.error('يرجى تسجيل الدخول أولاً لإرسال طلب دعم'); + toast.error("يرجى تسجيل الدخول أولاً لإرسال طلب دعم"); return; } setIsSubmitting(true); try { await submitReport(subject, body); - toast.success('تم إرسال طلب الدعم بنجاح'); - setSubject(''); - setBody(''); + toast.success("تم إرسال طلب الدعم بنجاح"); + setSubject(""); + setBody(""); } catch (error) { - toast.error('حدث خطأ أثناء إرسال الطلب. حاول مرة أخرى'); + toast.error("حدث خطأ أثناء إرسال الطلب. حاول مرة أخرى"); } finally { setIsSubmitting(false); } }; return ( -
+
-

خدمة العملاء

+

+ خدمة العملاء +

- نحن هنا لمساعدتك. تواصل معنا عبر النموذج أدناه أو من خلال معلومات الاتصال المباشرة + نحن هنا لمساعدتك. تواصل معنا عبر النموذج أدناه أو من خلال معلومات + الاتصال المباشرة

@@ -63,7 +76,9 @@ export default function SupportPage() { className="md:col-span-2" >
-

أرسل لنا رسالة

+

+ أرسل لنا رسالة +

@@ -112,7 +127,9 @@ export default function SupportPage() { className="space-y-6" >
-

معلومات الاتصال

+

+ معلومات الاتصال +

@@ -120,7 +137,9 @@ export default function SupportPage() {

البريد الإلكتروني

-

support@sweethome.com

+

+ support@sweethome.com +

@@ -129,7 +148,9 @@ export default function SupportPage() {

رقم الهاتف

-

+963 11 234 5678

+

+ +963 11 234 5678 +

@@ -145,7 +166,9 @@ export default function SupportPage() {
-

ساعات العمل

+

+ ساعات العمل +

السبت - الخميس