import React from "react";
import { Box, Center, Flex, Wrap, WrapItem } from "@chakra-ui/react";
import { ClassNames } from "@emotion/react";
import gql from "graphql-tag";
import { useQuery } from "@apollo/client";
import { Link } from "react-router-dom";
import { Heading1, MajorErrorMessage, useCommonStyles } from "./util";
import HangerSpinner from "./components/HangerSpinner";
import OutfitThumbnail from "./components/OutfitThumbnail";
import useRequireLogin from "./components/useRequireLogin";
import WIPCallout from "./components/WIPCallout";
function UserOutfitsPage() {
return (
Your outfits
);
}
function UserOutfitsPageContent() {
const { isLoading: userLoading } = useRequireLogin();
const { loading: queryLoading, error, data } = useQuery(
gql`
query UserOutfitsPageContent {
currentUser {
id
outfits {
id
name
updatedAt
# For alt text
petAppearance {
species {
id
name
}
color {
id
name
}
}
wornItems {
id
name
}
}
}
}
`,
{
context: { sendAuth: true },
skip: userLoading,
}
);
if (userLoading || queryLoading) {
return (
);
}
if (error) {
return ;
}
const outfits = data.currentUser.outfits;
if (outfits.length === 0) {
return (
You don't have any outfits yet. Maybe you can create some!
);
}
return (
{outfits.map((outfit) => (
))}
);
}
function OutfitCard({ outfit }) {
const image = (
{({ css }) => (
)}
);
return (
);
}
function OutfitCardLayout({ image, caption }) {
const { brightBackground } = useCommonStyles();
return (
{image}
{caption}
);
}
function buildOutfitAltText(outfit) {
const { petAppearance, wornItems } = outfit;
const { species, color } = petAppearance;
let altText = "";
const petDescription = `${color.name} ${species.name}`;
altText += petDescription;
if (wornItems.length > 0) {
const itemNames = wornItems
.map((item) => item.name)
.sort()
.join(", ");
altText += ` wearing ${itemNames}`;
}
return altText;
}
export default UserOutfitsPage;