From b522c88268e550d7ca7ab813170b8c245408689b Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Wed, 13 Mar 2024 22:20:12 +0200 Subject: [PATCH] invite users --- components/UsersPage/UsersPage.module.scss | 15 +++++ components/UsersPage/UsersPage.tsx | 64 +++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/components/UsersPage/UsersPage.module.scss b/components/UsersPage/UsersPage.module.scss index 4a17570..72be68f 100644 --- a/components/UsersPage/UsersPage.module.scss +++ b/components/UsersPage/UsersPage.module.scss @@ -65,3 +65,18 @@ } } } + +.headerRow { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 1.5rem; + + h1 { + margin: 0; + } +} + +.disclaimerText { + margin-top: 0; +} diff --git a/components/UsersPage/UsersPage.tsx b/components/UsersPage/UsersPage.tsx index c16b755..796a781 100644 --- a/components/UsersPage/UsersPage.tsx +++ b/components/UsersPage/UsersPage.tsx @@ -251,6 +251,63 @@ const EditUserModal = ({ ); }; +const InviteUserModal = ({ close, modalRef }: ModalProps) => { + const formRef = useRef(null); + + const { formData, handleInputChange, handleSubmit } = useForm( + { email: '' }, + async () => { + // Invite user + toast + .promise(publishJSON(`/api/admin/users/invite`, 'POST', formData), { + loading: 'Sending the invite...', + success: 'Invite sent!', + error: (err) => `Sending invite failed: ${err.message}`, + }) + .then((data) => { + if (data) { + close(true); + } + }); + return false; + } + ); + + return ( + + +

Invite a new user

+
+ +

+ The new user will receive a link to create their account. It will be + activated automatically. +

+ +
+ + + + +
+
+
+ + + + +
+ ); +}; + const UserCard = ({ user, update, @@ -419,7 +476,12 @@ export const UsersPage = () => {
-

Users{userCount && ` (${userCount})`}

+
+

Users{userCount && ` (${userCount})`}

+ +