add user search in admin panel and remove user skeleton while loading data
All checks were successful
delpoy / build-and-deploy (push) Successful in 31s

This commit is contained in:
2023-09-30 01:42:59 +02:00
parent b7177708a7
commit b1f546ee94
4 changed files with 69 additions and 76 deletions

View File

@@ -14,12 +14,24 @@ export const POST = (async ({ request, cookies }) => {
const data: {
limit: number | null;
from: number | null;
name: string | null;
edition: 'java' | 'bedrock' | 'cracked' | null;
search: string | null;
slim: boolean | null;
} = await request.json();
const usersFindOptions: Attributes<User> = {};
if (data.search) {
if (data.name) {
Object.assign(usersFindOptions, {
[Op.or]: {
firstname: { [Op.like]: `%${data.name}%` },
lastname: { [Op.like]: `%${data.name}%` },
username: { [Op.like]: `%${data.name}%` }
}
});
} else if (data.search) {
Object.assign(usersFindOptions, {
[Op.or]: {
username: { [Op.like]: `%${data.search}%` },
@@ -27,6 +39,9 @@ export const POST = (async ({ request, cookies }) => {
}
});
}
if (data.edition) {
usersFindOptions.edition = data.edition;
}
const users = await User.findAll({
where: usersFindOptions,
attributes: data.slim ? ['username', 'uuid'] : undefined,