eventcreator ux - disable inputs while creating

This commit is contained in:
Michael Fatemi 2021-06-24 11:49:09 -04:00
parent 912244dcf6
commit ca1c6fe474
4 changed files with 14 additions and 4 deletions

View File

@ -49,13 +49,13 @@ export default function EventCreator({ group }: { group: IGroup }) {
</h1> </h1>
<h3 style={{ textAlign: 'center', marginTop: '0.5rem' }}>{group.name}</h3> <h3 style={{ textAlign: 'center', marginTop: '0.5rem' }}>{group.name}</h3>
Name Name
<UITextInput value={name} onChangeText={setName} /> <UITextInput value={name} onChangeText={setName} disabled={creating} />
<br /> <br />
Start time Start time
<UIDatetimeInput onChangedDate={setStartTime} /> <UIDatetimeInput onChangedDate={setStartTime} disabled={creating} />
<br /> <br />
End time End time
<UIDatetimeInput onChangedDate={setEndTime} /> <UIDatetimeInput onChangedDate={setEndTime} disabled={creating} />
<br /> <br />
Location Location
<UIPlacesAutocomplete <UIPlacesAutocomplete
@ -71,7 +71,7 @@ export default function EventCreator({ group }: { group: IGroup }) {
{creating ? 'Creating event' : 'Create event'} {creating ? 'Creating event' : 'Create event'}
</UIButton> </UIButton>
) : ( ) : (
<span> <span style={{ marginTop: '1rem' }}>
Created <b>{name}</b>. Created <b>{name}</b>.
</span> </span>
)} )}

View File

@ -9,13 +9,16 @@ const baseStyle = {
export default function UIDatetimeInput({ export default function UIDatetimeInput({
onChangedDate, onChangedDate,
disabled = false,
}: { }: {
onChangedDate: (date: Date | null) => void; onChangedDate: (date: Date | null) => void;
disabled?: boolean;
}) { }) {
return ( return (
<input <input
style={baseStyle} style={baseStyle}
type="datetime-local" type="datetime-local"
disabled={disabled}
onChange={(e) => { onChange={(e) => {
const number = e.target.valueAsNumber; const number = e.target.valueAsNumber;
if (!isNaN(number)) { if (!isNaN(number)) {

View File

@ -22,6 +22,7 @@ function SuggestionsList({
borderBottomRightRadius: '0.5em', borderBottomRightRadius: '0.5em',
backgroundColor: 'white', backgroundColor: 'white',
maxWidth: '100%', maxWidth: '100%',
textAlign: 'left',
}} }}
> >
{suggestions.map((suggestion) => ( {suggestions.map((suggestion) => (
@ -42,9 +43,11 @@ function SuggestionsList({
export default function UIPlacesAutocomplete({ export default function UIPlacesAutocomplete({
onSelected, onSelected,
placeholder = 'Enter a location', placeholder = 'Enter a location',
disabled = false,
}: { }: {
onSelected?: (address: string, placeID: string) => void; onSelected?: (address: string, placeID: string) => void;
placeholder?: string; placeholder?: string;
disabled?: boolean;
}) { }) {
const [location, setLocation] = useState(''); const [location, setLocation] = useState('');
const suggestionsRef = useRef<readonly Suggestion[]>([]); const suggestionsRef = useRef<readonly Suggestion[]>([]);
@ -89,6 +92,7 @@ export default function UIPlacesAutocomplete({
}, },
placeholder, placeholder,
})} })}
disabled={disabled}
/> />
{suggestionsRef.current.length > 0 && ( {suggestionsRef.current.length > 0 && (
<SuggestionsList <SuggestionsList

View File

@ -9,15 +9,18 @@ const baseStyle = {
export default function UITextInput({ export default function UITextInput({
value, value,
disabled = false,
onChangeText, onChangeText,
}: { }: {
value: string; value: string;
disabled?: boolean;
onChangeText: (text: string) => void; onChangeText: (text: string) => void;
}) { }) {
return ( return (
<input <input
style={baseStyle} style={baseStyle}
value={value} value={value}
disabled={disabled}
onChange={(e) => onChangeText(e.target.value)} onChange={(e) => onChangeText(e.target.value)}
/> />
); );