Changeset 6eba109 for reactapp/src/Pages
- Timestamp:
- 08/17/22 16:21:10 (2 years ago)
- Branches:
- main
- Children:
- 702ca77
- Parents:
- 800779d
- Location:
- reactapp/src/Pages
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/Pages/Home.js
r800779d r6eba109 20 20 </a>{" "} 21 21 <Search /> 22 <div style={{ marginTop: "140px" }}></div> 22 23 <Outlet /> 23 24 </MainWrapper> -
reactapp/src/Pages/Login.js
r800779d r6eba109 1 import React, { useRef, useState, useEffect } from "react"; 1 import React, { useRef, useState, useEffect, useContext } from "react"; 2 import { Navigate } from "react-router-dom"; 3 import AuthApi from "../api/AuthApi"; 2 4 import axios from "../api/axios"; 5 import Cookies from "js-cookie"; 3 6 const LOGIN_URL = "/login"; 4 7 5 8 const Login = () => { 9 const { auth, setAuth } = useContext(AuthApi); 6 10 const userRef = useRef(); 7 11 const errRef = useRef(); … … 10 14 const [password, setPassword] = useState(""); 11 15 const [errMsg, setErrMsg] = useState(""); 12 const [success, setSuccess] = useState(false);13 16 14 17 useEffect(() => { 15 18 userRef.current.focus(); 16 19 }, []); 17 18 useEffect(() => {19 setErrMsg("");20 }, [username, password]);21 20 22 21 const handleSubmit = async (e) => { … … 33 32 } 34 33 ); 34 if (!response.request.responseURL.includes("error")) { 35 // ako NE redirektira na /login?error 36 Cookies.set("JSESSIONID", response.data.sessionId); 37 setAuth(true); 38 setErrMsg(""); 39 } else { 40 setErrMsg("Погрешно корисиничко име и/или лозинка"); 41 } 42 35 43 setUsername(""); 36 44 setPassword(""); 37 setSuccess(true);38 45 }; 39 46 40 return success ? ( 47 const handleLogout = () => { 48 setAuth(false); 49 Cookies.remove("JSESSIONID"); 50 }; 51 52 return auth ? ( 53 /* 41 54 <div style={{ marginTop: "140px" }}> 42 55 <h1>Успешна најава!</h1> 43 56 <br /> 44 57 <p> 45 <a href="/ ">Оди на почетната страница</a>58 <a href="/user">Оди на protected</a> 46 59 </p> 60 <button onClick={handleLogout}>Одјави се</button> 47 61 </div> 62 */ 63 <Navigate to="/user" /> 48 64 ) : ( 49 65 <div style={{ marginTop: "140px" }}> -
reactapp/src/Pages/Professor.js
r800779d r6eba109 18 18 19 19 useEffect(() => { 20 const url = `http://192.168.0.1 7:8080/public/professor/${params.professorId}`;20 const url = `http://192.168.0.18:8080/public/professor/${params.professorId}`; 21 21 22 22 const fetchData = async () => {
Note:
See TracChangeset
for help on using the changeset viewer.