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
All checks were successful
delpoy / build-and-deploy (push) Successful in 31s
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user