import { gql, useQuery } from "@apollo/client";
import { QuestionIcon } from "@chakra-ui/icons";
import { Box, Flex, Wrap, WrapItem } from "@chakra-ui/layout";
import {
Popover,
PopoverArrow,
PopoverBody,
PopoverContent,
PopoverTrigger,
} from "@chakra-ui/popover";
import { Link } from "react-router-dom";
import HangerSpinner from "./components/HangerSpinner";
import {
getValidPoses,
useAllValidPetPoses,
} from "./components/SpeciesColorPicker";
import { ErrorMessage, Heading1 } from "./util";
import useSupport from "./WardrobePage/support/useSupport";
function SupportPetAppearancesPage() {
const { isSupportUser } = useSupport();
if (!isSupportUser) {
return "Sorry, this page is only for Support users!";
}
return (
<>
Support: Pet appearances
>
);
}
function UnlabeledPetAppearancesList() {
const { loading, error, speciesColorPairs } = useUnlabeledPetAppearances();
return (
These species/color combinations have some UNKNOWN
{" "}
appearances that need labeled! Please take a look!
This includes species/color combinations that have at least one{" "}
UNKNOWN
pose, and are missing at least one of the
standard 6 mood/gender-presentation poses.
{loading && (
)}
{error && {error.message}}
{speciesColorPairs.length > 0 && (
{speciesColorPairs.map(({ species, color }) => (
))}
)}
);
}
function SpeciesColorEditorLink({ species, color }) {
return (
{color.name} {species.name}
);
}
function useUnlabeledPetAppearances() {
const {
loading: loadingValids,
error: errorValids,
valids,
} = useAllValidPetPoses({ headers: { "Cache-Control": "no-cache" } });
const { loading: loadingGQL, error: errorGQL, data } = useQuery(gql`
query SupportUnlabeledPetAppearances {
allColors {
id
name
}
allSpecies {
id
name
}
}
`);
const loading = loadingValids || loadingGQL;
const error = errorValids || errorGQL;
const speciesColorPairs =
valids && data?.allColors && data?.allSpecies
? data?.allSpecies
.map((species) => data.allColors.map((color) => ({ species, color })))
.flat()
.filter(({ species, color }) => {
const poses = getValidPoses(valids, species.id, color.id);
const hasAllStandardPoses =
poses.has("HAPPY_MASC") &&
poses.has("HAPPY_FEM") &&
poses.has("SAD_MASC") &&
poses.has("SAD_FEM") &&
poses.has("SICK_MASC") &&
poses.has("SICK_FEM");
const hasAtLeastOneUnknownPose = poses.has("UNKNOWN");
return !hasAllStandardPoses && hasAtLeastOneUnknownPose;
})
.sort((a, b) =>
`${a.species.name} ${a.color.name}`.localeCompare(
`${b.species.name} ${b.color.name}`
)
)
: [];
return {
loading,
error,
speciesColorPairs,
};
}
export default SupportPetAppearancesPage;