From dd337670593a4044875bd8d7c6a62ea8d10e17a7 Mon Sep 17 00:00:00 2001 From: Sean Hatfield Date: Tue, 14 Nov 2023 13:58:00 -0800 Subject: [PATCH] 365 update invite UI to match new UI (#370) * update NewUserModal to match ui styles * fix bg color of invite screen/auto login after accept invitation * fix error text color * cleanup --------- Co-authored-by: timothycarambat --- .../src/pages/Invite/NewUserModal/index.jsx | 41 ++++++++++++------- frontend/src/pages/Invite/index.jsx | 8 ++-- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/frontend/src/pages/Invite/NewUserModal/index.jsx b/frontend/src/pages/Invite/NewUserModal/index.jsx index ae3fb6ed..39841190 100644 --- a/frontend/src/pages/Invite/NewUserModal/index.jsx +++ b/frontend/src/pages/Invite/NewUserModal/index.jsx @@ -2,10 +2,13 @@ import React, { useState } from "react"; import Invite from "../../../models/invite"; import paths from "../../../utils/paths"; import { useParams } from "react-router-dom"; +import { AUTH_TOKEN, AUTH_USER } from "../../../utils/constants"; +import System from "../../../models/system"; export default function NewUserModal() { const { code } = useParams(); const [error, setError] = useState(null); + const handleCreate = async (e) => { setError(null); e.preventDefault(); @@ -13,16 +16,26 @@ export default function NewUserModal() { const form = new FormData(e.target); for (var [key, value] of form.entries()) data[key] = value; const { success, error } = await Invite.acceptInvite(code, data); - if (!!success) window.location.replace(paths.home()); + if (success) { + const { valid, user, token, message } = await System.requestToken(data); + if (valid && !!token && !!user) { + window.localStorage.setItem(AUTH_USER, JSON.stringify(user)); + window.localStorage.setItem(AUTH_TOKEN, token); + window.location = paths.home(); + } else { + setError(message); + } + return; + } setError(error); }; return (
-
-
-

+
+
+

Create a new account

@@ -32,14 +45,14 @@ export default function NewUserModal() {
{error && ( -

- Error: {error} -

+

Error: {error}

)} -

+

After creating your account you will be able to login with these credentials and start using workspaces.

-
+
diff --git a/frontend/src/pages/Invite/index.jsx b/frontend/src/pages/Invite/index.jsx index 2818fd11..1ed25e79 100644 --- a/frontend/src/pages/Invite/index.jsx +++ b/frontend/src/pages/Invite/index.jsx @@ -31,7 +31,7 @@ export default function InvitePage() { if (result.status === "loading") { return ( -
+
); @@ -39,14 +39,14 @@ export default function InvitePage() { if (result.status === "invalid") { return ( -
-

{result.message}

+
+

{result.message}

); } return ( -
+
);