import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { History, ToyBrick } from "lucide-react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import Image from "next/image"; import type { RentalHistoryEntry } from "@/types"; import { mockRentalHistory } from "@/lib/mockData"; import { getI18n } from "@/locales/server"; import type { Locale } from "@/locales/server"; import { Badge } from "@/components/ui/badge"; import { format } from 'date-fns'; const currentUserId = 1; // Assume this is the logged-in user's ID export default async function RentalHistoryPage({ params }: { params: { locale: Locale } }) { const t = await getI18n(); const locale = params.locale; // Filter rental history for the current user const userRentalHistory = mockRentalHistory.filter(entry => entry.userId === currentUserId); return (

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

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

{userRentalHistory.length === 0 ? ( {t('dashboard.rental_history.no_history_title')} {t('dashboard.rental_history.no_history_description')} ) : (
{userRentalHistory.map(entry => ( ))}
)}
); } interface RentalHistoryItemCardProps { item: RentalHistoryEntry; t: (key: string, params?: Record) => string; locale: Locale; } function RentalHistoryItemCard({ item, t, locale }: RentalHistoryItemCardProps) { const placeholderHint = item.dataAiHint || item.toy.category.toLowerCase() || "toy"; const formattedStartDate = format(new Date(item.rentalStartDate), 'PP'); const formattedEndDate = format(new Date(item.rentalEndDate), 'PP'); const getStatusTextKey = (status: RentalHistoryEntry['status']) => { if (status === 'Completed') return 'rental_history_card.status_completed'; if (status === 'Returned') return 'rental_history_card.status_returned'; return ''; } return (
{item.toy.name}
{item.toy.name} {t(getStatusTextKey(item.status))}

{t('rental_history_card.rented_from')}: {item.toy.ownerName}

{t('rental_history_card.rental_period')}: {formattedStartDate} - {formattedEndDate}

{t('rental_history_card.cost')}: ${item.totalCost.toFixed(2)}

{t('rental_history_card.status')}: {t(getStatusTextKey(item.status))}

); }