import * as React from "react";
import {
Button,
Box,
FormControl,
FormErrorMessage,
FormHelperText,
FormLabel,
HStack,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Radio,
RadioGroup,
Spinner,
} from "@chakra-ui/core";
import { ExternalLinkIcon } from "@chakra-ui/icons";
import { OutfitLayers } from "../../components/OutfitPreview";
import SpeciesColorPicker from "../../components/SpeciesColorPicker";
import useOutfitAppearance from "../../components/useOutfitAppearance";
function ItemSupportAppearanceLayerModal({
item,
itemLayer,
outfitState,
isOpen,
onClose,
}) {
return (
Layer {itemLayer.id}: {item.name}
ID:
{itemLayer.id}
Zone:
{itemLayer.zone.label} ({itemLayer.zone.id})
Assets:
{itemLayer.svgUrl ? (
) : (
)}
{itemLayer.imageUrl ? (
) : (
)}
);
}
function ItemSupportAppearanceLayerPetCompatibility({
item,
itemLayer,
outfitState,
}) {
const [bodyId, setBodyId] = React.useState(itemLayer.bodyId);
const [selectedBiology, setSelectedBiology] = React.useState({
speciesId: outfitState.speciesId,
colorId: outfitState.colorId,
pose: outfitState.pose,
isValid: true,
});
const [visibleBiology, setVisibleBiology] = React.useState(selectedBiology);
const {
loading,
error,
visibleLayers,
bodyId: appearanceBodyId,
} = useOutfitAppearance({
speciesId: visibleBiology.speciesId,
colorId: visibleBiology.colorId,
pose: visibleBiology.pose,
wornItemIds: [item.id],
});
const biologyLayers = visibleLayers.filter((l) => l.source === "pet");
// When the appearance body ID changes, select it as the new body ID. (This
// is an effect because it happens after the appearance finishes loading!)
React.useEffect(() => {
if (bodyId !== "0") {
setBodyId(appearanceBodyId);
}
}, [bodyId, appearanceBodyId]);
return (
Pet compatibility
setBodyId(newBodyId)}
marginBottom="4"
>
Fits all pets{" "}
(Body ID: 0)
Fits all pets with the same body as:{" "}
(Body ID:{" "}
{appearanceBodyId == null ? (
) : (
appearanceBodyId
)}
)
{
const speciesId = species.id;
const colorId = color.id;
setSelectedBiology({ speciesId, colorId, isValid, pose });
if (isValid) {
setVisibleBiology({ speciesId, colorId, isValid, pose });
}
}}
/>
{!error && (
If it doesn't look right, try some other options until it does!
)}
{error && {error.message}}
);
}
function Metadata({ children }) {
return (
{children}
);
}
function MetadataLabel({ children }) {
return (
{children}
);
}
function MetadataValue({ children }) {
return (
{children}
);
}
export default ItemSupportAppearanceLayerModal;