Make admin panel functional for local testing

This commit is contained in:
Wlowscha 2025-09-20 19:48:12 +02:00
parent 93b79724b5
commit 6f37f1b5de
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 19 additions and 3 deletions

View File

@ -1,8 +1,11 @@
import { pokerogueApi } from "#api/pokerogue-api";
import { globalScene } from "#app/global-scene";
import { bypassLogin } from "#app/global-vars/bypass-login";
import { Button } from "#enums/buttons";
import { TextStyle } from "#enums/text-style";
import { UiMode } from "#enums/ui-mode";
import type { GameData } from "#system/game-data";
import type { SearchAccountResponse } from "#types/api/pokerogue-admin-api";
import type { InputFieldConfig } from "#ui/form-modal-ui-handler";
import { FormModalUiHandler } from "#ui/form-modal-ui-handler";
import type { ModalConfig } from "#ui/modal-ui-handler";
@ -17,6 +20,8 @@ export class AdminUiHandler extends FormModalUiHandler {
private adminResult: AdminSearchInfo;
private config: ModalConfig;
private tempSaveData: GameData;
private readonly buttonGap = 10;
private readonly ERR_REQUIRED_FIELD = (field: string) => {
if (field === "username") {
@ -273,8 +278,8 @@ export class AdminUiHandler extends FormModalUiHandler {
}
break;
case AdminMode.SEARCH:
if (!this.inputs[0].text) {
// username missing from search panel
if (!this.inputs[0].text && !bypassLogin) {
// username missing from search panel, skip check for local testing
return {
error: true,
errorMessage: this.ERR_REQUIRED_FIELD("username"),
@ -314,6 +319,17 @@ export class AdminUiHandler extends FormModalUiHandler {
}
private async adminSearch(adminSearchResult: AdminSearchInfo) {
// Mocking response, solely for local testing
if (bypassLogin) {
const fakeResponse: SearchAccountResponse = {
username: adminSearchResult.username,
discordId: "",
googleId: "",
lastLoggedIn: "",
registered: "",
};
return { adminSearchResult: fakeResponse, error: false };
}
try {
const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({
username: adminSearchResult.username,

View File

@ -452,7 +452,7 @@ export class MenuUiHandler extends MessageUiHandler {
keepOpen: true,
},
];
if (!bypassLogin && loggedInUser?.hasAdminRole) {
if (bypassLogin || loggedInUser?.hasAdminRole) {
communityOptions.push({
label: "Admin",
handler: () => {