crush-level-web/src/app/(main)/user/[userId]/components/UserProfileTabs.tsx

50 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-11-28 06:31:36 +00:00
import { TabsList, TabsTrigger } from '@/components/ui/tabs'
import { UserTab } from '../types'
import { useAIUser } from '../context/aiUser'
import { Button } from '@/components/ui/button'
import { useRouter } from 'next/navigation'
2025-11-13 08:38:25 +00:00
const UserProfileTabs = ({ currentTab }: { currentTab: UserTab }) => {
2025-11-28 06:31:36 +00:00
const { isOwner, userId } = useAIUser()
const router = useRouter()
2025-11-13 08:38:25 +00:00
const handleCreatePhoto = () => {
2025-11-28 06:31:36 +00:00
router.push(`/generate/image-2-image?id=${userId}`)
2025-11-13 08:38:25 +00:00
}
return (
<div className="flex items-center justify-between gap-4">
{/* Tab 列表 */}
2025-11-28 06:31:36 +00:00
<TabsList className="mb-0 h-auto w-fit justify-start gap-4 bg-transparent p-0">
<TabsTrigger
2025-11-13 08:38:25 +00:00
value={UserTab.About}
2025-11-28 06:31:36 +00:00
className="relative h-auto cursor-pointer flex-col gap-1"
2025-11-13 08:38:25 +00:00
>
<span className="txt-title-m text-txt-secondary-normal group-data-[state=active]:text-txt-primary-normal">
About
</span>
2025-11-28 06:31:36 +00:00
<div className="bg-primary-normal h-1 w-5 rounded opacity-0 group-data-[state=active]:opacity-100" />
2025-11-13 08:38:25 +00:00
</TabsTrigger>
2025-11-28 06:31:36 +00:00
<TabsTrigger
2025-11-13 08:38:25 +00:00
value={UserTab.Album}
2025-11-28 06:31:36 +00:00
className="relative h-auto cursor-pointer flex-col gap-1"
2025-11-13 08:38:25 +00:00
>
<span className="txt-title-m text-txt-secondary-normal group-data-[state=active]:text-txt-primary-normal">
Album
</span>
2025-11-28 06:31:36 +00:00
<div className="bg-primary-normal h-1 w-5 rounded opacity-0 group-data-[state=active]:opacity-100" />
2025-11-13 08:38:25 +00:00
</TabsTrigger>
</TabsList>
2025-11-28 06:31:36 +00:00
{isOwner && currentTab === UserTab.Album && (
<Button variant="secondary" size="small" onClick={handleCreatePhoto}>
Generate
</Button>
)}
2025-11-13 08:38:25 +00:00
</div>
2025-11-28 06:31:36 +00:00
)
2025-11-13 08:38:25 +00:00
}
2025-11-28 06:31:36 +00:00
export default UserProfileTabs