diff --git a/src/App.jsx b/src/App.jsx
index 6a2e781..7dd4742 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -38,6 +38,7 @@ const App = () => {
useEffect(() => {
async function verifyUser() {
const response = await verifyUserApi(cookies.token);
+ console.log("app", user)
if (response) {
if (response.status === 200) {
diff --git a/src/components/NavBar.jsx b/src/components/NavBar.jsx
index 462cc52..d613514 100644
--- a/src/components/NavBar.jsx
+++ b/src/components/NavBar.jsx
@@ -4,24 +4,9 @@ import classes from "../assets/styles/components/navbar.module.scss";
import { verifyUserApi } from "../hooks/api/enterAccountApi";
const NavBar = ({navigate, auth, setAuth}) => {
- // const [cookies, _, __] = useCookies(["user"]);
-
- // useEffect(() => {
- // async function verifyUser() {
- // const response = await verifyUserApi(cookies.token);
-
- // if (response) {
- // if (response.status === 200) {
- // setAuth(response.data);
- // }
- // else {
- // console.log(response)
- // }
- // }
- // }
-
- // verifyUser()
- // }, []);
+ useEffect(() => {
+ console.log("nav", auth)
+ })
return (
diff --git a/src/hooks/validation/enterAccountValidate.js b/src/hooks/validation/enterAccountValidate.js
index 6234291..c5381e9 100644
--- a/src/hooks/validation/enterAccountValidate.js
+++ b/src/hooks/validation/enterAccountValidate.js
@@ -17,7 +17,7 @@ const totalRegisterValidate = (data) => {
// constructorAnswerValidate(data.email.length, "Обязательное поле."),
// constructorAnswerValidate(data.phone.length, "Обязательное поле."),
constructorAnswerValidate(data.password === data.repiedPassword, "Введенные пароли не совпадают."),
- constructorAnswerValidate(data.password >= 8, "Пароль должен иметь более 8 символов.")
+ // constructorAnswerValidate(data.password >= 8, "Пароль должен иметь более 8 символов.")
]
for (let value of listValidation) {
diff --git a/src/pages/EnterAccount.jsx b/src/pages/EnterAccount.jsx
index 0fbc70c..6060be1 100644
--- a/src/pages/EnterAccount.jsx
+++ b/src/pages/EnterAccount.jsx
@@ -45,18 +45,11 @@ const EnterAccount = () => {
});
if (response.status === 200) {
- setUser({
- email: email,
- phone: phone,
- login: login,
- surname: surname,
- patronymic: patronymic,
- password: password,
- });
+ const responseMe = await verifyUserApi(response.data.token)
+ setUser(responseMe.data);
setCookie("token", response.data.token);
cleanState();
- window.location.reload();
- // navigate("/");
+ navigate("/");
}
else {
console.log("Error")
@@ -68,13 +61,11 @@ const EnterAccount = () => {
if (response.status === 200) {
setCookie("token", response.data.token);
+ const responseMe = await verifyUserApi(response.data.token)
+ setUser(responseMe.data)
+
cleanState();
- // setUser({
- // login: login
- // })
- window.location.reload();
- // navigate("/")
- // window.location.reload()
+ navigate("/")
}
else {
console.log(response)