mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +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 { pokerogueApi } from "#api/pokerogue-api";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
|
import { bypassLogin } from "#app/global-vars/bypass-login";
|
||||||
import { Button } from "#enums/buttons";
|
import { Button } from "#enums/buttons";
|
||||||
import { TextStyle } from "#enums/text-style";
|
import { TextStyle } from "#enums/text-style";
|
||||||
import { UiMode } from "#enums/ui-mode";
|
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 type { InputFieldConfig } from "#ui/form-modal-ui-handler";
|
||||||
import { FormModalUiHandler } from "#ui/form-modal-ui-handler";
|
import { FormModalUiHandler } from "#ui/form-modal-ui-handler";
|
||||||
import type { ModalConfig } from "#ui/modal-ui-handler";
|
import type { ModalConfig } from "#ui/modal-ui-handler";
|
||||||
@ -17,6 +20,8 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
private adminResult: AdminSearchInfo;
|
private adminResult: AdminSearchInfo;
|
||||||
private config: ModalConfig;
|
private config: ModalConfig;
|
||||||
|
|
||||||
|
private tempSaveData: GameData;
|
||||||
|
|
||||||
private readonly buttonGap = 10;
|
private readonly buttonGap = 10;
|
||||||
private readonly ERR_REQUIRED_FIELD = (field: string) => {
|
private readonly ERR_REQUIRED_FIELD = (field: string) => {
|
||||||
if (field === "username") {
|
if (field === "username") {
|
||||||
@ -273,8 +278,8 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AdminMode.SEARCH:
|
case AdminMode.SEARCH:
|
||||||
if (!this.inputs[0].text) {
|
if (!this.inputs[0].text && !bypassLogin) {
|
||||||
// username missing from search panel
|
// username missing from search panel, skip check for local testing
|
||||||
return {
|
return {
|
||||||
error: true,
|
error: true,
|
||||||
errorMessage: this.ERR_REQUIRED_FIELD("username"),
|
errorMessage: this.ERR_REQUIRED_FIELD("username"),
|
||||||
@ -314,6 +319,17 @@ export class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async adminSearch(adminSearchResult: AdminSearchInfo) {
|
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 {
|
try {
|
||||||
const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({
|
const [adminInfo, errorType] = await pokerogueApi.admin.searchAccount({
|
||||||
username: adminSearchResult.username,
|
username: adminSearchResult.username,
|
||||||
|
@ -452,7 +452,7 @@ export class MenuUiHandler extends MessageUiHandler {
|
|||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (!bypassLogin && loggedInUser?.hasAdminRole) {
|
if (bypassLogin || loggedInUser?.hasAdminRole) {
|
||||||
communityOptions.push({
|
communityOptions.push({
|
||||||
label: "Admin",
|
label: "Admin",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user