From 5d44fb56eca939c84341f216a4be31d75c58d59e Mon Sep 17 00:00:00 2001 From: Rahaf Date: Wed, 1 Apr 2026 01:46:48 +0300 Subject: [PATCH] Edit profits --- app/owner/profits/page.js | 63 +++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/app/owner/profits/page.js b/app/owner/profits/page.js index a341528..949f37f 100644 --- a/app/owner/profits/page.js +++ b/app/owner/profits/page.js @@ -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 ( {
- {change !== undefined && ( -
- {trend === 'up' ? : } - {Math.abs(change)}% -
- )}

{title}

{value}
@@ -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 ( { {property.valuation}
- + مؤجر {property.rentedCount} مرة
@@ -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() {