aboutsummaryrefslogtreecommitdiffstats
path: root/components/Popup.js
blob: 3df11c5c1de3bc7a2fa2ca2570f1d70efe89fb64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import React from 'react'
import usePopup from 'hooks/usePopup'

const Popup = () => {
  const {popupData: p} = usePopup()

  if (!p || !p.content) return null

  return (
    <div className={`window window--popup${p.error ? ' window--error' : ''}`}>
      <div className="window__content--popup">{p.content}</div>
      {
        (p.yes || p.no) && (
          <div className="window__buttons--popup">
            {[p.no, p.yes].map(a => a && <input key={a.label} className='window__button' type="button" onClick={async () => a.action()} value={a.label} />)}
          </div>
        )
      }
    </div>
  )
}

export default Popup