Handle update and hangle close functions. Updated modal footer butons.

This commit is contained in:
Lucid Kobold
2022-02-10 00:06:05 -06:00
parent 5924158906
commit dc5c83641c

View File

@@ -48,24 +48,29 @@ const AddSticker = ({
const { addEditSticker } = useContext(StickersContext);
const handleSubmit = () => {
if (selectedSticker !== null) {
addEditSticker(date, selectedSticker);
}
const handleClose = () => {
setSelectedSticker(null);
updateIsOpen(false);
}
const handleSubmit = (sticker) => {
addEditSticker(date, sticker);
handleClose();
};
useEffect(() => {
if (selectedSticker !== null) {
addEditSticker(date, selectedSticker);
}
}, [selectedSticker]);
// useEffect(() => {
// if (selectedSticker !== null) {
// addEditSticker(date, selectedSticker);
// }
// }, [selectedSticker]);
return (
<Fragment>
<Modal
isCentered
isOpen={isOpen}
onClose={() => updateIsOpen(!isOpen)}
onClose={() => handleClose()}
motionPreset="slideInBottom"
scrollBehavior="inside"
size="lg"
@@ -116,13 +121,14 @@ const AddSticker = ({
</ModalBody>
<ModalFooter>
<Button
colorScheme="blue"
mr={3}
onClick={() => updateIsOpen(!isOpen)}
variant="primary"
isDisabled={selectedSticker === null}
// mr={3}
onClick={() => handleSubmit(selectedSticker)}
>
Close
{"Submit"}
</Button>
<Button variant="ghost">Secondary Action</Button>
{/* <Button variant="ghost">Secondary Action</Button> */}
</ModalFooter>
</ModalContent>
</Modal>