Can create new accounts

This commit is contained in:
2025-04-09 19:24:59 +02:00
parent 132482c47d
commit 84e1c57dc9
3 changed files with 32 additions and 6 deletions

View File

@@ -20,6 +20,19 @@ export function AccountsRoute(): React.ReactElement {
const list = accounts.list.list;
const createAccount = async () => {
try {
await AccountApi.Create(`New account #${list.length + 1}`);
snackbar("New account successfully created!");
await accounts.reload();
} catch (e) {
console.error("Failed to create new account!", e);
alert(`Failed to create new account! ${e}`);
}
};
const setDefaultAccount = async (account: Account) => {
try {
await AccountApi.SetDefaultAccount(account);
@@ -125,12 +138,12 @@ export function AccountsRoute(): React.ReactElement {
actions={
<span>
<Tooltip title="Create a new account">
<IconButton onClick={undefined}>
<IconButton onClick={createAccount}>
<AddIcon />
</IconButton>
</Tooltip>
<Tooltip title="Refresh accounts list">
<IconButton onClick={undefined}>
<IconButton onClick={() => accounts.reload()}>
<RefreshIcon />
</IconButton>
</Tooltip>