Add dedicated Sign page
This commit is contained in:
+1
-47
@@ -7,6 +7,7 @@ import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Me
|
||||
import { statusColor, BasicTable, siteUrl, staticUrl, requester, isAdmin } from './utils.js';
|
||||
import { LoginForm, SignupForm } from './LoginSignup.js';
|
||||
import { AccountForm } from './Account.js';
|
||||
import { SignForm } from './Sign.js';
|
||||
import { PayPalSubscribeDeal } from './PayPal.js';
|
||||
|
||||
function MemberInfo(props) {
|
||||
@@ -138,53 +139,6 @@ function MemberInfo(props) {
|
||||
);
|
||||
};
|
||||
|
||||
function SignForm(props) {
|
||||
const { token } = props;
|
||||
const [error, setError] = useState({});
|
||||
const [sign, setSign] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [success, setSuccess] = useState(false);
|
||||
|
||||
const handleValues = (e, v) => setSign(v.value);
|
||||
const handleChange = (e) => handleValues(e, e.currentTarget);
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
if (loading) return;
|
||||
setLoading(true);
|
||||
const data = {sign: sign};
|
||||
requester('/stats/sign/', 'POST', token, data)
|
||||
.then(res => {
|
||||
setLoading(false);
|
||||
setSuccess(true);
|
||||
setError({});
|
||||
setSign('');
|
||||
})
|
||||
.catch(err => {
|
||||
setLoading(false);
|
||||
console.log(err);
|
||||
setError(err.data);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<p>Send a message to the sign:</p>
|
||||
|
||||
<Form.Input
|
||||
name='sign'
|
||||
onChange={handleChange}
|
||||
value={sign}
|
||||
error={error.sign}
|
||||
/>
|
||||
|
||||
<Form.Button loading={loading} error={error.non_field_errors}>
|
||||
Submit
|
||||
</Form.Button>
|
||||
{success && <div>Success!</div>}
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export function Home(props) {
|
||||
const { user, token } = props;
|
||||
const [stats, setStats] = useState(JSON.parse(localStorage.getItem('stats', 'false')));
|
||||
|
||||
Reference in New Issue
Block a user