Looading indicator
This commit is contained in:
parent
c4f5ca74f6
commit
06ecdcd45b
19
src/App.js
19
src/App.js
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Heading, IconButton, StarIcon, Pane, TextInput, Text
|
Heading, IconButton, StarIcon, Pane, TextInput, Text, Spinner
|
||||||
} from 'evergreen-ui'
|
} from 'evergreen-ui'
|
||||||
|
|
||||||
import './App.css';
|
import './App.css';
|
||||||
@ -17,10 +17,15 @@ class Form extends React.Component {
|
|||||||
|
|
||||||
handleSubmit(event) {
|
handleSubmit(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
this.setState({
|
||||||
|
loading: true,
|
||||||
|
});
|
||||||
|
|
||||||
if (!event.target.checkValidity()) {
|
if (!event.target.checkValidity()) {
|
||||||
this.setState({
|
this.setState({
|
||||||
invalid: true,
|
invalid: true,
|
||||||
displayErrors: true,
|
displayErrors: true,
|
||||||
|
loading: false,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,15 +41,16 @@ class Form extends React.Component {
|
|||||||
invalid: false,
|
invalid: false,
|
||||||
displayErrors: false,
|
displayErrors: false,
|
||||||
name: form_data.get('meeting-name'),
|
name: form_data.get('meeting-name'),
|
||||||
meetingid: data.id
|
meetingid: data.id,
|
||||||
|
loading: false,
|
||||||
})
|
})
|
||||||
console.log(this.state.meetingid)
|
console.log('Meeting ID: ' + this.state.meetingid)
|
||||||
})
|
})
|
||||||
.catch(console.log);
|
.catch(console.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { name, meetingid, invalid, displayErrors } = this.state;
|
const { name, meetingid, invalid, loading, displayErrors } = this.state;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form
|
<form
|
||||||
@ -60,13 +66,18 @@ class Form extends React.Component {
|
|||||||
placeholder="YourMeetingNameHere"
|
placeholder="YourMeetingNameHere"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
{!loading && (
|
||||||
<IconButton icon={StarIcon} height={60} onClick={this.onClick}/>
|
<IconButton icon={StarIcon} height={60} onClick={this.onClick}/>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div className="res-block">
|
<div className="res-block">
|
||||||
{invalid && (
|
{invalid && (
|
||||||
<Pane><Text>Form is not valid</Text></Pane>
|
<Pane><Text>Form is not valid</Text></Pane>
|
||||||
)}
|
)}
|
||||||
|
{loading && (
|
||||||
|
<Spinner marginX="auto" />
|
||||||
|
)}
|
||||||
{!invalid && name && (
|
{!invalid && name && (
|
||||||
<div>
|
<div>
|
||||||
<h3>Copy Pasta</h3>
|
<h3>Copy Pasta</h3>
|
||||||
|
Loading…
Reference in New Issue
Block a user