fix: biome lint suppressions + admin-badges.ts formatting
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Failing after 23s
CI / tests-unit (push) Skipped
CI / tests-integration (push) Skipped
CI / tests-ui (push) Skipped
CI / preflight (push) Skipped
CI / deploy (push) Skipped
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Failing after 23s
CI / tests-unit (push) Skipped
CI / tests-integration (push) Skipped
CI / tests-ui (push) Skipped
CI / preflight (push) Skipped
CI / deploy (push) Skipped
This commit is contained in:
1 parent
a06db72c65
commit
7d8874c8cd
1 file changed
+20
-6
@@ -13,8 +13,18 @@ export async function giveBadge(formData: FormData): Promise<void> {
|
|||||||
// Support comma-separated userIds and/or codes for bulk operations
|
// Support comma-separated userIds and/or codes for bulk operations
|
||||||
const userIdInput = String(formData.get("userId") ?? "").trim();
|
const userIdInput = String(formData.get("userId") ?? "").trim();
|
||||||
const codeInput = String(formData.get("code") ?? "").trim();
|
const codeInput = String(formData.get("code") ?? "").trim();
|
||||||
const userIds = userIdInput ? userIdInput.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
const userIds = userIdInput
|
||||||
const codes = codeInput ? codeInput.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
? userIdInput
|
||||||
|
.split(",")
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
: [];
|
||||||
|
const codes = codeInput
|
||||||
|
? codeInput
|
||||||
|
.split(",")
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (userIds.length === 0 || codes.length === 0) {
|
if (userIds.length === 0 || codes.length === 0) {
|
||||||
return;
|
return;
|
||||||
@@ -41,7 +51,10 @@ export async function giveBadge(formData: FormData): Promise<void> {
|
|||||||
.select({ id: UsersBadges.id })
|
.select({ id: UsersBadges.id })
|
||||||
.from(UsersBadges)
|
.from(UsersBadges)
|
||||||
.where(
|
.where(
|
||||||
and(eq(UsersBadges.userId, Number(userId)), eq(UsersBadges.badgeCode, code)),
|
and(
|
||||||
|
eq(UsersBadges.userId, Number(userId)),
|
||||||
|
eq(UsersBadges.badgeCode, code),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
@@ -50,7 +63,9 @@ export async function giveBadge(formData: FormData): Promise<void> {
|
|||||||
.from(UsersBadges)
|
.from(UsersBadges)
|
||||||
.where(eq(UsersBadges.userId, Number(userId)));
|
.where(eq(UsersBadges.userId, Number(userId)));
|
||||||
const slotId = (agg?.maxSlot ?? 0) + 1;
|
const slotId = (agg?.maxSlot ?? 0) + 1;
|
||||||
await db.insert(UsersBadges).values({ userId: Number(userId), slotId, badgeCode: code });
|
await db
|
||||||
|
.insert(UsersBadges)
|
||||||
|
.values({ userId: Number(userId), slotId, badgeCode: code });
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Best-effort: the RCON grant already succeeded for online users.
|
// Best-effort: the RCON grant already succeeded for online users.
|
||||||
@@ -58,6 +73,5 @@ export async function giveBadge(formData: FormData): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
revalidatePath("/admin/badges");
|
revalidatePath("/admin/badges");
|
||||||
}
|
}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user