From 08c15022f409f4d4d2684dd35afc456df8cfcd9b Mon Sep 17 00:00:00 2001 From: Davide Date: Mon, 18 Nov 2024 01:45:42 +0100 Subject: [PATCH] allow account selection during creation --- .../mainWindow/src/pages/Login/GDLAccount.tsx | 70 +++++++++++++++++-- .../mainWindow/src/pages/Login/index.tsx | 2 +- .../src/pages/Settings/Accounts.tsx | 11 +-- packages/i18n/locale/english/common.json | 1 + packages/i18n/locale/english/settings.json | 2 +- 5 files changed, 69 insertions(+), 17 deletions(-) diff --git a/apps/desktop/packages/mainWindow/src/pages/Login/GDLAccount.tsx b/apps/desktop/packages/mainWindow/src/pages/Login/GDLAccount.tsx index 92087a240..4cec99db4 100644 --- a/apps/desktop/packages/mainWindow/src/pages/Login/GDLAccount.tsx +++ b/apps/desktop/packages/mainWindow/src/pages/Login/GDLAccount.tsx @@ -1,7 +1,7 @@ -import { createEffect, Show, Suspense } from "solid-js"; +import { createEffect, Match, Show, Suspense, Switch } from "solid-js"; import { Trans, useTransContext } from "@gd/i18n"; -import { rspc } from "@/utils/rspcClient"; -import { Collapsable } from "@gd/ui"; +import { port, rspc } from "@/utils/rspcClient"; +import { Collapsable, Dropdown } from "@gd/ui"; type Props = { activeUuid: string | null | undefined; @@ -10,6 +10,10 @@ type Props = { const GDLAccount = (props: Props) => { const [t] = useTransContext(); + const setActiveAccountMutation = rspc.createMutation(() => ({ + mutationKey: ["account.setActiveUuid"] + })); + const accounts = rspc.createQuery(() => ({ queryKey: ["account.getAccounts"] })); @@ -41,9 +45,66 @@ const GDLAccount = (props: Props) => { } }); + const accountOptions = () => { + return accounts.data?.map((account) => { + return { + label: ( +
{ + setActiveAccountMutation.mutate(account.uuid); + }} + > +
+ +
{account.username}
+
+
+ + +
+ + +
+ + + + +
+ + +
+ + +
+ + +
+ + +
+
+ ), + key: account?.uuid + }; + }); + }; + return ( -
+
+
+
+ +
+ +

@@ -59,7 +120,6 @@ const GDLAccount = (props: Props) => {

-

diff --git a/apps/desktop/packages/mainWindow/src/pages/Login/index.tsx b/apps/desktop/packages/mainWindow/src/pages/Login/index.tsx index e896eb754..f927a5305 100644 --- a/apps/desktop/packages/mainWindow/src/pages/Login/index.tsx +++ b/apps/desktop/packages/mainWindow/src/pages/Login/index.tsx @@ -500,7 +500,7 @@ export default function Login() { i() + 1 < step() && (step() > Steps.CodeStep ? i() + 1 > Steps.CodeStep - : step() > Steps.Auth && + : step() >= Steps.Auth && searchParams.addMicrosoftAccount ? false : true) diff --git a/apps/desktop/packages/mainWindow/src/pages/Settings/Accounts.tsx b/apps/desktop/packages/mainWindow/src/pages/Settings/Accounts.tsx index ba764a626..d44cd4144 100644 --- a/apps/desktop/packages/mainWindow/src/pages/Settings/Accounts.tsx +++ b/apps/desktop/packages/mainWindow/src/pages/Settings/Accounts.tsx @@ -362,16 +362,7 @@ const Accounts = () => { navigate("/"); }} > - - account.uuid === - globalStore.currentlySelectedAccountUuid.data - )?.username - }} - /> +

diff --git a/packages/i18n/locale/english/common.json b/packages/i18n/locale/english/common.json index ff1571759..9706fa4ce 100644 --- a/packages/i18n/locale/english/common.json +++ b/packages/i18n/locale/english/common.json @@ -72,6 +72,7 @@ "login.next": "Next", "login.prev": "Prev", "login.register": "Register", + "login.link_account": "Link Account", "login.request_email_change": "Request Email Change", "login.sync_gdl_account": "Sync GDL Account", "login.manage": "Manage", diff --git a/packages/i18n/locale/english/settings.json b/packages/i18n/locale/english/settings.json index fc5719ee6..196aa992c 100644 --- a/packages/i18n/locale/english/settings.json +++ b/packages/i18n/locale/english/settings.json @@ -56,7 +56,7 @@ "remove_ms_account_with_gdl_account_removal_description": "This Microsoft account has been linked to a GDLauncher account. If you remove this account, you will also be logged out of the GDLauncher account and data will not continue to be synced.", "confirm_removal": "Confirm Removal", "cannot_request_deletion_for_time": "Wait {{time}} before requesting again", - "add_gdl_account": "Add GDLauncher Account ({{accountName}})", + "link_gdl_account": "Link GDLauncher Account", "log_out_gdl_account": "Log Out GDLauncher Account", "minecraft_accounts": "Minecraft Accounts", "uuid": "UUID",