import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import './light.css'; import { Form, Header, Message } from 'semantic-ui-react'; import { requester, randomString } from './utils.js'; export function LoginForm(props) { const [input, setInput] = useState({ username: '' }); const [error, setError] = useState({}); const [loading, setLoading] = useState(false); const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); const handleChange = (e) => handleValues(e, e.currentTarget); const handleSubmit = (e) => { if (input.username.includes('@')) { setError({ username: 'Username, not email.' }); } else { if (loading) return; setLoading(true); const data = { ...input, username: input.username.toLowerCase() }; requester('/rest-auth/login/', 'POST', '', data) .then(res => { setError({}); props.setTokenCache(res.key); window.scrollTo(0, 0); }) .catch(err => { setLoading(false); console.log(err); setError(err.data); }); } }; return (
Forgot Password
); }; export function SignupForm(props) { const [input, setInput] = useState({ email: '' }); const [error, setError] = useState({}); const [progress, setProgress] = useState([]); const [loading, setLoading] = useState(false); const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); const handleChange = (e) => handleValues(e, e.currentTarget); const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked }); const genUsername = () => { if (input.preferred_name && input.last_name) { let preferred_name = input.preferred_name.trim().toLowerCase(); let last_name = input.last_name.trim().toLowerCase(); preferred_name = preferred_name.replace(/[^a-z- ]+/g, ''); last_name = last_name.replace(/[^a-z- ]+/g, ''); preferred_name = preferred_name.replace(/[ -]/g, '.'); last_name = last_name.replace(/[ -]/g, '.'); return preferred_name + '.' + last_name; } else { return ''; } }; const handleSubmit = (e) => { if (loading) return; setLoading(true); input.username = genUsername(); const request_id = randomString(); const getStatus = () => { requester('/stats/progress/?request_id='+request_id, 'GET') .then(res => { setProgress(res); }) .catch(err => { console.log(err); }); }; const interval = setInterval(getStatus, 500); const data = { ...input, email: input.email.toLowerCase(), request_id: request_id }; requester('/registration/', 'POST', '', data) .then(res => { clearInterval(interval); setError({}); props.setTokenCache(res.key); window.scrollTo(0, 0); }) .catch(err => { clearInterval(interval); setLoading(false); console.log(err); setError(err.data); }); }; return (Please do a password reset instead.
{progress.map(x => <>{x}
>)}
You'll need to sign a waiver and fill out member forms.
Our address:
1530 27th Avenue NE
Bay 108
Calgary, Alberta, Canada