diff --git a/src/app/[locale]/dashboard/my-toys/page.tsx b/src/app/[locale]/dashboard/my-toys/page.tsx index c7e581b..6fee55e 100644 --- a/src/app/[locale]/dashboard/my-toys/page.tsx +++ b/src/app/[locale]/dashboard/my-toys/page.tsx @@ -2,9 +2,8 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { getToysByOwner } from "@/data/operations"; -import { mockRentalHistory } from "@/lib/mockData"; import Link from "next/link"; -import { PlusCircle, Edit3, Trash2, Eye, ToyBrick as ToyBrickIcon, BarChartHorizontalBig } from "lucide-react"; +import { PlusCircle, Edit3, Trash2, Eye, ToyBrick as ToyBrickIcon } from "lucide-react"; import Image from "next/image"; import type { Toy } from "@/types"; import { Badge } from "@/components/ui/badge"; @@ -16,16 +15,6 @@ export default async function MyToysPage() { const t = await getI18n(); const userToys = getToysByOwner(currentUserId); - const getRentalCountForToy = (toyId: string): number => { - // NOTE: This part still uses mock data and will need to be migrated. - return mockRentalHistory.filter(entry => entry.toy.id === toyId && entry.toy.ownerId === currentUserId).length; - }; - - const userToysWithRentalCount = userToys.map(toy => ({ - ...toy, - rentalCount: getRentalCountForToy(toy.id), - })); - return (
@@ -41,7 +30,7 @@ export default async function MyToysPage() {
- {userToysWithRentalCount.length === 0 ? ( + {userToys.length === 0 ? ( @@ -59,8 +48,8 @@ export default async function MyToysPage() { ) : (
- {userToysWithRentalCount.map(toy => ( - + {userToys.map(toy => ( + ))}
)} @@ -71,10 +60,9 @@ export default async function MyToysPage() { interface ListedToyItemProps { toy: Toy & {dataAiHint?: string}; t: (key: string, params?: Record) => string; - rentalCount: number; } -function ListedToyItem({ toy, t, rentalCount }: ListedToyItemProps) { +function ListedToyItem({ toy, t }: ListedToyItemProps) { const placeholderHint = toy.dataAiHint || toy.category.toLowerCase() || "toy"; return ( @@ -117,14 +105,6 @@ function ListedToyItem({ toy, t, rentalCount }: ListedToyItemProps) { {t('toy_details.price')}: {toy.pricePerDay !== undefined ? (toy.pricePerDay > 0 ? `$${toy.pricePerDay}${t('toy_details.price_per_day')}` : t('toy_details.price_free')) : 'Not set'}
- {rentalCount > 0 && ( -
- - {rentalCount === 1 - ? t('dashboard.my_toys.rental_count_one') - : t('dashboard.my_toys.rental_count_many', { count: rentalCount })} -
- )} diff --git a/src/app/[locale]/dashboard/page.tsx b/src/app/[locale]/dashboard/page.tsx index 6644332..4528f8b 100644 --- a/src/app/[locale]/dashboard/page.tsx +++ b/src/app/[locale]/dashboard/page.tsx @@ -3,15 +3,20 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; import { ToyBrick, PlusCircle, ListOrdered, User, ShoppingBag } from "lucide-react"; import { getI18n } from "@/locales/server"; +import { getToysByOwner } from "@/data/operations"; -const userStats = { - listedToys: 3, - activeRentals: 1, - pendingRequests: 2, -}; +const currentUserId = 1; // Mock logged-in user ID export default async function DashboardOverviewPage() { const t = await getI18n(); + const userToys = getToysByOwner(currentUserId); + + const userStats = { + listedToys: userToys.length, // Real data from DB + activeRentals: 1, // Mock data + pendingRequests: 2, // Mock data + }; + return (
diff --git a/toyshare.db b/toyshare.db index db7a745..55e1ab8 100644 Binary files a/toyshare.db and b/toyshare.db differ diff --git a/toyshare.db-shm b/toyshare.db-shm index 8b4efd5..b1b45ea 100644 Binary files a/toyshare.db-shm and b/toyshare.db-shm differ diff --git a/toyshare.db-wal b/toyshare.db-wal index df16db9..e564ea3 100644 Binary files a/toyshare.db-wal and b/toyshare.db-wal differ