feat(03-05): Explore + pet search — routers GREEN + pages + nav
- explore.listPets: publicProcedure, speciesId/breedId filter, cursor pagination - search.pets: protectedProcedure, ILIKE name+breed OR, cursor pagination - ExploreCard: avatar, breed badge, follower count, FollowButton - /explore: species tabs + breed filter Select + infinite pet grid - /search: debounced input, Pets tab with FollowButton rows, Tags stub - Sidebar: Explore activated, Search added - MobileNav: Explore activated, Notifications placeholder → Search Tests: explore 3/3 GREEN, search.pets 2/2 GREEN; 65 total passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8507fe9489
commit
59a3be27b0
8 files changed
+496
-25
No files matched your search
@@ -0,0 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { FollowButton } from "@/components/social/FollowButton";
|
||||
import { getAvatarUrl } from "@/lib/avatar-url";
|
||||
|
||||
interface ExploreCardPet {
|
||||
id: string;
|
||||
name: string;
|
||||
avatarKey: string | null;
|
||||
species: { name: string };
|
||||
breed: { name: string } | null;
|
||||
_count: { followers: number };
|
||||
}
|
||||
|
||||
interface ExploreCardProps {
|
||||
pet: ExploreCardPet;
|
||||
activePetId: string;
|
||||
}
|
||||
|
||||
export function ExploreCard({ pet, activePetId }: ExploreCardProps) {
|
||||
const avatarUrl = getAvatarUrl(pet.avatarKey);
|
||||
const isOwnPet = pet.id === activePetId;
|
||||
const labelName = pet.breed?.name ?? pet.species.name;
|
||||
const followerCount = pet._count.followers;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-2 p-3 rounded-xl border bg-card hover:bg-muted/50 transition-colors">
|
||||
<Avatar className="w-14 h-14">
|
||||
{avatarUrl && <AvatarImage src={avatarUrl} alt={pet.name} />}
|
||||
<AvatarFallback className="text-sm bg-muted">
|
||||
{pet.name[0]?.toUpperCase() ?? "?"}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<p className="text-sm font-medium text-center truncate max-w-full">
|
||||
{pet.name}
|
||||
</p>
|
||||
|
||||
<Badge variant="secondary" className="text-xs">
|
||||
{labelName}
|
||||
</Badge>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{followerCount === 1 ? "1 follower" : `${followerCount} followers`}
|
||||
</p>
|
||||
|
||||
{isOwnPet ? (
|
||||
<p className="text-xs text-muted-foreground">Your pet</p>
|
||||
) : (
|
||||
<FollowButton
|
||||
followerPetId={activePetId}
|
||||
followeePetId={pet.id}
|
||||
followeeName={pet.name}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import { usePathname, useRouter } from "next/navigation";
|
||||
import {
|
||||
Home,
|
||||
Compass,
|
||||
Search,
|
||||
Plus,
|
||||
Bell,
|
||||
User,
|
||||
ChevronDown,
|
||||
} from "lucide-react";
|
||||
@@ -61,6 +61,8 @@ export function MobileNav({ pets }: MobileNavProps) {
|
||||
// D-05: Home → /feed; also highlight when on / (which redirects to /feed)
|
||||
const isHomePage = pathname === "/feed" || pathname === "/";
|
||||
const isPetsPage = pathname.startsWith("/pets");
|
||||
const isExplorePage = pathname.startsWith("/explore");
|
||||
const isSearchPage = pathname.startsWith("/search");
|
||||
|
||||
return (
|
||||
<div className="lg:hidden fixed bottom-0 left-0 right-0 z-50">
|
||||
@@ -147,14 +149,16 @@ export function MobileNav({ pets }: MobileNavProps) {
|
||||
<span>Home</span>
|
||||
</Link>
|
||||
|
||||
{/* Explore — placeholder, Phase 1 */}
|
||||
<span
|
||||
aria-disabled="true"
|
||||
className="flex flex-col items-center gap-0.5 px-3 py-2 text-xs text-muted-foreground/50 cursor-not-allowed"
|
||||
{/* Explore */}
|
||||
<Link
|
||||
href="/explore"
|
||||
className={`flex flex-col items-center gap-0.5 px-3 py-2 text-xs ${
|
||||
isExplorePage ? "text-orange-500" : "text-muted-foreground"
|
||||
}`}
|
||||
>
|
||||
<Compass className="h-5 w-5" aria-hidden="true" />
|
||||
<span>Explore</span>
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
{/* Post — center, accent-filled. D-01: opens PostTypeSheet */}
|
||||
<button
|
||||
@@ -168,14 +172,16 @@ export function MobileNav({ pets }: MobileNavProps) {
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{/* Notifications — placeholder, Phase 1 */}
|
||||
<span
|
||||
aria-disabled="true"
|
||||
className="flex flex-col items-center gap-0.5 px-3 py-2 text-xs text-muted-foreground/50 cursor-not-allowed"
|
||||
{/* Search */}
|
||||
<Link
|
||||
href="/search"
|
||||
className={`flex flex-col items-center gap-0.5 px-3 py-2 text-xs ${
|
||||
isSearchPage ? "text-orange-500" : "text-muted-foreground"
|
||||
}`}
|
||||
>
|
||||
<Bell className="h-5 w-5" aria-hidden="true" />
|
||||
<span>Alerts</span>
|
||||
</span>
|
||||
<Search className="h-5 w-5" aria-hidden="true" />
|
||||
<span>Search</span>
|
||||
</Link>
|
||||
|
||||
{/* Profile (My Pets) */}
|
||||
<Link
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
Home,
|
||||
Heart,
|
||||
Compass,
|
||||
Search,
|
||||
Bell,
|
||||
MessageCircle,
|
||||
PawPrint,
|
||||
@@ -39,9 +40,10 @@ type SidebarProps = {
|
||||
};
|
||||
|
||||
const navLinks = [
|
||||
{ href: "/feed", label: "Home", icon: Home, active: true }, // D-05: Home → /feed
|
||||
{ href: "/feed", label: "Home", icon: Home, active: true },
|
||||
{ href: "/pets", label: "My Pets", icon: Heart, active: true },
|
||||
{ href: "/explore", label: "Explore", icon: Compass, active: false },
|
||||
{ href: "/explore", label: "Explore", icon: Compass, active: true },
|
||||
{ href: "/search", label: "Search", icon: Search, active: true },
|
||||
{ href: "/notifications", label: "Notifications", icon: Bell, active: false },
|
||||
{ href: "/messages", label: "Messages", icon: MessageCircle, active: false },
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user