aboutsummaryrefslogtreecommitdiffstats
path: root/components/Popup.js
blob: 3e5ab1fe079064cecbb28e70c20cb6e05c31e593 (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
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