mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 15:33:29 +02:00
Make admin panel functional for local testing
This commit is contained in:
parent
93b79724b5
commit
6f37f1b5de
@ -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,
|
||||
|
@ -452,7 +452,7 @@ export class MenuUiHandler extends MessageUiHandler {
|
||||
keepOpen: true,
|
||||
},
|
||||
];
|
||||
if (!bypassLogin && loggedInUser?.hasAdminRole) {
|
||||
if (bypassLogin || loggedInUser?.hasAdminRole) {
|
||||
communityOptions.push({
|
||||
label: "Admin",
|
||||
handler: () => {
|
||||
|
Loading…
Reference in New Issue
Block a user