add button to clear outfit
This commit is contained in:
parent
177aedc09d
commit
3092cf9a51
2 changed files with 25 additions and 3 deletions
|
@ -12,6 +12,7 @@ import {
|
||||||
ModalFooter,
|
ModalFooter,
|
||||||
FormErrorMessage,
|
FormErrorMessage,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
Box,
|
||||||
} from "@chakra-ui/core";
|
} from "@chakra-ui/core";
|
||||||
|
|
||||||
function OutfitResetModal({ isOpen, onClose, dispatchToOutfit }) {
|
function OutfitResetModal({ isOpen, onClose, dispatchToOutfit }) {
|
||||||
|
@ -36,6 +37,17 @@ function OutfitResetModal({ isOpen, onClose, dispatchToOutfit }) {
|
||||||
onComplete
|
onComplete
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const clearOutfit = () => {
|
||||||
|
dispatchToOutfit({
|
||||||
|
type: "reset",
|
||||||
|
name: "",
|
||||||
|
wornItemIds: [],
|
||||||
|
closetedItemIds: [],
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
setPetName("");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onClose={onClose}>
|
<Modal isOpen={isOpen} onClose={onClose}>
|
||||||
<ModalOverlay />
|
<ModalOverlay />
|
||||||
|
@ -56,10 +68,11 @@ function OutfitResetModal({ isOpen, onClose, dispatchToOutfit }) {
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<Text mb={4}>
|
<Text>
|
||||||
Choose a pet from Neopets.com, and we'll pull their outfit data
|
Choose a pet from Neopets.com, and we'll pull their outfit data
|
||||||
into here for you to play with!
|
into here for you to play with!
|
||||||
</Text>
|
</Text>
|
||||||
|
<Box height="4" />
|
||||||
<FormControl isInvalid={error}>
|
<FormControl isInvalid={error}>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Enter a pet's name…"
|
placeholder="Enter a pet's name…"
|
||||||
|
@ -78,6 +91,15 @@ function OutfitResetModal({ isOpen, onClose, dispatchToOutfit }) {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
|
<Button
|
||||||
|
leftIcon="delete"
|
||||||
|
variant="outline"
|
||||||
|
variantColor="red"
|
||||||
|
onClick={clearOutfit}
|
||||||
|
>
|
||||||
|
Reset outfit
|
||||||
|
</Button>
|
||||||
|
<Box flex="1"></Box>
|
||||||
<Button type="submit" variantColor="green" isLoading={loading}>
|
<Button type="submit" variantColor="green" isLoading={loading}>
|
||||||
Show me!
|
Show me!
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -150,8 +150,8 @@ const outfitStateReducer = (apolloClient) => (baseState, action) => {
|
||||||
const { name, speciesId, colorId, wornItemIds, closetedItemIds } = action;
|
const { name, speciesId, colorId, wornItemIds, closetedItemIds } = action;
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
speciesId: String(speciesId),
|
speciesId: String(speciesId || baseState.speciesId),
|
||||||
colorId: String(colorId),
|
colorId: String(colorId || baseState.colorId),
|
||||||
wornItemIds: new Set(wornItemIds.map(String)),
|
wornItemIds: new Set(wornItemIds.map(String)),
|
||||||
closetedItemIds: new Set(closetedItemIds.map(String)),
|
closetedItemIds: new Set(closetedItemIds.map(String)),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue