Handle update and hangle close functions. Updated modal footer butons.
This commit is contained in:
@@ -48,24 +48,29 @@ const AddSticker = ({
|
|||||||
|
|
||||||
const { addEditSticker } = useContext(StickersContext);
|
const { addEditSticker } = useContext(StickersContext);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleClose = () => {
|
||||||
if (selectedSticker !== null) {
|
setSelectedSticker(null);
|
||||||
addEditSticker(date, selectedSticker);
|
updateIsOpen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleSubmit = (sticker) => {
|
||||||
|
addEditSticker(date, sticker);
|
||||||
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (selectedSticker !== null) {
|
// useEffect(() => {
|
||||||
addEditSticker(date, selectedSticker);
|
// if (selectedSticker !== null) {
|
||||||
}
|
// addEditSticker(date, selectedSticker);
|
||||||
}, [selectedSticker]);
|
// }
|
||||||
|
// }, [selectedSticker]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Modal
|
<Modal
|
||||||
isCentered
|
isCentered
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onClose={() => updateIsOpen(!isOpen)}
|
onClose={() => handleClose()}
|
||||||
motionPreset="slideInBottom"
|
motionPreset="slideInBottom"
|
||||||
scrollBehavior="inside"
|
scrollBehavior="inside"
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -116,13 +121,14 @@ const AddSticker = ({
|
|||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button
|
<Button
|
||||||
colorScheme="blue"
|
variant="primary"
|
||||||
mr={3}
|
isDisabled={selectedSticker === null}
|
||||||
onClick={() => updateIsOpen(!isOpen)}
|
// mr={3}
|
||||||
|
onClick={() => handleSubmit(selectedSticker)}
|
||||||
>
|
>
|
||||||
Close
|
{"Submit"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="ghost">Secondary Action</Button>
|
{/* <Button variant="ghost">Secondary Action</Button> */}
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user