'use client'; import { motion } from 'framer-motion'; import { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import '../i18n/config'; import { Users, Home, Calendar, User, Clock, DollarSign, PlusCircle, Edit, Trash2, CheckCircle, XCircle, Search, Filter, Download, Eye, MapPin, Bed, Bath, Square, Star, Phone, Mail, CalendarDays } from 'lucide-react'; export default function AdminPage() { const { t, i18n } = useTranslation(); const [activeTab, setActiveTab] = useState('properties'); const [searchQuery, setSearchQuery] = useState(''); const [selectedUser, setSelectedUser] = useState(null); // احصل على اللغة الحالية من i18n const currentLanguage = i18n.language || 'en'; const [stats, setStats] = useState({ totalUsers: 0, totalProperties: 0, activeBookings: 0, availableProperties: 0 }); const [properties, setProperties] = useState([ { id: 1, name: "luxuryVillaDamascus", type: "villa", price: 500000, location: "Damascus, Al-Mazzeh", bedrooms: 5, bathrooms: 4, area: 450, status: "available", images: [], features: ["swimmingPool", "privateGarden", "parking", "superLuxFinish"] }, { id: 2, name: "modernApartmentAleppo", type: "apartment", price: 250000, location: "Aleppo, Al-Shahba", bedrooms: 3, bathrooms: 2, area: 180, status: "booked", images: [], features: ["equippedKitchen", "centralHeating", "balcony", "securitySystem"] }, { id: 3, name: "familyHouseHoms", type: "house", price: 350000, location: "Homs, Baba Amr", bedrooms: 4, bathrooms: 3, area: 300, status: "available", images: [], features: ["largeGarden", "receptionHall", "maidRoom", "garage"] }, { id: 4, name: "seasideApartmentLatakia", type: "apartment", price: 300000, location: "Latakia, Blue Beach", bedrooms: 3, bathrooms: 2, area: 200, status: "available", images: [], features: ["seaView", "centralHeating", "centralAC", "parking"] }, { id: 5, name: "villaDaraa", type: "villa", price: 400000, location: "Daraa, Doctors District", bedrooms: 4, bathrooms: 3, area: 350, status: "booked", images: [], features: ["fruitGarden", "highWall", "advancedSecurity", "storage"] } ]); const [users, setUsers] = useState([ { id: 1, name: "Ahmed Mohamed", email: "ahmed@example.com", phone: "+963 123 456 789", joinDate: "2024-01-15", activeBookings: 1, totalBookings: 3, currentBooking: { propertyId: 2, propertyName: "modernApartmentAleppo", startDate: "2024-02-01", endDate: "2024-08-01", duration: "6 months", totalAmount: 1500000 } }, { id: 2, name: "Sara Ahmed", email: "sara@example.com", phone: "+963 987 654 321", joinDate: "2024-02-10", activeBookings: 0, totalBookings: 2, currentBooking: null }, { id: 3, name: "Mohammed Al-Halabi", email: "mohammed@example.com", phone: "+963 555 123 456", joinDate: "2024-01-25", activeBookings: 1, totalBookings: 1, currentBooking: { propertyId: 5, propertyName: "villaDaraa", startDate: "2024-02-15", endDate: "2024-05-15", duration: "3 months", totalAmount: 1200000 } } ]); const [bookingRequests, setBookingRequests] = useState([ { id: "B001", userId: 2, userName: "Sara Ahmed", propertyId: 1, propertyName: "luxuryVillaDamascus", startDate: "2024-03-01", endDate: "2024-06-01", duration: "3 months", totalAmount: 1500000, status: "pending", requestDate: "2024-02-20" }, { id: "B002", userId: 1, userName: "Ahmed Mohamed", propertyId: 4, propertyName: "seasideApartmentLatakia", startDate: "2024-03-15", endDate: "2024-05-15", duration: "2 months", totalAmount: 600000, status: "pending", requestDate: "2024-02-18" } ]); const formatNumber = (num) => { return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; const fadeInUp = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { duration: 0.5 } } }; const staggerContainer = { hidden: { opacity: 0 }, visible: { opacity: 1, transition: { staggerChildren: 0.1 } } }; const cardHover = { rest: { scale: 1, y: 0, boxShadow: "0 4px 6px rgba(0, 0, 0, 0.05)" }, hover: { scale: 1.02, y: -5, boxShadow: "0 10px 25px rgba(0, 0, 0, 0.1)", transition: { type: "spring", stiffness: 300 } } }; const buttonHover = { rest: { scale: 1 }, hover: { scale: 1.05 }, tap: { scale: 0.98 } }; useEffect(() => { const totalBookings = users.reduce((sum, user) => sum + user.activeBookings, 0); const availableProps = properties.filter(p => p.status === "available").length; setStats({ totalUsers: users.length, totalProperties: properties.length, activeBookings: totalBookings, availableProperties: availableProps }); }, [users, properties]); const handleBookingAction = (bookingId, action) => { setBookingRequests(prev => prev.map(booking => booking.id === bookingId ? { ...booking, status: action === 'accept' ? 'approved' : 'rejected' } : booking ) ); }; const handlePropertyAction = (propertyId, action) => { if (action === 'delete') { setProperties(prev => prev.filter(p => p.id !== propertyId)); } }; const showUserDetails = (user) => { setSelectedUser(user); }; const getLocation = (location) => { const [city, district] = location.split(",").map(s => s.trim()); // تحويل القيم إلى مفاتيح ترجمة const cityKey = city.toLowerCase(); const districtKey = district.replace(/\s+/g, ''); return `${t(cityKey)}, ${t(districtKey)}`; }; return (
{t("manageProperties")}
{t("pricesInSYP")}
{t("addEditDeleteProperties")}
{t("manageBookingRequests")}
{t("viewUserDetails")}