import * as React from 'react' export interface RegistrationPageProps { setIsLoggedIn: (set: boolean) => void setIsAskingForRegistration: (set: boolean) => void error: string | null setError: (a: string|null) => void } export default function RegistrationPage (props: RegistrationPageProps): JSX.Element { const userInputRef = React.useRef(null) const passwordInputRef = React.useRef(null) const repeatPasswordInputRef = React.useRef(null) const emailInputRef = React.useRef(null) const onUserAsksForLogin = (): void => { props.setIsAskingForRegistration(false) } function registerUser (): void { if (userInputRef.current === null) { return } if (passwordInputRef.current === null) { return } if (repeatPasswordInputRef.current === null) { return } if (emailInputRef.current === null) { return } fetch('/player/register', { method: 'POST', mode: 'same-origin', cache: 'no-cache', body: JSON.stringify({ username: userInputRef.current.value, password: passwordInputRef.current.value, repeat_password: repeatPasswordInputRef.current.value, email: emailInputRef.current.value }) }).then(async (response) => { const statusCode = response.status const data = await response.json() if (statusCode !== 200) { props.setError(data.error) return } props.setError(null) }).catch((error) => { console.log(error) }) } return ( <>

Inicia sesión en L3TDE online

{(props.error !== null ? (

{props.error}

) : (<>) )}

¿Ya tienes cuenta? Inicia sesión.

) }