import React from "react";
import gql from "graphql-tag";
import { useQuery } from "@apollo/react-hooks";
import { Flex, Image, Spinner, Text, Icon, Box } from "@chakra-ui/core";
import { Delay } from "./util";
function OutfitPreview({ itemIds, speciesId, colorId }) {
const { loading, error, data } = useQuery(
gql`
query($itemIds: [ID!]!, $speciesId: ID!, $colorId: ID!) {
petAppearance(speciesId: $speciesId, colorId: $colorId) {
layers {
id
imageUrl(size: SIZE_600)
zone {
depth
}
}
}
items(ids: $itemIds) {
id
appearanceOn(speciesId: $speciesId, colorId: $colorId) {
layers {
id
imageUrl(size: SIZE_600)
zone {
depth
}
}
}
}
}
`,
{ variables: { itemIds, speciesId, colorId } }
);
if (loading) {
return (
);
}
if (error) {
return (
Could not load preview. Try again?
);
}
const allLayers = [
...data.petAppearance.layers,
...data.items.map((i) => i.appearanceOn.layers).flat(),
];
allLayers.sort((a, b) => a.zone.depth - b.zone.depth);
return (
{allLayers.map((layer) => (
))}
);
}
function FullScreenCenter({ children }) {
return (
{children}
);
}
export default OutfitPreview;