2020-09-06 23:32:04 -07:00
|
|
|
import React from "react";
|
2020-09-06 23:49:04 -07:00
|
|
|
import { Badge, Box, SimpleGrid } from "@chakra-ui/core";
|
2020-09-06 23:32:04 -07:00
|
|
|
import gql from "graphql-tag";
|
|
|
|
import { useQuery } from "@apollo/client";
|
|
|
|
|
|
|
|
import HangerSpinner from "./components/HangerSpinner";
|
2020-09-06 23:49:04 -07:00
|
|
|
import { Heading1, Heading2 } from "./util";
|
|
|
|
import ItemSummary, { ItemSummaryBadgeList } from "./components/ItemSummary";
|
2020-09-06 23:32:04 -07:00
|
|
|
|
|
|
|
function ModelingPage() {
|
|
|
|
return (
|
|
|
|
<Box>
|
|
|
|
<Heading1 marginBottom="2">Modeling Hub</Heading1>
|
2020-09-06 23:49:04 -07:00
|
|
|
<Heading2 marginBottom="2">Item models we need</Heading2>
|
2020-09-06 23:32:04 -07:00
|
|
|
<ItemModelsList />
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ItemModelsList() {
|
|
|
|
const { loading, error, data } = useQuery(gql`
|
|
|
|
query ModelingPage {
|
|
|
|
itemsThatNeedModels {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
thumbnailUrl
|
|
|
|
speciesThatNeedModels {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
return (
|
|
|
|
<Box display="flex" justifyContent="center">
|
|
|
|
<HangerSpinner />
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <Box color="red.400">{error.message}</Box>;
|
|
|
|
}
|
|
|
|
|
2020-09-06 23:49:04 -07:00
|
|
|
const items = data.itemsThatNeedModels
|
|
|
|
// enough MMEs are broken that I just don't want to deal right now!
|
|
|
|
.filter((item) => !item.name.includes("MME"))
|
|
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
2020-09-06 23:32:04 -07:00
|
|
|
|
|
|
|
return (
|
2020-09-06 23:49:04 -07:00
|
|
|
<SimpleGrid columns={{ sm: 1, lg: 2 }} spacing="6">
|
2020-09-06 23:32:04 -07:00
|
|
|
{items.map((item) => (
|
2020-09-06 23:49:04 -07:00
|
|
|
<ItemModelCard key={item.id} item={item} />
|
2020-09-06 23:32:04 -07:00
|
|
|
))}
|
2020-09-06 23:49:04 -07:00
|
|
|
</SimpleGrid>
|
2020-09-06 23:32:04 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-06 23:49:04 -07:00
|
|
|
function ItemModelCard({ item, ...props }) {
|
2020-09-06 23:32:04 -07:00
|
|
|
return (
|
2020-09-06 23:49:04 -07:00
|
|
|
<Box p="2" boxShadow="lg" borderRadius="lg" width="400px" {...props}>
|
|
|
|
<ItemSummary item={item} badges={<ItemModelBadges item={item} />} />
|
2020-09-06 23:32:04 -07:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-06 23:49:04 -07:00
|
|
|
function ItemModelBadges({ item }) {
|
|
|
|
return (
|
|
|
|
<ItemSummaryBadgeList>
|
|
|
|
{item.speciesThatNeedModels.map((species) => (
|
|
|
|
<Badge>{species.name}</Badge>
|
|
|
|
))}
|
|
|
|
</ItemSummaryBadgeList>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-06 23:32:04 -07:00
|
|
|
export default ModelingPage;
|