Teams: Add delete team button

This commit is contained in:
Mia 2025-07-23 23:24:32 -05:00
parent 29945cc90e
commit cbdfd34a5e

View File

@ -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);