Make group optional in groups form
This commit is contained in:
parent
eddb1cab37
commit
64141420d2
@ -12,8 +12,8 @@ export function loadGuests(onLoad?: (guests: Guest[]) => void) {
|
|||||||
id: record.id,
|
id: record.id,
|
||||||
name: record.name,
|
name: record.name,
|
||||||
status: record.status,
|
status: record.status,
|
||||||
group_name: record.group.name,
|
group_name: record.group?.name || 'Not grouped',
|
||||||
groupId: record.group.id,
|
groupId: record.group?.id,
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
@ -21,17 +21,17 @@ export default function GuestFormDialog({ groups, onCreate, onHide, guest, visib
|
|||||||
}) {
|
}) {
|
||||||
|
|
||||||
const [name, setName] = useState(guest?.name || '');
|
const [name, setName] = useState(guest?.name || '');
|
||||||
const [group, setGroup] = useState(guest?.groupId || null);
|
const [group, setGroup] = useState(guest?.groupId || undefined);
|
||||||
const [status, setStatus] = useState<GuestStatus | null>(guest?.status || null);
|
const [status, setStatus] = useState<GuestStatus | undefined>(guest?.status || undefined);
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
setName('');
|
setName('');
|
||||||
setGroup(null);
|
setGroup(undefined);
|
||||||
setStatus(null);
|
setStatus(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitGuest() {
|
function submitGuest() {
|
||||||
if (!(name && group && status)) {
|
if (!(name && status)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ export default function GuestFormDialog({ groups, onCreate, onHide, guest, visib
|
|||||||
} />
|
} />
|
||||||
<label htmlFor="status">Status</label>
|
<label htmlFor="status">Status</label>
|
||||||
</FloatLabel>
|
</FloatLabel>
|
||||||
<button className={classNames('primary')} onClick={submitGuest} disabled={!(name.length > 0 && group && status)}>
|
<button className={classNames('primary')} onClick={submitGuest} disabled={!(name.length > 0 && status)}>
|
||||||
{guest?.id !== undefined ? 'Update' : 'Create'}
|
{guest?.id !== undefined ? 'Update' : 'Create'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user