From 59a9882fcd28b4b0d8e2b8d4ad67d498d51a106c Mon Sep 17 00:00:00 2001
From: Nolwenn <28621493+NoB0@users.noreply.github.com>
Date: Tue, 21 Nov 2023 17:05:44 +0100
Subject: [PATCH] Remove changes to frontend related files
---
pkg_client/src/App.tsx | 21 ++----
.../src/components/LoginForm/LoginForm.tsx | 65 -------------------
pkg_client/src/contexts/UserContext.tsx | 22 -------
pkg_client/src/index.tsx | 8 +--
4 files changed, 7 insertions(+), 109 deletions(-)
delete mode 100644 pkg_client/src/components/LoginForm/LoginForm.tsx
delete mode 100644 pkg_client/src/contexts/UserContext.tsx
diff --git a/pkg_client/src/App.tsx b/pkg_client/src/App.tsx
index 4cca3ef..cb5e9be 100644
--- a/pkg_client/src/App.tsx
+++ b/pkg_client/src/App.tsx
@@ -1,24 +1,13 @@
-import React, { useContext } from "react";
+import React from "react";
import "./App.css";
import APIHandler from "./APIHandler";
-import LoginForm from "./components/LoginForm/LoginForm";
-import Container from 'react-bootstrap/Container'
-import { UserContext } from "./contexts/UserContext";
function App() {
- const { user } = useContext(UserContext);
-
- const content = !user ? : ;
-
return (
-
-
-
- {content}
-
-
-
+
);
}
-export default App;
+export default App;
\ No newline at end of file
diff --git a/pkg_client/src/components/LoginForm/LoginForm.tsx b/pkg_client/src/components/LoginForm/LoginForm.tsx
deleted file mode 100644
index 0c36514..0000000
--- a/pkg_client/src/components/LoginForm/LoginForm.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { useContext, useState } from "react";
-import { UserContext } from "../../contexts/UserContext";
-import axios from "axios";
-import Button from 'react-bootstrap/Button';
-import Form from 'react-bootstrap/Form';
-import Alert from 'react-bootstrap/Alert';
-import Row from 'react-bootstrap/Row';
-import Col from "react-bootstrap/Col";
-
-const LoginForm = () => {
- const { setUser } = useContext(UserContext);
- const [username, setUsername] = useState("");
- const [password, setPassword] = useState("");
- const [error, setError] = useState("");
- const baseURL = (window as any)["PKG_API_BASE_URL"] || "http://127.0.0.1:5000";
-
- const handleAuth = (isRegistration: boolean) => {
- axios.post(`${baseURL}/auth`, { username, password, isRegistration })
- .then((response) => {
- setUser(response.data.user);
- setError("");
- console.log(response.data.message);
- })
- .catch((error) => {
- setError(error.response.data.message);
- });
- }
-
- const login = () => {
- handleAuth(false);
- }
-
- const register = () => {
- handleAuth(true);
- }
-
- return (
-
- Username
- setUsername(e.target.value)} />
-
-
- Password
- setPassword(e.target.value)} />
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default LoginForm;
\ No newline at end of file
diff --git a/pkg_client/src/contexts/UserContext.tsx b/pkg_client/src/contexts/UserContext.tsx
deleted file mode 100644
index 0e00073..0000000
--- a/pkg_client/src/contexts/UserContext.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import React, { useState } from "react";
-
-export type User = {
- username: string;
- uri: string;
-}
-
-type UserProviderProps = {
- children: React.ReactNode;
-};
-
-export const UserContext = React.createContext<{ user: User | null; setUser: React.Dispatch>; }>({ user: null, setUser: () => { } });
-
-export const UserProvider: React.FC = ({ children, }: { children: React.ReactNode }) => {
- const [user, setUser] = useState(null);
-
- return (
-
- {children}
-
- );
-}
\ No newline at end of file
diff --git a/pkg_client/src/index.tsx b/pkg_client/src/index.tsx
index 2a657e1..eb06ee1 100644
--- a/pkg_client/src/index.tsx
+++ b/pkg_client/src/index.tsx
@@ -3,21 +3,17 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
-import 'bootstrap/dist/css/bootstrap.min.css';
-import { UserProvider } from './contexts/UserContext';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
-
-
-
+
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();
+reportWebVitals();
\ No newline at end of file