"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 } from "react"; import { X } from "lucide-react"; 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(); 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; return (
setVisible(false)} >
event.stopPropagation()} >

Outfits

Pick a look to update your avatar instantly.

{!acc ? (
Sign in to load your outfits.
) : isLoading ? (
{Array.from({ length: 8 }).map((_, index) => (
))}
) : hasOutfits ? (
{outfits.map((outfit: { id: number; name: string }) => ( ))}
) : (
No outfits found yet. Make one in the Roblox avatar editor, then come back here.
)}
); }