Skip to content

Commit

Permalink
added skip ppl check setting ti admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Dec 9, 2024
1 parent 96d0ee3 commit a80829d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
17 changes: 12 additions & 5 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ const Admin = () => {
})
}, [])

const changeBan = (user: UserAdmins, banned: boolean): Promise<void> => {
const updateUser = (user: UserAdmins, data: { banned?: boolean, skip_ppl_check?: boolean }): Promise<void> => {
return new Promise((resolve, reject) => {
ApiManager.updateUser(user.username, { banned })
ApiManager.updateUser(user.username, data)
.then(resolve)
.catch(reject);
.catch((err) => { alert(err.data.message_ru || err.data.message); reject(); });
});
}

Expand All @@ -60,14 +60,21 @@ const Admin = () => {
<Link href={`https://discord.com/users/${user.discord_id}`} className={style_root.username}>{user.username}</Link>
<p className={`${style_root.did} ${fira.className}`}>{user.discord_id}</p>
</div>
<div>
<div style={{ display: 'flex', flexDirection: 'column', gap: '.5rem' }}>
<SlideButton
label='Banned'
strict={true}
loadable={true}
onChange={value => changeBan(user, value)}
onChange={value => updateUser(user, { banned: value })}
defaultValue={user.banned}
disabled={!user.permissions.every((perm) => perm === 'default')} />

<SlideButton
label='Skip PPL check'
strict={true}
loadable={true}
onChange={value => updateUser(user, { skip_ppl_check: value })}
defaultValue={user.skip_ppl_check} />
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/app/interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export interface UserAdmins {
joined_at: Date,
discord_id: number,
banned: boolean,
permissions: string[]
permissions: string[],
skip_ppl_check: boolean
}


Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/utils/apiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ApiManager {
static async updateUser(username: string, params: UpdateUsersProps): Promise<void> {
await this.doRequest({
url: `/users/${username}`,
method: 'PUT',
method: 'PATCH',
data: params
});
}
Expand Down
15 changes: 13 additions & 2 deletions src/app/styles/admin/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
margin-bottom: 15px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
align-items: flex-start;
flex-direction: column;
gap: .5rem;
}

.user_card h3 {
Expand Down Expand Up @@ -55,4 +56,14 @@

.name:hover {
text-decoration: underline;
}

@media(max-width: 803px) {
.user_card {
width: 100%;
}

.adaptive_grid_column {
width: 100% !important;
}
}

0 comments on commit a80829d

Please sign in to comment.