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