can actually see body ID in pet compatibility form
This commit is contained in:
parent
213f30b2f2
commit
e8917936d6
2 changed files with 35 additions and 8 deletions
|
@ -11,10 +11,12 @@ import {
|
||||||
ModalBody,
|
ModalBody,
|
||||||
ModalCloseButton,
|
ModalCloseButton,
|
||||||
ModalContent,
|
ModalContent,
|
||||||
|
ModalFooter,
|
||||||
ModalHeader,
|
ModalHeader,
|
||||||
ModalOverlay,
|
ModalOverlay,
|
||||||
Radio,
|
Radio,
|
||||||
RadioGroup,
|
RadioGroup,
|
||||||
|
Spinner,
|
||||||
} from "@chakra-ui/core";
|
} from "@chakra-ui/core";
|
||||||
import { ExternalLinkIcon } from "@chakra-ui/icons";
|
import { ExternalLinkIcon } from "@chakra-ui/icons";
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ function ItemSupportAppearanceLayerModal({
|
||||||
Layer {itemLayer.id}: {item.name}
|
Layer {itemLayer.id}: {item.name}
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody mb="4" pb="4">
|
<ModalBody>
|
||||||
<Metadata>
|
<Metadata>
|
||||||
<MetadataLabel>ID:</MetadataLabel>
|
<MetadataLabel>ID:</MetadataLabel>
|
||||||
<MetadataValue>{itemLayer.id}</MetadataValue>
|
<MetadataValue>{itemLayer.id}</MetadataValue>
|
||||||
|
@ -88,6 +90,9 @@ function ItemSupportAppearanceLayerModal({
|
||||||
outfitState={outfitState}
|
outfitState={outfitState}
|
||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button colorScheme="green">Save changes</Button>
|
||||||
|
</ModalFooter>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</ModalOverlay>
|
</ModalOverlay>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -99,6 +104,7 @@ function ItemSupportAppearanceLayerPetCompatibility({
|
||||||
itemLayer,
|
itemLayer,
|
||||||
outfitState,
|
outfitState,
|
||||||
}) {
|
}) {
|
||||||
|
const [bodyId, setBodyId] = React.useState(itemLayer.bodyId);
|
||||||
const [selectedBiology, setSelectedBiology] = React.useState({
|
const [selectedBiology, setSelectedBiology] = React.useState({
|
||||||
speciesId: outfitState.speciesId,
|
speciesId: outfitState.speciesId,
|
||||||
colorId: outfitState.colorId,
|
colorId: outfitState.colorId,
|
||||||
|
@ -106,9 +112,13 @@ function ItemSupportAppearanceLayerPetCompatibility({
|
||||||
isValid: true,
|
isValid: true,
|
||||||
});
|
});
|
||||||
const [visibleBiology, setVisibleBiology] = React.useState(selectedBiology);
|
const [visibleBiology, setVisibleBiology] = React.useState(selectedBiology);
|
||||||
console.log(selectedBiology, visibleBiology);
|
|
||||||
|
|
||||||
const { loading, error, visibleLayers } = useOutfitAppearance({
|
const {
|
||||||
|
loading,
|
||||||
|
error,
|
||||||
|
visibleLayers,
|
||||||
|
bodyId: appearanceBodyId,
|
||||||
|
} = useOutfitAppearance({
|
||||||
speciesId: visibleBiology.speciesId,
|
speciesId: visibleBiology.speciesId,
|
||||||
colorId: visibleBiology.colorId,
|
colorId: visibleBiology.colorId,
|
||||||
pose: visibleBiology.pose,
|
pose: visibleBiology.pose,
|
||||||
|
@ -117,13 +127,21 @@ function ItemSupportAppearanceLayerPetCompatibility({
|
||||||
|
|
||||||
const biologyLayers = visibleLayers.filter((l) => l.source === "pet");
|
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 (
|
return (
|
||||||
<FormControl isInvalid={error || !selectedBiology.isValid ? true : false}>
|
<FormControl isInvalid={error || !selectedBiology.isValid ? true : false}>
|
||||||
<FormLabel>Pet compatibility</FormLabel>
|
<FormLabel>Pet compatibility</FormLabel>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
colorScheme="green"
|
colorScheme="green"
|
||||||
value={itemLayer.bodyId}
|
value={bodyId}
|
||||||
onChange={(e) => console.log(e)}
|
onChange={(newBodyId) => setBodyId(newBodyId)}
|
||||||
marginBottom="4"
|
marginBottom="4"
|
||||||
>
|
>
|
||||||
<Radio value="0">
|
<Radio value="0">
|
||||||
|
@ -132,10 +150,16 @@ function ItemSupportAppearanceLayerPetCompatibility({
|
||||||
(Body ID: 0)
|
(Body ID: 0)
|
||||||
</Box>
|
</Box>
|
||||||
</Radio>
|
</Radio>
|
||||||
<Radio as="div" value="100" marginTop="2">
|
<Radio as="div" value={appearanceBodyId} marginTop="2">
|
||||||
Fits all pets with the same body as:{" "}
|
Fits all pets with the same body as:{" "}
|
||||||
<Box display="inline" color="gray.400" fontSize="sm">
|
<Box display="inline" color="gray.400" fontSize="sm">
|
||||||
(Body ID: 100)
|
(Body ID:{" "}
|
||||||
|
{appearanceBodyId == null ? (
|
||||||
|
<Spinner size="sm" />
|
||||||
|
) : (
|
||||||
|
appearanceBodyId
|
||||||
|
)}
|
||||||
|
)
|
||||||
</Box>
|
</Box>
|
||||||
</Radio>
|
</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
@ -157,7 +181,6 @@ function ItemSupportAppearanceLayerPetCompatibility({
|
||||||
speciesId={selectedBiology.speciesId}
|
speciesId={selectedBiology.speciesId}
|
||||||
colorId={selectedBiology.colorId}
|
colorId={selectedBiology.colorId}
|
||||||
idealPose={outfitState.pose}
|
idealPose={outfitState.pose}
|
||||||
isDisabled={itemLayer.bodyId === "0"}
|
|
||||||
size="sm"
|
size="sm"
|
||||||
showPlaceholders
|
showPlaceholders
|
||||||
onChange={(species, color, isValid, pose) => {
|
onChange={(species, color, isValid, pose) => {
|
||||||
|
|
|
@ -77,10 +77,13 @@ export default function useOutfitAppearance(outfitState) {
|
||||||
[data1, itemAppearances]
|
[data1, itemAppearances]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const bodyId = data1?.petAppearance?.bodyId;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading: loading1 || loading2,
|
loading: loading1 || loading2,
|
||||||
error: error1 || error2,
|
error: error1 || error2,
|
||||||
visibleLayers,
|
visibleLayers,
|
||||||
|
bodyId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +137,7 @@ export const itemAppearanceFragment = gql`
|
||||||
export const petAppearanceFragment = gql`
|
export const petAppearanceFragment = gql`
|
||||||
fragment PetAppearanceForOutfitPreview on PetAppearance {
|
fragment PetAppearanceForOutfitPreview on PetAppearance {
|
||||||
id
|
id
|
||||||
|
bodyId
|
||||||
layers {
|
layers {
|
||||||
id
|
id
|
||||||
svgUrl
|
svgUrl
|
||||||
|
|
Loading…
Reference in a new issue