import React, { useRef, useState, useEffect, useContext } from "react";
import axios from "../api/axios";
import {
FieldConstraintModal,
LoginButton,
LoginInput,
RequiredAsterisk,
} from "../Components/Styled/Login.style";
import { Navigate } from "react-router-dom";
import AuthApi from "../api/AuthApi";
const REGISTRATION_URL = "/registration";
const Registration = () => {
const { auth, setAuth } = useContext(AuthApi);
const userRef = useRef();
const errRef = useRef();
const [fullName, setFullName] = useState("");
const [username, setUsername] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [errMsg, setErrMsg] = useState("");
const [registrationSuccessful, setRegistrationSuccessful] = useState(false);
useEffect(() => {
userRef.current.focus();
}, []);
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await axios(REGISTRATION_URL, {
method: "post",
headers: { "Content-Type": "application/json" },
data: {
fullName: fullName,
username: username,
email: email,
password: password,
},
});
setRegistrationSuccessful(true);
} catch (error) {
setErrMsg("Некои од полињата се неправилни.");
}
};
const [FieldConstraintModalOpacity1, setFieldConstraintModalOpacity1] =
useState(0);
const [FieldConstraintModalOpacity2, setFieldConstraintModalOpacity2] =
useState(0);
return auth ? (
Успешна регистрација! На {email} е испратен токен за потврда на сметката.
Оди на најава