From 9f74c550927671f4ded301d0cf3e9d592716375c Mon Sep 17 00:00:00 2001 From: piotrruss Date: Sun, 22 Aug 2021 14:33:54 +0200 Subject: settings --- components/Popup.js | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'components/Popup.js') diff --git a/components/Popup.js b/components/Popup.js index 911d2fa..3df11c5 100644 --- a/components/Popup.js +++ b/components/Popup.js @@ -1,32 +1,24 @@ -import React, {useState, useEffect} from 'react' +import React from 'react' +import usePopup from 'hooks/usePopup' -const Popup = ({popup}) => { - const [visible, setVisible] = useState(false) - const { - content = null, - time = null, - error = null, - yes = null, - no = null, - } = popup +const Popup = () => { + const {popupData: p} = usePopup() - useEffect(() => { - setVisible(true) - time && setTimeout(() => setVisible(false), time) - }, [popup]) + if (!p || !p.content) return null - if (!content) return null - - return visible ? ( -
-
{ content }
+ return ( +
+
{p.content}
{ - (yes || no) && (
- {[yes, no].map(a => a && { setVisible(false); a.action() }} value={a.label} />)} -
) + (p.yes || p.no) && ( +
+ {[p.no, p.yes].map(a => a && a.action()} value={a.label} />)} +
+ ) }
- ) : null + ) } export default Popup + -- cgit v1.2.3