source: frontend/src/Components/Layout/Navbar/Navigation.js@ ac19a0c

Last change on this file since ac19a0c was ac19a0c, checked in by darsov2 <62809499+darsov2@…>, 9 months ago

authContext impl, admin panel impl, search bar fixes, reservations listings impl

  • Property mode set to 100644
File size: 3.2 KB
Line 
1import { Button } from "react-bootstrap";
2import React from "react";
3import { Container, Image, Navbar } from "react-bootstrap";
4import { Nav } from "react-bootstrap";
5import { BsFillPersonFill } from "react-icons/bs";
6import { useNavigate } from "react-router-dom";
7import useGet from "../../Hooks/useGet";
8import axios from "../../../axios.js";
9import {useAuth} from "../../Context/AuthContext";
10//import logo from 'assets/images/logo.png';
11//src="https://upload.wikimedia.org/wikipedia/commons/0/08/Vergina_Sun_-_Golden_Larnax.png"
12
13function Navigation(props) {
14 const navigator = useNavigate();
15 const Auth = useAuth();
16 const isLoggedIn = Auth.userIsAuthenticated();
17 return (
18 <>
19 <Navbar
20 bg="white"
21 variant="white"
22 expand="md"
23 className={props.mt == "0" ? "px-5 m-4" : ""}
24 >
25 <Container>
26 <Navbar.Brand href="/home">
27 <span className="ikona">
28 <Image
29 id="background-img"
30 src="https://i.ibb.co/BwtmZqX/logo.png"
31 width={60}
32 height={60}
33 ></Image>
34 </span>
35 <span className="mx-3 ikona">
36 <span className="svetlo">Tour</span>
37 <span className="temno">Mate</span>
38 </span>
39 </Navbar.Brand>
40 <Navbar.Toggle aria-controls="navbarScroll" />
41 <Navbar.Collapse id="navbarScroll">
42 <Nav className="ms-auto" navbarScroll>
43 <Nav.Link className="m-2" href="/home">
44 Home
45 </Nav.Link>
46 <Nav.Link className="m-2" href="#features">
47 Features
48 </Nav.Link>
49 <Nav.Link className="m-2" href="#pricing">
50 Pricing
51 </Nav.Link>
52 {!isLoggedIn && (
53 <Button
54 className="m-2"
55 size="md"
56 style={{ backgroundColor: "#159895" }}
57 onClick={() => {
58 navigator("/login");
59 }}
60 >
61 <BsFillPersonFill size={"1.5em"}></BsFillPersonFill> Најави се
62 </Button>
63 )}
64 {isLoggedIn && (
65 <>
66 <Nav.Link className="m-2" href="/profile">
67 {Auth.getUser().username}
68 </Nav.Link>
69 <Button
70 className="m-2"
71 size="md"
72 style={{ backgroundColor: "#159895" }}
73 onClick={async () => {
74 await axios.get("/logout")
75 .then((res) => {
76 console.log(res);
77 Auth.userLogout();
78 })
79 .catch((err) => {
80 console.log(err)
81 window.location.href="/login"
82 })
83 }}
84 >
85 <BsFillPersonFill size={"1.5em"}></BsFillPersonFill>
86 Одјави се
87 </Button>
88 </>
89 )}
90 </Nav>
91 </Navbar.Collapse>
92 </Container>
93 </Navbar>
94 <br />
95 </>
96 );
97}
98
99export default Navigation;
Note: See TracBrowser for help on using the repository browser.