forked from manifoldmarkets/manifold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperBanControl.tsx
58 lines (52 loc) · 1.88 KB
/
SuperBanControl.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { useState } from 'react'
import { Modal } from './layout/modal'
import { superBanUser } from 'web/lib/firebase/super-ban-user'
import { Col } from './layout/col'
import { Button } from './buttons/button'
const SuperBanControl = (props: { userId: string }) => {
const { userId } = props
const [showConfirmModal, setShowConfirmModal] = useState(false)
const [showSummaryModal, setShowSummaryModal] = useState(false)
const [summaryMessage, setSummaryMessage] = useState('')
async function handleSuperBan() {
setShowConfirmModal(false)
try {
const message = await superBanUser(userId)
setSummaryMessage(message)
setShowSummaryModal(true)
} catch (error) {
console.error('Superban failed:', error)
}
}
return (
<>
<Button color="red" size="xs" onClick={() => setShowConfirmModal(true)}>
Superban
</Button>
<Modal open={showConfirmModal} setOpen={setShowConfirmModal} size="md">
<Col className={'bg-canvas-0 text-ink-1000 rounded-md p-4 '}>
<div className="text-left">
<p>
Are you sure you want to superban this user? This will ban them,
unlist and N/A all their markets, and hide all their comments.
</p>
<div className="mt-4 flex justify-around">
<Button color="red" onClick={() => handleSuperBan()}>
Yes, superban
</Button>
<Button color="gray" onClick={() => setShowConfirmModal(false)}>
No, cancel
</Button>
</div>
</div>
</Col>
</Modal>
<Modal open={showSummaryModal} setOpen={setShowSummaryModal} size="md">
<Col className={'bg-canvas-0 text-ink-1000 rounded-md p-4 '}>
<div className="text-center">{summaryMessage}</div>
</Col>
</Modal>
</>
)
}
export default SuperBanControl