import { getCurrentUser } from "@/lib/auth" import { getJobsByPlumberId, getPlumberEarnings } from "@/lib/plumber-jobs" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { DollarSign, TrendingUp, Calendar, CheckCircle, Star } from "lucide-react" export default async function PlumberEarningsPage() { const user = await getCurrentUser() const jobs = user ? getJobsByPlumberId(user.id) : [] const earnings = user ? getPlumberEarnings(user.id) : null const completedJobs = jobs.filter((job) => job.status === "completed") const thisMonthJobs = completedJobs.filter((job) => { const jobDate = new Date(job.completedAt || job.createdAt) const now = new Date() return jobDate.getMonth() === now.getMonth() && jobDate.getFullYear() === now.getFullYear() }) return (
تتبع أرباحك ومهامك المكتملة
الأرباح الإجمالية
{earnings.totalEarnings} جنيه
أرباح هذا الشهر
{earnings.monthlyEarnings} جنيه
المهام المكتملة
{earnings.completedJobs}
متوسط التقييم
{earnings.averageRating.toFixed(1)}
من {earnings.totalReviews} تقييم
العميل: {job.customerName}
{job.actualPrice || job.estimatedPrice} جنيه
{job.customerRating && (لا توجد مهام مكتملة بعد
{thisMonthJobs.length}
مهام مكتملة
{thisMonthJobs.reduce((sum, job) => sum + (job.actualPrice || job.estimatedPrice), 0)} جنيه
أرباح الشهر
{thisMonthJobs.length > 0 ? ( thisMonthJobs.reduce((sum, job) => sum + (job.actualPrice || job.estimatedPrice), 0) / thisMonthJobs.length ).toFixed(0) : 0}{" "} جنيه
متوسط المهمة