From 88576a15a2c621e6202c3178b53fa02586ca5737 Mon Sep 17 00:00:00 2001 From: Indigo Tang Date: Mon, 9 Jun 2025 03:39:27 +0000 Subject: [PATCH] dashboard/rentals page is blank --- src/app/[locale]/dashboard/rentals/page.tsx | 91 +++++++++++++++++++++ src/locales/en.ts | 9 ++ src/locales/zh-TW.ts | 9 ++ 3 files changed, 109 insertions(+) create mode 100644 src/app/[locale]/dashboard/rentals/page.tsx diff --git a/src/app/[locale]/dashboard/rentals/page.tsx b/src/app/[locale]/dashboard/rentals/page.tsx new file mode 100644 index 0000000..6cc7999 --- /dev/null +++ b/src/app/[locale]/dashboard/rentals/page.tsx @@ -0,0 +1,91 @@ +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { ShoppingBag, ToyBrick } from "lucide-react"; +import Link from "next/link"; +import { Button } from "@/components/ui/button"; +import Image from "next/image"; +import type { Toy } from "@/types"; +import { mockToys } from "@/lib/mockData"; +import { getI18n } from "@/locales/server"; + +const rentedToys: (Toy & { rentalEndDate?: string, dataAiHint?: string })[] = [ + { ...mockToys[1], rentalEndDate: "2024-08-15", dataAiHint: mockToys[1]?.category.toLowerCase() }, + { ...mockToys[4], rentalEndDate: "2024-09-01", dataAiHint: mockToys[4]?.category.toLowerCase() }, +]; + +export default async function MyRentalsPage() { + const t = await getI18n(); + + return ( +
+
+

{t('dashboard.rentals.title')}

+

{t('dashboard.rentals.description')}

+
+ + {rentedToys.length === 0 ? ( + + + + {t('dashboard.rentals.no_rentals_title')} + {t('dashboard.rentals.no_rentals_description')} + + + + + + + + ) : ( +
+ {rentedToys.map(toy => ( + + ))} +
+ )} +
+ ); +} + +interface RentalItemCardProps { + toy: Toy & { rentalEndDate?: string, dataAiHint?: string }; + t: (key: string, params?: Record) => string; +} + +function RentalItemCard({ toy, t }: RentalItemCardProps) { + const placeholderHint = toy.dataAiHint || toy.category.toLowerCase() || "toy"; + return ( + +
+
+ {toy.name} +
+
+ {toy.name} +

{t('dashboard.rentals.rented_from', { ownerName: toy.ownerName })}

+ {toy.rentalEndDate && ( +

+ {t('dashboard.rentals.rental_ends', { date: new Date(toy.rentalEndDate).toLocaleDateString() })} +

+ )} +

{toy.description}

+
+ + + + +
+
+
+
+ ); +} diff --git a/src/locales/en.ts b/src/locales/en.ts index c7059e7..04e8f1a 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -120,4 +120,13 @@ export default { 'add_toy_form.list_button': 'List My Toy', 'add_toy_form.saving_button': 'Saving Changes...', 'add_toy_form.listing_button': 'Listing Toy...', + 'dashboard.rentals.title': 'My Rentals', + 'dashboard.rentals.description': 'Toys you are currently renting from others.', + 'dashboard.rentals.no_rentals_title': 'No Active Rentals', + 'dashboard.rentals.no_rentals_description': "You haven't rented any toys yet. Explore available toys and find your next adventure!", + 'dashboard.rentals.browse_toys_button': 'Browse Toys', + 'dashboard.rentals.rented_from': 'Rented from: {ownerName}', + 'dashboard.rentals.rental_ends': 'Rental ends: {date}', + 'dashboard.rentals.view_toy_details_button': 'View Toy Details', + 'dashboard.rentals.contact_owner_button': 'Contact Owner', } as const; diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index 6f95884..f0d4930 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -120,4 +120,13 @@ export default { 'add_toy_form.list_button': '列出我的玩具', 'add_toy_form.saving_button': '儲存變更中...', 'add_toy_form.listing_button': '列出玩具中...', + 'dashboard.rentals.title': '我的租借', + 'dashboard.rentals.description': '您目前正在向他人租借的玩具。', + 'dashboard.rentals.no_rentals_title': '沒有進行中的租借', + 'dashboard.rentals.no_rentals_description': '您尚未租借任何玩具。探索可用玩具,尋找您的下一次冒險!', + 'dashboard.rentals.browse_toys_button': '瀏覽玩具', + 'dashboard.rentals.rented_from': '租借自:{ownerName}', + 'dashboard.rentals.rental_ends': '租借結束於:{date}', + 'dashboard.rentals.view_toy_details_button': '查看玩具詳情', + 'dashboard.rentals.contact_owner_button': '聯絡擁有者', } as const;