import React, { useState, useEffect } from 'react'; import { BrowserRouter as Router, Switch, Route, Link, useParams, useLocation } from 'react-router-dom'; import './light.css'; import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } 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 (
Log In to Spaceport
First time at the new portal?

Sign up below from Protospace Wi-Fi / computers.

Log In Forgot your password?

Click here to reset it.

); }; export function SignupForm(props) { const [input, setInput] = useState({ email: '' }); const [error, setError] = useState({}); const [progress, setProgress] = useState([]); const [loading, setLoading] = useState(false); const location = useLocation(); const bypass_code = location.hash.replace('#', ''); const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); const handleChange = (e) => handleValues(e, e.currentTarget); const genUsername = () => ( input.first_name && input.last_name ? (input.first_name + '.' + input.last_name).toLowerCase().replace(/ /g, '.') : '' ); 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(), bypass_code: bypass_code, 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 (
Sign Up to Spaceport
{props.show_signup ? <>

{progress.map(x => <>{x}
)}

Sign Up : <> Please Visit Protospace

You'll need to sign a waiver and fill out member forms.

Our address:
1530 27th Avenue NE
Bay 108
Calgary, Alberta, Canada

Google Maps Link

} ); };