mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 14:54:22 +00:00
🔧 Enable the create button only if all required fields have been filled
This commit is contained in:
parent
7c0bef7aa0
commit
36c5ead53d
1 changed files with 9 additions and 4 deletions
|
@ -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
|
|||
</Details.Summary>
|
||||
<Details.Content>
|
||||
<Form>
|
||||
<Form.Field label={"Name"} {...name}/>
|
||||
<Form.Field label={"Slug"} disabled={true} value={slug} validity={slug.length > 0 ? true : undefined}/>
|
||||
<Form.Field label={"Name"} required {...name}/>
|
||||
<Form.Field label={"Slug"} required disabled={true} value={slug} validity={slug.length > 0 ? true : undefined}/>
|
||||
<Form.Area label={"Description"} {...description}/>
|
||||
<Form.Multiselect label={"Members"} options={membersOptions ?? {}} {...members}/>
|
||||
<Form.Field label={"Owner"} disabled={true} value={authorization?.state.user?.username} validity={Boolean(authorization?.state.user?.username)}/>
|
||||
<Form.Field label={"Owner"} required disabled={true} value={authorization?.state.user?.username} validity={Boolean(authorization?.state.user?.username)}/>
|
||||
<Form.Select
|
||||
label={"Access"}
|
||||
options={{
|
||||
|
@ -94,7 +99,7 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu
|
|||
: null
|
||||
}
|
||||
<Form.Row>
|
||||
<Form.Button onClick={doCreate}>
|
||||
<Form.Button type={"button"} onClick={doCreate} disabled={!canCreate}>
|
||||
Create
|
||||
</Form.Button>
|
||||
</Form.Row>
|
||||
|
|
Loading…
Reference in a new issue