// 'use client';
// import { useState, useEffect } from 'react';
// import { motion } from 'framer-motion';
// import { useRouter } from 'next/navigation';
// import Link from 'next/link';
// import {
// DollarSign,
// TrendingUp,
// TrendingDown,
// Calendar,
// Home,
// Building,
// Download,
// Filter,
// ChevronLeft,
// ChevronRight,
// ArrowLeft,
// Loader2,
// Eye,
// PieChart,
// BarChart,
// LineChart,
// Wallet,
// CreditCard,
// Clock,
// CheckCircle,
// XCircle
// } from 'lucide-react';
// import toast, { Toaster } from 'react-hot-toast';
// import AuthService from '../../services/AuthService';
// const StatCard = ({ title, value, change, icon: Icon, color, trend }) => {
// return (
//
//
//
//
//
//
// {trend === 'up' ? : }
// {Math.abs(change)}%
//
//
// {title}
// {value}
//
// );
// };
// const PropertyProfitCard = ({ property, onViewDetails }) => {
// const formatCurrency = (amount) => {
// return amount?.toLocaleString() + ' ل.س';
// };
// return (
//
//
//
//
//
{property.title}
//
{property.location}
//
//
// {property.status === 'active' ? 'نشط' : 'غير نشط'}
//
//
//
//
//
//
إجمالي الأرباح
//
{formatCurrency(property.totalProfit)}
//
//
//
//
عدد الحجوزات
//
{property.totalBookings}
//
//
//
//
// هذا الشهر
// {formatCurrency(property.monthlyProfit)}
//
//
// الأسبوع الماضي
// {formatCurrency(property.weeklyProfit)}
//
//
// متوسط السعر اليومي
// {formatCurrency(property.avgDailyPrice)}
//
//
//
//
//
// );
// };
// const ProfitDetailsModal = ({ property, isOpen, onClose }) => {
// if (!isOpen || !property) return null;
// const formatCurrency = (amount) => {
// return amount?.toLocaleString() + ' ل.س';
// };
// const monthlyData = [
// { month: 'يناير', profit: 1250000 },
// { month: 'فبراير', profit: 1500000 },
// { month: 'مارس', profit: 1800000 },
// { month: 'إبريل', profit: 2100000 },
// { month: 'مايو', profit: 2500000 },
// { month: 'يونيو', profit: 2300000 }
// ];
// const maxProfit = Math.max(...monthlyData.map(d => d.profit));
// return (
//
// e.stopPropagation()}
// >
//
//
//
//
{property.title}
//
{property.location}
//
//
//
//
//
//
//
//
{formatCurrency(property.totalProfit)}
//
إجمالي الأرباح
//
//
//
{property.totalBookings}
//
عدد الحجوزات
//
//
//
{property.occupancyRate}%
//
نسبة الإشغال
//
//
//
{formatCurrency(property.avgDailyPrice)}
//
متوسط السعر اليومي
//
//
//
//
الأرباح الشهرية
//
// {monthlyData.map((data, index) => (
//
//
// {data.month}
// {formatCurrency(data.profit)}
//
//
//
//
//
// ))}
//
//
//
//
آخر الحجوزات
//
// {property.recentBookings?.map((booking, index) => (
//
//
//
{booking.tenantName}
//
{booking.startDate} - {booking.endDate}
//
//
//
{formatCurrency(booking.amount)}
//
{booking.status === 'completed' ? 'مكتمل' : 'قيد التنفيذ'}
//
//
// ))}
//
//
//
//
//
// );
// };
// export default function OwnerProfitsPage() {
// const router = useRouter();
// const [user, setUser] = useState(null);
// const [properties, setProperties] = useState([]);
// const [filteredProperties, setFilteredProperties] = useState([]);
// const [isLoading, setIsLoading] = useState(true);
// const [selectedProperty, setSelectedProperty] = useState(null);
// const [dateRange, setDateRange] = useState({ start: '', end: '' });
// const [selectedPeriod, setSelectedPeriod] = useState('month');
// useEffect(() => {
// const authUser = AuthService.getUser();
// if (authUser && AuthService.isOwner()) {
// setUser({
// name: authUser.name || authUser.email,
// email: authUser.email,
// role: 'owner',
// });
// loadData();
// } else {
// router.push('/auth/choose-role');
// }
// }, [router]); // month, year, all
// const loadProfitsData = () => {
// const storedProfits = localStorage.getItem('ownerProfits');
// if (storedProfits) {
// setProperties(JSON.parse(storedProfits));
// setFilteredProperties(JSON.parse(storedProfits));
// } else {
// const mockProperties = [
// {
// id: 1,
// title: 'فيلا فاخرة في المزة',
// location: 'دمشق، المزة',
// status: 'active',
// totalProfit: 12500000,
// totalBookings: 24,
// monthlyProfit: 3200000,
// weeklyProfit: 850000,
// avgDailyPrice: 500000,
// occupancyRate: 78,
// recentBookings: [
// { tenantName: 'أحمد محمد', startDate: '2024-03-10', endDate: '2024-03-15', amount: 2500000, status: 'completed' },
// { tenantName: 'سارة أحمد', startDate: '2024-03-05', endDate: '2024-03-08', amount: 1500000, status: 'completed' }
// ]
// },
// {
// id: 2,
// title: 'شقة حديثة في الشهباء',
// location: 'حلب، الشهباء',
// status: 'active',
// totalProfit: 5800000,
// totalBookings: 18,
// monthlyProfit: 1500000,
// weeklyProfit: 400000,
// avgDailyPrice: 250000,
// occupancyRate: 65,
// recentBookings: [
// { tenantName: 'محمد علي', startDate: '2024-03-12', endDate: '2024-03-14', amount: 750000, status: 'completed' }
// ]
// },
// {
// id: 3,
// title: 'بيت عائلي في بابا عمرو',
// location: 'حمص، بابا عمرو',
// status: 'active',
// totalProfit: 8400000,
// totalBookings: 12,
// monthlyProfit: 2100000,
// weeklyProfit: 525000,
// avgDailyPrice: 350000,
// occupancyRate: 45,
// recentBookings: []
// }
// ];
// setProperties(mockProperties);
// setFilteredProperties(mockProperties);
// localStorage.setItem('ownerProfits', JSON.stringify(mockProperties));
// }
// setIsLoading(false);
// };
// const totalStats = {
// totalProfit: properties.reduce((sum, p) => sum + p.totalProfit, 0),
// totalBookings: properties.reduce((sum, p) => sum + p.totalBookings, 0),
// avgOccupancy: Math.round(properties.reduce((sum, p) => sum + p.occupancyRate, 0) / properties.length),
// activeProperties: properties.filter(p => p.status === 'active').length
// };
// const formatCurrency = (amount) => {
// if (amount >= 1000000) {
// return (amount / 1000000).toFixed(1) + ' مليون ل.س';
// }
// return amount?.toLocaleString() + ' ل.س';
// };
// if (isLoading) {
// return (
//
//
//
//
جاري تحميل بيانات الأرباح...
//
//
// );
// }
// return (
//
//
//
setSelectedProperty(null)}
// />
//
//
//
//
الأرباح والإحصائيات
//
مرحباً {user?.name}، إليك ملخص أرباحك
//
//
//
// {/* */}
//
//
//
//
//
//
//
//
//
//
//
أرباح العقارات
//
//
//
//
// {filteredProperties.length === 0 ? (
//
//
//
//
//
لا توجد بيانات
//
لا توجد أرباح مسجلة حتى الآن
//
// ) : (
//
// {filteredProperties.map((property) => (
//
// ))}
//
// )}
//
//
//
//
//
احصل على المزيد من الأرباح
//
أضف عقارات جديدة وحسّن أسعارك لزيادة الإشغال
//
//
// إضافة عقار جديد
//
//
//
//
//
// );
// }
'use client';
import { useState, useEffect } from 'react';
import { motion } from 'framer-motion';
import { useRouter } from 'next/navigation';
import {
DollarSign,
TrendingUp,
Wallet,
Star,
Eye,
Download,
CalendarDays
} from 'lucide-react';
import toast, { Toaster } from 'react-hot-toast';
import AuthService from '@/app/services/AuthService';
const StatCard = ({ title, value, icon: Icon, color }) => {
return (
{title}
{value}
);
};
const PropertyProfitCard = ({ property, onViewDetails }) => {
const formatCurrency = (amount) => `$${amount?.toLocaleString()}`;
return (
{property.title}
{property.isNotSeized && (
غير محجوز
)}
{property.location}
الإيرادات
{formatCurrency(property.revenue)}
العمولة
{formatCurrency(property.commission)}
المتبقي
{formatCurrency(property.remaining)}
التقييم العام:
{property.valuation}
مؤجر {property.rentedCount} مرة
);
};
const PropertyCalendar = ({ year, month }) => {
const [currentMonth, setCurrentMonth] = useState(new Date(year, month - 1));
const monthNames = ['يناير', 'فبراير', 'مارس', 'إبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'];
const weekDays = ['إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت', 'أحد'];
const getDaysInMonth = (date) => {
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
};
const getFirstDayOfMonth = (date) => {
const day = new Date(date.getFullYear(), date.getMonth(), 1).getDay();
return day === 0 ? 6 : day - 1;
};
const daysInMonth = getDaysInMonth(currentMonth);
const firstDayIndex = getFirstDayOfMonth(currentMonth);
const cells = [];
for (let i = 0; i < firstDayIndex; i++) {
cells.push();
}
for (let d = 1; d <= daysInMonth; d++) {
cells.push(
{d}
);
}
return (
{monthNames[currentMonth.getMonth()]} {currentMonth.getFullYear()}
{weekDays.map(day => (
{day}
))}
{cells}
);
};
export default function OwnerProfitsPage() {
const router = useRouter();
const [user, setUser] = useState(null);
const [isLoading, setIsLoading] = useState(true);
const [summary] = useState({
totalRevenue: 4290,
totalCommission: 644,
remainingBalance: 3647,
});
const [properties] = useState([
{
id: 1,
title: 'Damascus Olive Residence',
location: 'دمشق، المزة',
isNotSeized: true,
revenue: 3240,
commission: 486,
remaining: 2754,
valuation: 'جيد جدا',
rentedCount: 18,
},
]);
useEffect(() => {
if (AuthService.isGuest()) {
router.push('/auth/choose-role');
return;
}
if (!AuthService.isOwner()) {
router.push('/');
return;
}
const authUser = AuthService.getUser();
if (authUser) {
setUser({
name: authUser.name || authUser.email,
email: authUser.email,
});
}
setIsLoading(false);
}, [router]);
const formatCurrency = (amount) => `$${amount?.toLocaleString()}`;
const handleViewDetails = (property) => {
toast.info(`عرض تفاصيل ${property.title}`);
};
const handleExportReport = () => {
toast.success('جاري تصدير التقرير...');
};
if (isLoading) {
return (
);
}
return (
دفتر الحسابات
نظرة عامة على أرباح المالك
عقاراتي
{properties.map((property) => (
))}
{/*
*/}
);
}