mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 14:59:26 +02:00
Apply suggestions from code review
Moka review changes Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com>
This commit is contained in:
parent
65c3748f95
commit
4533e53383
@ -165,7 +165,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this is used to update the fields' text when loading a new admin ui handler. It uses the adminResult to update the input text fields depending on the adminMode
|
// this is used to update the fields' text when loading a new admin ui handler. It uses the adminResult to update the input text fields depending on the adminMode
|
||||||
populateFields(adminMode: AdminMode, adminResult: AdminSearchInfo) {
|
private populateFields(adminMode: AdminMode, adminResult: AdminSearchInfo) {
|
||||||
switch (adminMode) {
|
switch (adminMode) {
|
||||||
case AdminMode.LINK:
|
case AdminMode.LINK:
|
||||||
this.inputs[0].setText(adminResult.username);
|
this.inputs[0].setText(adminResult.username);
|
||||||
@ -214,7 +214,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
areFieldsValid(adminMode: AdminMode, service?: string): { error: boolean; errorMessage?: string; } {
|
private areFieldsValid(adminMode: AdminMode, service?: string): { error: boolean; errorMessage?: string; } {
|
||||||
switch (adminMode) {
|
switch (adminMode) {
|
||||||
case AdminMode.LINK:
|
case AdminMode.LINK:
|
||||||
if (!this.inputs[0].text) { // username missing from link panel
|
if (!this.inputs[0].text) { // username missing from link panel
|
||||||
@ -258,7 +258,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
convertInputsToAdmin(): AdminSearchInfo {
|
private convertInputsToAdmin(): AdminSearchInfo {
|
||||||
return {
|
return {
|
||||||
username: this.inputs[0]?.node ? this.inputs[0].text : "",
|
username: this.inputs[0]?.node ? this.inputs[0].text : "",
|
||||||
discordId: this.inputs[1]?.node ? this.inputs[1]?.text : "",
|
discordId: this.inputs[1]?.node ? this.inputs[1]?.text : "",
|
||||||
@ -268,7 +268,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async adminSearch(adminSearchResult: AdminSearchInfo) {
|
private async adminSearch(adminSearchResult: AdminSearchInfo) {
|
||||||
try {
|
try {
|
||||||
const adminInfo = await Utils.apiFetch(`admin/account/adminSearch?username=${encodeURIComponent(adminSearchResult.username)}`, true);
|
const adminInfo = await Utils.apiFetch(`admin/account/adminSearch?username=${encodeURIComponent(adminSearchResult.username)}`, true);
|
||||||
if (!adminInfo.ok) { // error - if adminInfo.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db
|
if (!adminInfo.ok) { // error - if adminInfo.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db
|
||||||
@ -283,7 +283,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async adminLinkUnlink(adminSearchResult: AdminSearchInfo, service: string, mode: string) {
|
private async adminLinkUnlink(adminSearchResult: AdminSearchInfo, service: string, mode: string) {
|
||||||
try {
|
try {
|
||||||
const response = await Utils.apiPost(`admin/account/${service}${mode}`, `username=${encodeURIComponent(adminSearchResult.username)}&${service}Id=${encodeURIComponent(service === "discord" ? adminSearchResult.discordId : adminSearchResult.googleId)}`, "application/x-www-form-urlencoded", true);
|
const response = await Utils.apiPost(`admin/account/${service}${mode}`, `username=${encodeURIComponent(adminSearchResult.username)}&${service}Id=${encodeURIComponent(service === "discord" ? adminSearchResult.discordId : adminSearchResult.googleId)}`, "application/x-www-form-urlencoded", true);
|
||||||
if (!response.ok) { // error - if response.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db
|
if (!response.ok) { // error - if response.status === this.httpUserNotFoundErrorCode that means the username can't be found in the db
|
||||||
@ -297,7 +297,7 @@ export default class AdminUiHandler extends FormModalUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAdminPanelInfo(adminSearchResult: AdminSearchInfo, mode?: AdminMode) {
|
private updateAdminPanelInfo(adminSearchResult: AdminSearchInfo, mode?: AdminMode) {
|
||||||
mode = mode ?? AdminMode.ADMIN;
|
mode = mode ?? AdminMode.ADMIN;
|
||||||
this.scene.ui.setMode(Mode.ADMIN, {
|
this.scene.ui.setMode(Mode.ADMIN, {
|
||||||
buttonActions: [
|
buttonActions: [
|
||||||
|
@ -30,7 +30,8 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all information for each field to display in the modal
|
* Get configuration for all fields that should be part of the modal
|
||||||
|
* Gets used by {@linkcode updateFields} to add the proper text inputs and labels to the view
|
||||||
* @returns array of {@linkcode InputFieldConfig}
|
* @returns array of {@linkcode InputFieldConfig}
|
||||||
*/
|
*/
|
||||||
abstract getInputFieldConfigs(): InputFieldConfig[];
|
abstract getInputFieldConfigs(): InputFieldConfig[];
|
||||||
@ -65,7 +66,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||||||
this.modalContainer.add(this.errorMessage);
|
this.modalContainer.add(this.errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFields(fieldsConfig: InputFieldConfig[], hasTitle: boolean) {
|
protected updateFields(fieldsConfig: InputFieldConfig[], hasTitle: boolean) {
|
||||||
this.inputContainers = [];
|
this.inputContainers = [];
|
||||||
this.inputs = [];
|
this.inputs = [];
|
||||||
this.formLabels = [];
|
this.formLabels = [];
|
||||||
@ -90,7 +91,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
|
|||||||
inputContainer.add(input);
|
inputContainer.add(input);
|
||||||
|
|
||||||
this.inputContainers.push(inputContainer);
|
this.inputContainers.push(inputContainer);
|
||||||
this.modalContainer.add(this.inputContainers[this.inputContainers.length - 1]);
|
this.modalContainer.add(inputContainer);
|
||||||
|
|
||||||
this.inputs.push(input);
|
this.inputs.push(input);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user