import React from "react"; import { Box, Editable, EditablePreview, EditableInput, Flex, Grid, Heading, Icon, IconButton, Image, Input, InputGroup, InputLeftElement, InputRightElement, PseudoBox, Skeleton, Stack, Text, useToast, } from "@chakra-ui/core"; import ItemList, { ItemListSkeleton } from "./ItemList"; import useOutfitState from "./useOutfitState.js"; import { ITEMS } from "./data"; function WardrobePage() { const { loading, error, data, wearItem } = useOutfitState(); const [searchQuery, setSearchQuery] = React.useState(""); const toast = useToast(); const [hasSentToast, setHasSentToast] = React.useState(false); const wearItemAndToast = React.useCallback( (itemIdToAdd) => { wearItem(itemIdToAdd); if (!hasSentToast) { setTimeout(() => { toast({ title: "So, the outfit didn't change 😅", description: "This is a prototype, and the outfit preview is static right " + "now! But the list animation is good, yeah? Nice and smooth 😊", status: "warning", isClosable: true, duration: 10000, position: window.innerWidth < 992 ? "top" : "bottom-left", }); }, 3000); setHasSentToast(true); } }, [toast, wearItem, hasSentToast, setHasSentToast] ); React.useEffect(() => { if (error) { toast({ title: "We couldn't load this outfit 😖", description: "Please reload the page to try again. Sorry!", status: "error", isClosable: true, duration: Infinity, }); } }, [error, toast]); return ( {searchQuery ? ( ) : ( )} ); } function OutfitPreview() { return ( ); } function SearchToolbar({ query, onChange }) { return ( onChange(e.target.value)} onKeyDown={(e) => { if (e.key === "Escape") { onChange(""); e.target.blur(); } }} /> {query && ( onChange("")} /> )} ); } function SearchPanel({ query, wornItemIds, onWearItem }) { const normalize = (s) => s.toLowerCase(); const results = ITEMS.filter((item) => normalize(item.name).includes(normalize(query)) ); results.sort((a, b) => a.name.localeCompare(b.name)); const resultsSection = results.length > 0 ? ( ) : ( We couldn't find any matching items{" "} 🤔 {" "} Try again? ); return ( Searching for "{query}" {resultsSection} ); } function ItemsPanel({ zonesAndItems, loading, onWearItem }) { return ( {loading && [1, 2, 3].map((i) => ( ))} {!loading && zonesAndItems.map(({ zoneName, items, wornItemId }) => ( {zoneName} ))} ); } function OutfitHeading() { return ( {({ isEditing, onRequestEdit }) => ( <> {!isEditing && ( )} )} ); } function OutfitNameEditButton({ onRequestEdit }) { return ( ); } function Heading1({ children, ...props }) { return ( {children} ); } function Heading2({ children, ...props }) { return ( {children} ); } export default WardrobePage;