mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-23 07:14:21 +00:00
🔧 Enable the create button only if all required fields have been filled
This commit is contained in:
parent
55210e1f82
commit
c1bf5978ac
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],
|
[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) {
|
if(!authorization?.state.token) {
|
||||||
return null
|
return null
|
||||||
|
@ -72,11 +77,11 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu
|
||||||
</Details.Summary>
|
</Details.Summary>
|
||||||
<Details.Content>
|
<Details.Content>
|
||||||
<Form>
|
<Form>
|
||||||
<Form.Field label={"Name"} {...name}/>
|
<Form.Field label={"Name"} required {...name}/>
|
||||||
<Form.Field label={"Slug"} disabled={true} value={slug} validity={slug.length > 0 ? true : undefined}/>
|
<Form.Field label={"Slug"} required disabled={true} value={slug} validity={slug.length > 0 ? true : undefined}/>
|
||||||
<Form.Area label={"Description"} {...description}/>
|
<Form.Area label={"Description"} {...description}/>
|
||||||
<Form.Multiselect label={"Members"} options={membersOptions ?? {}} {...members}/>
|
<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
|
<Form.Select
|
||||||
label={"Access"}
|
label={"Access"}
|
||||||
options={{
|
options={{
|
||||||
|
@ -94,7 +99,7 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
<Form.Row>
|
<Form.Row>
|
||||||
<Form.Button onClick={doCreate}>
|
<Form.Button type={"button"} onClick={doCreate} disabled={!canCreate}>
|
||||||
Create
|
Create
|
||||||
</Form.Button>
|
</Form.Button>
|
||||||
</Form.Row>
|
</Form.Row>
|
||||||
|
|
Loading…
Reference in a new issue