diff --git a/src/app/[locale]/owner/[ownerId]/toys/page.tsx b/src/app/[locale]/owner/[ownerId]/toys/page.tsx index 6ca8def..49b23ff 100644 --- a/src/app/[locale]/owner/[ownerId]/toys/page.tsx +++ b/src/app/[locale]/owner/[ownerId]/toys/page.tsx @@ -1,17 +1,39 @@ + 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 { ArrowLeft, Home } from 'lucide-react'; +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); @@ -20,35 +42,55 @@ async function getOwnerToys(ownerId: string): Promise { 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 ownerName: string | undefined; - if (ownerToys.length > 0) { - ownerName = ownerToys[0].ownerName; - } else { - // Attempt to find owner name even if they have no toys, if we had a user list - // For now, we rely on toys or show a generic message if ownerId itself is unknown - const ownerFromAnyToy = mockToys.find(toy => toy.ownerId === params.ownerId); - if (ownerFromAnyToy) { - ownerName = ownerFromAnyToy.ownerName; - } - } - - const pageTitle = ownerName - ? t('owner_toys.title', { ownerName }) - : t('owner_toys.owner_not_found'); + 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()}))} /> ) : ( @@ -56,12 +98,14 @@ export default async function OwnerToysPage({ params }: OwnerToysPageProps) { - {ownerName ? t('owner_toys.no_toys_listed_by', { ownerName }) : t('owner_toys.owner_not_found')} + {displayOwnerName !== t('owner_toys.unknown_owner') + ? t('owner_toys.no_toys_listed_by', { ownerName: displayOwnerName }) + : t('owner_toys.owner_not_found')} - {ownerName && {t('home.explore_toys')}} + {displayOwnerName !== t('owner_toys.unknown_owner') && {t('home.explore_toys')}} - + @@ -74,7 +118,7 @@ export default async function OwnerToysPage({ params }: OwnerToysPageProps) { } export async function generateStaticParams() { - const localeParams = getLocaleStaticParams(); // e.g. [{ locale: 'en' }, { locale: 'zh-TW' }] + const localeParams = getLocaleStaticParams(); const ownerIds = Array.from(new Set(mockToys.map(toy => toy.ownerId))); const ownerParams = ownerIds.map(id => ({ ownerId: id })); diff --git a/src/locales/en.ts b/src/locales/en.ts index 2cc9f86..7f4a374 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -151,11 +151,14 @@ export default { 'dashboard.requests.status_pending': 'Pending', 'dashboard.requests.status_approved': 'Approved', 'dashboard.requests.status_declined': 'Declined', - 'owner_toys.title': "{ownerName}'s Shared Toys", + 'owner_toys.title_specific': "{ownerName}'s Toy Collection", + 'owner_toys.title_generic': "Owner's Toy Collection", + 'owner_toys.about_owner': "About {ownerName}", 'owner_toys.no_toys_listed_by': '{ownerName} has not listed any toys yet.', - 'owner_toys.owner_not_found': 'Owner not found or has no toys listed.', + 'owner_toys.owner_not_found': 'Owner profile not found or they have no toys listed.', 'owner_toys.back_to_home': 'Back to Home', 'owner_toys.unknown_owner': 'Unknown Owner', + 'owner_toys.unknown_owner_simple': 'This Owner', 'toy_categories.educational': 'Educational', 'toy_categories.vehicles': 'Vehicles', 'toy_categories.electronics': 'Electronics', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index 09da941..4e3cb08 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -151,11 +151,14 @@ export default { 'dashboard.requests.status_pending': '待處理', 'dashboard.requests.status_approved': '已批准', 'dashboard.requests.status_declined': '已拒絕', - 'owner_toys.title': '{ownerName} 分享的玩具', + 'owner_toys.title_specific': "{ownerName}的玩具收藏", + 'owner_toys.title_generic': "擁有者的玩具收藏", + 'owner_toys.about_owner': "關於 {ownerName}", 'owner_toys.no_toys_listed_by': '{ownerName} 目前沒有列出任何玩具。', - 'owner_toys.owner_not_found': '找不到擁有者或該擁有者沒有列出任何玩具。', + 'owner_toys.owner_not_found': '找不到擁有者資訊或該擁有者沒有列出任何玩具。', 'owner_toys.back_to_home': '返回首頁', 'owner_toys.unknown_owner': '未知擁有者', + 'owner_toys.unknown_owner_simple': '此擁有者', 'toy_categories.educational': '教育類', 'toy_categories.vehicles': '交通工具', 'toy_categories.electronics': '電子玩具',