diff --git a/.gitignore b/.gitignore index c2234a6..b515f42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env img/node_modules +frontend/src/generated/graphql-types.ts diff --git a/frontend/src/components/AdminRouteProtection.tsx b/frontend/src/components/AdminRouteProtection.tsx index f72ff37..a806380 100644 --- a/frontend/src/components/AdminRouteProtection.tsx +++ b/frontend/src/components/AdminRouteProtection.tsx @@ -1,11 +1,12 @@ import { useContext } from "react"; import { Navigate } from "react-router-dom"; import { UserContext } from "./Layout"; +import { Role } from "../interface/types"; function AdminRouteProtection({ children }: { children: React.ReactNode }) { const userInfo = useContext(UserContext); - if (!userInfo.isLoggedIn || userInfo.role !== "ADMIN") { + if (!userInfo.isLoggedIn || userInfo.role !== Role.Admin) { return ; } diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 6ad7311..9c4cd61 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -9,9 +9,10 @@ import { import { Input, Button, message } from "antd"; import { Link } from "react-router-dom"; import { UserContext } from "../components/Layout"; -import { Role, useLogoutLazyQuery } from "../generated/graphql-types"; +import { useLogoutLazyQuery } from "../generated/graphql-types"; import Logo from "../assets/logo.png"; import RangePicker from "./RangePicker"; +import { Role } from "../interface/types"; const { Search } = Input; @@ -27,14 +28,13 @@ function Navbar() { ]; const onSearch = (value?: string) => { - console.log("value", value) if (value) { - navigate(`/search/${value}`) + navigate(`/search/${value}`); } else { - navigate("/search") + navigate("/search"); } - } - + }; + return (
diff --git a/frontend/src/interface/types.tsx b/frontend/src/interface/types.tsx index 781436c..95f2836 100644 --- a/frontend/src/interface/types.tsx +++ b/frontend/src/interface/types.tsx @@ -61,7 +61,7 @@ export interface NewProductFormValues { export type Article = { id: number; product?: ProductCard; - reservations?: Reservation[] | null + reservations?: Reservation[] | null; }; export type Reservation = { @@ -78,3 +78,8 @@ export type Reservation = { export type ReservationData = Reservation & { totalPrice?: number; }; + +export enum Role { + Admin = "Admin", + User = "User", +}