import Link from 'next/link'; import { Button } from '@/components/ui/button'; import ToyList from '@/components/toys/ToyList'; import { mockToys } from '@/lib/mockData'; import type { Toy } from '@/types'; import { getI18n, getStaticParams as getLocaleStaticParams } from '@/locales/server'; import { Home, UserCircle } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { ToyBrick } from 'lucide-react'; import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"; interface OwnerToysPageProps { params: { ownerId: string; locale: string }; } // Mock owner profiles - can be expanded or moved to a data file later const mockOwnerProfiles: Record = { 'user1': { // Alice Wonderland name: 'Alice W.', // Can be different from toy.ownerName for display avatarUrl: 'https://placehold.co/100x100.png?text=AW', bio: "Lover of imaginative play and sharing joy. I have a collection of classic storybooks and dress-up costumes that my kids have outgrown but still have lots of life left in them!" }, 'user2': { // Bob The Builder name: 'Bob T.B.', avatarUrl: 'https://placehold.co/100x100.png?text=BT', bio: "Can we fix it? Yes, we can! Sharing my collection of construction toys, tools, and playsets. Always happy to help another budding builder." }, 'user3': { // Carol Danvers name: 'Captain C.', avatarUrl: 'https://placehold.co/100x100.png?text=CD', bio: "Higher, further, faster. Sharing toys that inspire adventure, courage, and exploration. My collection includes superhero action figures and space-themed playsets." } }; async function getOwnerToys(ownerId: string): Promise { await new Promise(resolve => setTimeout(resolve, 100)); // Simulate fetch return mockToys.filter(toy => toy.ownerId === ownerId); } export default async function OwnerToysPage({ params }: OwnerToysPageProps) { const t = await getI18n(); const ownerToys = await getOwnerToys(params.ownerId); const ownerProfile = mockOwnerProfiles[params.ownerId]; const ownerNameFromToys = ownerToys.length > 0 ? ownerToys[0].ownerName : undefined; let displayOwnerName = ownerProfile?.name || ownerNameFromToys || t('owner_toys.unknown_owner'); const pageTitle = displayOwnerName !== t('owner_toys.unknown_owner') ? t('owner_toys.title_specific', { ownerName: displayOwnerName }) : t('owner_toys.title_generic'); return (

{pageTitle}

{ownerProfile && (
{displayOwnerName ? displayOwnerName.split(' ').map(n => n[0]).join('').toUpperCase() : }
{t('owner_toys.about_owner', { ownerName: displayOwnerName })} {/* Display the original ownerName from toy data if it's different and available */} {ownerNameFromToys && ownerNameFromToys !== displayOwnerName && ( {t('toy_details.owner')}: {ownerNameFromToys} )}

{ownerProfile.bio}

)} {ownerToys.length > 0 ? ( ({...toy, dataAiHint: toy.category.toLowerCase()}))} /> ) : ( {displayOwnerName !== t('owner_toys.unknown_owner') ? t('owner_toys.no_toys_listed_by', { ownerName: displayOwnerName }) : t('owner_toys.owner_not_found')} {displayOwnerName !== t('owner_toys.unknown_owner') && {t('home.explore_toys')}} )}
); } export async function generateStaticParams() { const localeParams = getLocaleStaticParams(); const ownerIds = Array.from(new Set(mockToys.map(toy => toy.ownerId))); const ownerParams = ownerIds.map(id => ({ ownerId: id })); return localeParams.flatMap(lang => ownerParams.map(owner => ({ ...lang, ...owner })) ); }