diff --git a/captain-definition b/captain-definition new file mode 100644 index 0000000..338a4e5 --- /dev/null +++ b/captain-definition @@ -0,0 +1,12 @@ +{ + "schemaVersion": 2, + "dockerfileLines": [ + "FROM node", + "WORKDIR /app", + "COPY package*.json ./", + "RUN npm install", + "COPY . .", + "EXPOSE 3000", + "CMD [\"npm\", \"run\", \"start:dev\"]" + ] +} diff --git a/src/pages/EnterAccount.jsx b/src/pages/EnterAccount.jsx index 0fbc70c..df00423 100644 --- a/src/pages/EnterAccount.jsx +++ b/src/pages/EnterAccount.jsx @@ -5,123 +5,171 @@ import classes from "../assets/styles/enterAccount.module.scss"; import MyInput from "../components/MyInput.jsx"; import MyButton from "../components/MyButton.jsx"; import { UserData } from "../context"; -import { logIn, completeRegistration, verifyUserApi } from "../hooks/api/enterAccountApi.js"; +import { + logIn, + completeRegistration, + verifyUserApi, +} from "../hooks/api/enterAccountApi.js"; const EnterAccount = () => { - const [enter, setEnter] = useState("login"); - const navigate = useNavigate(); + const [enter, setEnter] = useState("login"); + const navigate = useNavigate(); - const [email, setEmail] = useState(""); - const [phone, setPhone] = useState(""); - const [login, setLogin] = useState(""); - const [surname, setSurname] = useState(""); - const [patronymic, setPatronymic] = useState(""); - const [password, setPassword] = useState(""); - const [repiedPassword, setRepiedPassword] = useState(""); + const [email, setEmail] = useState(""); + const [phone, setPhone] = useState(""); + const [login, setLogin] = useState(""); + const [surname, setSurname] = useState(""); + const [patronymic, setPatronymic] = useState(""); + const [password, setPassword] = useState(""); + const [repiedPassword, setRepiedPassword] = useState(""); - const {user, setUser} = useContext(UserData); - const [cookies, setCookie, removeCookie] = useCookies(["user"]); + const { user, setUser } = useContext(UserData); + const [cookies, setCookie, removeCookie] = useCookies(["user"]); - function cleanState() { - setEmail(""); - setPhone(""); - setLogin(""); - setSurname(""); - setPatronymic(""); - setPassword(""); - setRepiedPassword(""); - }; + function cleanState() { + setEmail(""); + setPhone(""); + setLogin(""); + setSurname(""); + setPatronymic(""); + setPassword(""); + setRepiedPassword(""); + } - function selectTag(tag) { - setEnter(tag); - cleanState(); - }; + function selectTag(tag) { + setEnter(tag); + cleanState(); + } - async function createUser() { - const response = await completeRegistration({ - login: login, - password: password, - repiedPassword: repiedPassword - }); + async function createUser() { + const response = await completeRegistration({ + login: login, + password: password, + repiedPassword: repiedPassword, + }); - if (response.status === 200) { - setUser({ - email: email, - phone: phone, - login: login, - surname: surname, - patronymic: patronymic, - password: password, - }); - setCookie("token", response.data.token); - cleanState(); - window.location.reload(); - // navigate("/"); - } - else { - console.log("Error") - } - }; - - async function logInToAccount() { - const response = await logIn(login, password) - - if (response.status === 200) { - setCookie("token", response.data.token); - cleanState(); - // setUser({ - // login: login - // }) - window.location.reload(); - // navigate("/") - // window.location.reload() - } - else { - console.log(response) - } + if (response.status === 200) { + setUser({ + email: email, + phone: phone, + login: login, + surname: surname, + patronymic: patronymic, + password: password, + }); + setCookie("token", response.data.token); + cleanState(); + window.location.reload(); + // navigate("/"); + } else { + console.log("Error"); } + } - return ( -