From afff118d54296f0eeaed4afa7fbf7cc3cea41eca Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Fri, 14 Nov 2025 18:52:34 -0600 Subject: [PATCH] invite update --- src/webpage/invite.ts | 14 +++++++++++--- src/webpage/utils/switcher.ts | 31 ++++++++++++++++++++++++++++--- translations/en.json | 1 + 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/webpage/invite.ts b/src/webpage/invite.ts index 705ce67..dab73ac 100644 --- a/src/webpage/invite.ts +++ b/src/webpage/invite.ts @@ -78,9 +78,17 @@ import {getBulkUsers, Specialuser} from "./utils/utils.js"; async function showAccounts() { console.log("showing!"); - const user = await new AccountSwitcher((user) => { - return !!(well && user.serverurls.wellknown.includes(well)); - }).show(); + const user = await new AccountSwitcher( + (user) => { + return !!(well && user.serverurls.wellknown.includes(well)); + }, + { + loginText: () => I18n.login.login(), + createOpt: true, + loginurl: "/login?" + new URLSearchParams([["goback", window.location.href]]), + registerurl: "/register?" + new URLSearchParams([["goback", window.location.href]]), + }, + ).show(); fetch(`${urls!.api}/invites/${code}`, { method: "POST", headers: { diff --git a/src/webpage/utils/switcher.ts b/src/webpage/utils/switcher.ts index 22755e2..679c7da 100644 --- a/src/webpage/utils/switcher.ts +++ b/src/webpage/utils/switcher.ts @@ -16,14 +16,30 @@ export class AccountSwitcher { canCreate: boolean; canLogOut: boolean; canHide: boolean; + createOpt: boolean; + loginText: () => string; + loginurl: string; + registerurl: string; constructor( filter: AccountSwitcher["filter"] = () => true, - {canCreate = true, canLogOut = true, canHide = true} = {}, + { + canCreate = true, + createOpt = false, + canLogOut = true, + canHide = true, + loginurl = "/login", + registerurl = "/register", + loginText = () => I18n.switchAccounts(), + } = {}, ) { this.filter = filter; this.canCreate = canCreate; this.canLogOut = canLogOut; this.canHide = canHide; + this.loginText = loginText; + this.createOpt = createOpt; + this.loginurl = loginurl; + this.registerurl = registerurl; } async show(): Promise { const table = document.createElement("div"); @@ -79,9 +95,18 @@ export class AccountSwitcher { if (this.canCreate) { const switchAccountDiv = document.createElement("div"); switchAccountDiv.classList.add("switchtable"); - switchAccountDiv.textContent = I18n.switchAccounts(); + switchAccountDiv.textContent = this.loginText(); switchAccountDiv.addEventListener("click", () => { - window.location.href = "/login"; + window.location.href = this.loginurl; + }); + table.append(switchAccountDiv); + } + if (this.createOpt) { + const switchAccountDiv = document.createElement("div"); + switchAccountDiv.classList.add("switchtable"); + switchAccountDiv.textContent = I18n.createAccount(); + switchAccountDiv.addEventListener("click", () => { + window.location.href = this.registerurl; }); table.append(switchAccountDiv); } diff --git a/translations/en.json b/translations/en.json index a06b470..8eb60dd 100644 --- a/translations/en.json +++ b/translations/en.json @@ -414,6 +414,7 @@ "DISCOVERABLE": "Discovery" }, "welcomeMessages": "Welcome $1! Nice to see ya!\nHello, nice to meet you $1!\nWelcome, hope you brought pizza $1!", + "createAccount":"Create Account", "role": { "displaySettings": "Display settings", "name": "Role name:",