This commit is contained in:
@ -468,6 +468,7 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
@ -476,10 +477,7 @@ import { useRouter } from 'next/navigation';
|
|||||||
import {
|
import {
|
||||||
DollarSign,
|
DollarSign,
|
||||||
TrendingUp,
|
TrendingUp,
|
||||||
TrendingDown,
|
|
||||||
Wallet,
|
Wallet,
|
||||||
Home,
|
|
||||||
Calendar,
|
|
||||||
Star,
|
Star,
|
||||||
Eye,
|
Eye,
|
||||||
Download,
|
Download,
|
||||||
@ -488,7 +486,7 @@ import {
|
|||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast, { Toaster } from 'react-hot-toast';
|
||||||
import AuthService from '@/app/services/AuthService';
|
import AuthService from '@/app/services/AuthService';
|
||||||
|
|
||||||
const StatCard = ({ title, value, icon: Icon, color, change, trend }) => {
|
const StatCard = ({ title, value, icon: Icon, color }) => {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 20 }}
|
initial={{ opacity: 0, y: 20 }}
|
||||||
@ -499,12 +497,6 @@ const StatCard = ({ title, value, icon: Icon, color, change, trend }) => {
|
|||||||
<div className={`w-12 h-12 ${color} rounded-xl flex items-center justify-center`}>
|
<div className={`w-12 h-12 ${color} rounded-xl flex items-center justify-center`}>
|
||||||
<Icon className="w-6 h-6 text-white" />
|
<Icon className="w-6 h-6 text-white" />
|
||||||
</div>
|
</div>
|
||||||
{change !== undefined && (
|
|
||||||
<div className={`flex items-center gap-1 text-sm ${trend === 'up' ? 'text-green-600' : 'text-red-600'}`}>
|
|
||||||
{trend === 'up' ? <TrendingUp className="w-4 h-4" /> : <TrendingDown className="w-4 h-4" />}
|
|
||||||
<span>{Math.abs(change)}%</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<h3 className="text-sm text-gray-500 mb-1">{title}</h3>
|
<h3 className="text-sm text-gray-500 mb-1">{title}</h3>
|
||||||
<div className="text-2xl font-bold text-gray-900">{value}</div>
|
<div className="text-2xl font-bold text-gray-900">{value}</div>
|
||||||
@ -513,9 +505,7 @@ const StatCard = ({ title, value, icon: Icon, color, change, trend }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PropertyProfitCard = ({ property, onViewDetails }) => {
|
const PropertyProfitCard = ({ property, onViewDetails }) => {
|
||||||
const formatCurrency = (amount) => {
|
const formatCurrency = (amount) => `$${amount?.toLocaleString()}`;
|
||||||
return `$${amount?.toLocaleString()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
@ -558,7 +548,7 @@ const PropertyProfitCard = ({ property, onViewDetails }) => {
|
|||||||
<span className="text-sm font-medium text-gray-900">{property.valuation}</span>
|
<span className="text-sm font-medium text-gray-900">{property.valuation}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 text-sm text-gray-500">
|
<div className="flex items-center gap-1 text-sm text-gray-500">
|
||||||
<Calendar className="w-4 h-4" />
|
<CalendarDays className="w-4 h-4" />
|
||||||
<span>مؤجر {property.rentedCount} مرة</span>
|
<span>مؤجر {property.rentedCount} مرة</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -590,7 +580,7 @@ const PropertyCalendar = ({ year, month }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const daysInMonth = getDaysInMonth(currentMonth);
|
const daysInMonth = getDaysInMonth(currentMonth);
|
||||||
const firstDayIndex = getFirstDayOfMonth(currentMonth); // 0 = الإثنين
|
const firstDayIndex = getFirstDayOfMonth(currentMonth);
|
||||||
|
|
||||||
const cells = [];
|
const cells = [];
|
||||||
for (let i = 0; i < firstDayIndex; i++) {
|
for (let i = 0; i < firstDayIndex; i++) {
|
||||||
@ -647,7 +637,6 @@ export default function OwnerProfitsPage() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [selectedProperty, setSelectedProperty] = useState(null);
|
|
||||||
|
|
||||||
const [summary] = useState({
|
const [summary] = useState({
|
||||||
totalRevenue: 4290,
|
totalRevenue: 4290,
|
||||||
@ -659,37 +648,39 @@ export default function OwnerProfitsPage() {
|
|||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Damascus Olive Residence',
|
title: 'Damascus Olive Residence',
|
||||||
location: 'دمشق، كفرسوسة',
|
location: 'دمشق، المزة',
|
||||||
isNotSeized: true,
|
isNotSeized: true,
|
||||||
revenue: 8888,
|
revenue: 3240,
|
||||||
commission: 444,
|
commission: 486,
|
||||||
remaining: 4454,
|
remaining: 2754,
|
||||||
valuation: 'جيد ',
|
valuation: 'جيد جدا',
|
||||||
rentedCount: 19,
|
rentedCount: 18,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedUser = localStorage.getItem('user');
|
if (AuthService.isGuest()) {
|
||||||
if (storedUser) {
|
|
||||||
const userData = JSON.parse(storedUser);
|
|
||||||
if (userData.role !== 'owner') {
|
|
||||||
router.push('/');
|
|
||||||
} else {
|
|
||||||
setUser(userData);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
router.push('/auth/choose-role');
|
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);
|
setIsLoading(false);
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
||||||
const formatCurrency = (amount) => {
|
const formatCurrency = (amount) => `$${amount?.toLocaleString()}`;
|
||||||
return `$${amount?.toLocaleString()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleViewDetails = (property) => {
|
const handleViewDetails = (property) => {
|
||||||
setSelectedProperty(property);
|
|
||||||
toast.info(`عرض تفاصيل ${property.title}`);
|
toast.info(`عرض تفاصيل ${property.title}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -759,7 +750,7 @@ export default function OwnerProfitsPage() {
|
|||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<button
|
<button
|
||||||
onClick={handleExportReport}
|
onClick={handleExportReport}
|
||||||
className="px-6 py-3 bg-amber-500 text-white rounded-xl font-medium hover:bg-amber-600 transition-colors flex items-center gap-2"
|
className="px-6 py-3 bg-amber-500 text-white rounded-xl font-medium hover:bg-amber-600 transition-colors flex items-center justify-center gap-2"
|
||||||
>
|
>
|
||||||
<Download className="w-5 h-5" />
|
<Download className="w-5 h-5" />
|
||||||
تصدير التقرير
|
تصدير التقرير
|
||||||
|
|||||||
Reference in New Issue
Block a user