mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-03-21 17:50:29 -05:00
Teams: Add delete team button
This commit is contained in:
parent
29945cc90e
commit
cbdfd34a5e
|
|
@ -308,6 +308,8 @@ export class TeamViewer extends preact.Component<PageProps> {
|
|||
{this.state.changesMade && <>
|
||||
<br /><button class="button notifying" onClick={() => this.commitEdit()}>Save changes</button>
|
||||
</>}
|
||||
<br />
|
||||
<button class="button" onClick={() => this.runDelete()}>Delete team</button>
|
||||
<hr />
|
||||
</>}
|
||||
</div>
|
||||
|
|
@ -390,6 +392,27 @@ export class TeamViewer extends preact.Component<PageProps> {
|
|||
});
|
||||
}
|
||||
|
||||
runDelete() {
|
||||
const conf = toID(prompt("Do you really want to delete this team? Type 'yes' to confirm."));
|
||||
if (conf !== 'yes') {
|
||||
return;
|
||||
}
|
||||
void query('deleteteam', { query: { teamid: this.id } }).then(result => {
|
||||
if (result.actionerror) {
|
||||
alert(`Error deleting team: ${result.actionerror}`);
|
||||
} else {
|
||||
alert(
|
||||
result.success ?
|
||||
`Team successfully deleted.` :
|
||||
`Error while deleting team. Please try again later.`
|
||||
);
|
||||
if (result.success) {
|
||||
location.replace('');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
copyTeam() {
|
||||
if (!this.state.team) return;
|
||||
const team = unpackTeam(this.state.team.team);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user