Skip to content

Commit a638a35

Browse files
committed
Upgrade ban logic
1 parent 8cc33d3 commit a638a35

3 files changed

Lines changed: 40 additions & 7 deletions

File tree

common/src/envs/dev.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ export const DEV_CONFIG: EnvConfig = {
1919
measurementId: "G-N6LZ64EMJ2",
2020
region: 'us-west1',
2121
},
22+
adminIds: [
23+
'ULxLz04VW1V4vbnj5XLwvzCSkYd2', // Martin
24+
],
2225
}

web/components/buttons/more-options-user-button.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { SimpleCopyTextButton } from 'web/components/buttons/copy-link-button'
1616
import { api } from 'web/lib/api'
1717
import { buildArray } from 'common/util/array'
1818
import { DeleteYourselfButton } from '../profile/delete-yourself'
19+
import {toast} from "react-hot-toast";
1920

2021
export function MoreOptionsUserButton(props: { user: User }) {
2122
const { user } = props
@@ -55,11 +56,22 @@ export function MoreOptionsUserButton(props: { user: User }) {
5556
<Button
5657
color={'red'}
5758
size="xs"
58-
onClick={() => {
59-
api('ban-user', {
60-
userId,
61-
unban: user.isBannedFromPosting ?? false,
62-
})
59+
onClick={async () => {
60+
await toast.promise(
61+
api('ban-user', {
62+
userId,
63+
unban: user.isBannedFromPosting ?? false,
64+
}),
65+
{
66+
loading: 'Banning...',
67+
success: () => {
68+
return 'User banned!'
69+
},
70+
error: () => {
71+
return 'Error banning user'
72+
},
73+
}
74+
)
6375
}}
6476
>
6577
{user.isBannedFromPosting ? 'Banned' : 'Ban User'}

web/pages/[username]/index.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,29 @@ type ActiveUserPageProps = {
8888
export default function UserPage(props: UserPageProps) {
8989
// console.debug('Starting UserPage in /[username]')
9090
if (!props.user) {
91-
return <div>This account has been deleted</div>
91+
return <LovePage
92+
trackPageView={'user page'}
93+
className={'relative p-2 sm:pt-0'}
94+
>
95+
<Col className="items-center justify-center h-full">
96+
<div className="text-xl font-semibold text-center mt-8">
97+
This account has been deleted.
98+
</div>
99+
</Col>
100+
</LovePage>
92101
}
93102

94103
if (props.user.isBannedFromPosting) {
95-
return <div>This account is banned</div>
104+
return <LovePage
105+
trackPageView={'user page'}
106+
className={'relative p-2 sm:pt-0'}
107+
>
108+
<Col className="items-center justify-center h-full">
109+
<div className="text-xl font-semibold text-center mt-8">
110+
This account has been suspended.
111+
</div>
112+
</Col>
113+
</LovePage>
96114
}
97115

98116
return <UserPageInner {...props} />

0 commit comments

Comments
 (0)