Skip to content

Commit

Permalink
React: Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborrosta committed Mar 30, 2024
1 parent 72f7e19 commit adbbddd
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/EditLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import { Modal, Form, Button, Alert, Row, Col } from "react-bootstrap";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";

function EditLocationContent({ location, mazesChanged, locationsChanged }) {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/MazeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Modal, Form, Button, Alert, Row, Col } from "react-bootstrap";
import LocationList from "./LocationList";
import { BACKEND_URL, FRONTEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";
import PDFButtons from "./PDFButtons";

function MazeModalContent({ mazeData, locations, mazeChanged, locationsChanged, token, setToken }) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { Container, Nav, Navbar, Form} from "react-bootstrap";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";

export default function Menu() {
const { i18n, t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ArrowUp, X } from "react-bootstrap-icons";
import ScrollToTop from "react-scroll-to-top";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";
import LoadingSpinner from "../components/LoadingSpinner";
import MazeModal from "../components/MazeModal";
import LocationList from "../components/LocationList";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/CheckMaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CheckMazeRecognise from "../components/CheckMazeRecognise";
import CheckMazeResults from "../components/CheckMazeResults";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";
import TokenRefresher from "../utils/TokenRefresher";

export default function CheckMaze() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/GenerateMaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MazeModal from "../components/MazeModal";
import SolutionIDForm from "../components/SolutionIDForm";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";
import ScrollToTop from "react-scroll-to-top";

export default function GenerateMaze() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNavigate, Link, useLocation } from "react-router-dom"
import { Form, Button, InputGroup, Alert } from "react-bootstrap";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";

export default function Login() {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useNavigate, Link } from "react-router-dom"
import { Form, Button, InputGroup, Alert } from "react-bootstrap";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";

export default function Signup() {
const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/SolveMaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
import { Form, Button, Alert, Row, Col } from "react-bootstrap";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "../utils/TokenContext";
import TokenContext from "../utils/TokenContext";
import LoadingSpinner from "../components/LoadingSpinner";
import MazeOnlineSolve from "../components/MazeOnlineSolve";
import CheckMazeResults from "../components/CheckMazeResults";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/AuthChecker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { toBeInTheDocument } from "@testing-library/jest-dom";
import { TokenContext } from "./TokenContext";
import { MemoryRouter } from "react-router-dom";
import TokenContext from "./TokenContext";
import AuthChecker from "./AuthChecker";

//Mock the Navigate component from react-router-dom
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Container, Modal } from "react-bootstrap";
import Menu from "../components/Menu";
import { BACKEND_URL } from "../utils/constants";
import axios from "axios";
import { TokenContext } from "./TokenContext";
import TokenContext from "./TokenContext";

const SessionExpired = {
NO: -1,
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/utils/TokenContext.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { createContext } from "react";

export const TokenContext = createContext({
/**
* TokenContext helps managing authentication token.
* It provides a context object with the following properties:
* - token: A string representing the current authentication token.
* - setToken: A function for setting the current authentication token.
* - logout: A function for logging out the user, which should clear the current authentication token.
*/
const TokenContext = createContext({
token: "",
setToken: () => {},
logout: () => {},
});

export default TokenContext;

0 comments on commit adbbddd

Please sign in to comment.