"use client"; import { useAvatarOutfits } from "@/hooks/roblox/useAvatarOutfits"; import { Button } from "@/components/ui/button"; import LazyLoadedImage from "../util/LazyLoadedImage"; import { StupidHoverThing } from "../util/MiscStuff"; import { loadThumbnails } from "@/lib/thumbnailLoader"; import { useCurrentAccount } from "@/hooks/roblox/useCurrentAccount"; import { useEffect, useMemo, useState } from "react"; import { Search, X } from "lucide-react"; import { Input } from "@/components/ui/input"; type OutfitSelectorProps = { setVisible: (visible: boolean) => void; updateOutfit: ( outfit: { id: number }, acc: { id: number } ) => Promise; }; export function OutfitSelector({ setVisible, updateOutfit }: OutfitSelectorProps) { const outfits = useAvatarOutfits(); const acc = useCurrentAccount(); const [query, setQuery] = useState(""); useEffect(() => { if (!outfits || outfits.length === 0) return; loadThumbnails( outfits.map((a) => ({ type: "Outfit", targetId: a.id, format: "webp", size: "420x420" })) ).catch(() => {}); }, [outfits]); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") setVisible(false); }; window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); }, [setVisible]); const isLoading = outfits === null; const hasOutfits = Array.isArray(outfits) && outfits.length > 0; const filteredOutfits = useMemo(() => { if (!hasOutfits) return []; if (!query.trim()) return outfits; const lowered = query.trim().toLowerCase(); return outfits.filter((outfit) => outfit.name.toLowerCase().includes(lowered) ); }, [hasOutfits, outfits, query]); return (
setVisible(false)} >
event.stopPropagation()} >

Outfits

Pick a look to update your avatar instantly.

setQuery(event.target.value) } placeholder="Search outfits" className="pl-9" />
{!acc ? (
Sign in to load your outfits.
) : isLoading ? (
{Array.from({ length: 8 }).map((_, index) => (
))}
) : hasOutfits ? (

{filteredOutfits.length} outfit {filteredOutfits.length === 1 ? "" : "s"}

{filteredOutfits.map( (outfit: { id: number; name: string }) => ( ) )}
{filteredOutfits.length === 0 ? (
No outfits match that search yet.
) : null}
) : (
No outfits found yet. Make one in the Roblox avatar editor, then come back here.
)}
); }