Upgrade ban logic

This commit is contained in:
MartinBraquet
2025-10-11 22:58:50 +02:00
parent 8cc33d3418
commit a638a35a76
3 changed files with 40 additions and 7 deletions

View File

@@ -19,4 +19,7 @@ export const DEV_CONFIG: EnvConfig = {
measurementId: "G-N6LZ64EMJ2",
region: 'us-west1',
},
adminIds: [
'ULxLz04VW1V4vbnj5XLwvzCSkYd2', // Martin
],
}

View File

@@ -16,6 +16,7 @@ import { SimpleCopyTextButton } from 'web/components/buttons/copy-link-button'
import { api } from 'web/lib/api'
import { buildArray } from 'common/util/array'
import { DeleteYourselfButton } from '../profile/delete-yourself'
import {toast} from "react-hot-toast";
export function MoreOptionsUserButton(props: { user: User }) {
const { user } = props
@@ -55,11 +56,22 @@ export function MoreOptionsUserButton(props: { user: User }) {
<Button
color={'red'}
size="xs"
onClick={() => {
api('ban-user', {
userId,
unban: user.isBannedFromPosting ?? false,
})
onClick={async () => {
await toast.promise(
api('ban-user', {
userId,
unban: user.isBannedFromPosting ?? false,
}),
{
loading: 'Banning...',
success: () => {
return 'User banned!'
},
error: () => {
return 'Error banning user'
},
}
)
}}
>
{user.isBannedFromPosting ? 'Banned' : 'Ban User'}

View File

@@ -88,11 +88,29 @@ type ActiveUserPageProps = {
export default function UserPage(props: UserPageProps) {
// console.debug('Starting UserPage in /[username]')
if (!props.user) {
return <div>This account has been deleted</div>
return <LovePage
trackPageView={'user page'}
className={'relative p-2 sm:pt-0'}
>
<Col className="items-center justify-center h-full">
<div className="text-xl font-semibold text-center mt-8">
This account has been deleted.
</div>
</Col>
</LovePage>
}
if (props.user.isBannedFromPosting) {
return <div>This account is banned</div>
return <LovePage
trackPageView={'user page'}
className={'relative p-2 sm:pt-0'}
>
<Col className="items-center justify-center h-full">
<div className="text-xl font-semibold text-center mt-8">
This account has been suspended.
</div>
</Col>
</LovePage>
}
return <UserPageInner {...props} />