From 36c5ead53dbc8c142949b85a9bbc560fe3ec6105 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 11 Oct 2021 18:50:03 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Enable=20the=20create=20button?= =?UTF-8?q?=20only=20if=20all=20required=20fields=20have=20been=20filled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/group/GroupCreateBox.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/group/GroupCreateBox.tsx b/frontend/src/components/group/GroupCreateBox.tsx index ddd7223..f8bce44 100644 --- a/frontend/src/components/group/GroupCreateBox.tsx +++ b/frontend/src/components/group/GroupCreateBox.tsx @@ -59,6 +59,11 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu [viewSet, name, slug, description, members, access], ) + const canCreate = + React.useMemo( + () => name.validity === true && access.validity === true && Boolean(authorization?.state.user?.username), + [name, access, authorization], + ) if(!authorization?.state.token) { return null @@ -72,11 +77,11 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu
- - 0 ? true : undefined}/> + + 0 ? true : undefined}/> - + - + Create