diff --git a/src/app/[locale]/dashboard/my-toys/page.tsx b/src/app/[locale]/dashboard/my-toys/page.tsx
index 339ff4a..86f4575 100644
--- a/src/app/[locale]/dashboard/my-toys/page.tsx
+++ b/src/app/[locale]/dashboard/my-toys/page.tsx
@@ -1,9 +1,10 @@
+
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import ToyCard from "@/components/toys/ToyCard"; // This component would also need translation if it has text
-import { mockToys } from "@/lib/mockData";
+import { mockToys, mockRentalHistory } from "@/lib/mockData";
import Link from "next/link";
-import { PlusCircle, Edit3, Trash2, Eye, ToyBrick as ToyBrickIcon } from "lucide-react"; // Renamed ToyBrick to avoid conflict
+import { PlusCircle, Edit3, Trash2, Eye, ToyBrick as ToyBrickIcon, BarChartHorizontalBig } from "lucide-react"; // Renamed ToyBrick to avoid conflict
import Image from "next/image";
import type { Toy } from "@/types";
import { Badge } from "@/components/ui/badge";
@@ -14,6 +15,16 @@ const userToys = mockToys.filter(toy => toy.ownerId === currentUserId);
export default async function MyToysPage() {
const t = await getI18n();
+
+ const getRentalCountForToy = (toyId: string): number => {
+ return mockRentalHistory.filter(entry => entry.toy.id === toyId && entry.toy.ownerId === currentUserId).length;
+ };
+
+ const userToysWithRentalCount = userToys.map(toy => ({
+ ...toy,
+ rentalCount: getRentalCountForToy(toy.id),
+ }));
+
return (
@@ -29,7 +40,7 @@ export default async function MyToysPage() {
- {userToys.length === 0 ? (
+ {userToysWithRentalCount.length === 0 ? (
@@ -47,8 +58,8 @@ export default async function MyToysPage() {
) : (
- {userToys.map(toy => (
-
+ {userToysWithRentalCount.map(toy => (
+
))}
)}
@@ -58,10 +69,11 @@ export default async function MyToysPage() {
interface ListedToyItemProps {
toy: Toy & {dataAiHint?: string};
- t: (key: string, params?: Record
) => string; // Pass t function for client components or sub-server components
+ t: (key: string, params?: Record) => string;
+ rentalCount: number;
}
-function ListedToyItem({ toy, t }: ListedToyItemProps) {
+function ListedToyItem({ toy, t, rentalCount }: ListedToyItemProps) {
const placeholderHint = toy.dataAiHint || toy.category.toLowerCase() || "toy";
return (
@@ -99,9 +111,19 @@ function ListedToyItem({ toy, t }: ListedToyItemProps) {
{toy.description}
-
-
{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'}
+
+
+ {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/locales/en.ts b/src/locales/en.ts
index 24f5721..f473557 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -82,6 +82,8 @@ export default {
'dashboard.my_toys.view_toy_action': 'View Toy',
'dashboard.my_toys.edit_toy_action': 'Edit Toy',
'dashboard.my_toys.delete_toy_action': 'Delete Toy',
+ 'dashboard.my_toys.rental_count_one': 'Rented 1 time',
+ 'dashboard.my_toys.rental_count_many': 'Rented {count} times',
'dashboard.profile.title': 'Profile Settings',
'dashboard.profile.description': 'Manage your personal information and account settings.',
'dashboard.profile.personal_info_title': 'Personal Information',
diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts
index abb187b..3956a3f 100644
--- a/src/locales/zh-TW.ts
+++ b/src/locales/zh-TW.ts
@@ -82,6 +82,8 @@ export default {
'dashboard.my_toys.view_toy_action': '查看玩具',
'dashboard.my_toys.edit_toy_action': '編輯玩具',
'dashboard.my_toys.delete_toy_action': '刪除玩具',
+ 'dashboard.my_toys.rental_count_one': '已租借 1 次',
+ 'dashboard.my_toys.rental_count_many': '已租借 {count} 次',
'dashboard.profile.title': '個人資料設定',
'dashboard.profile.description': '管理您的個人資訊和帳戶設定。',
'dashboard.profile.personal_info_title': '個人資訊',