From 5e14e0eecd7bcfb8c982afe797f7e91f82063f13 Mon Sep 17 00:00:00 2001
From: guadiamosS <guadiamos19@vt.edu>
Date: Tue, 27 Feb 2024 16:47:00 -0500
Subject: [PATCH] front-end back-end communication for login info

---
 crisis-react/package.json            |   1 +
 crisis-react/src/login.jsx           |  30 ++++++++++++++++++++++++++-
 crisis_events.db                     | Bin 12288 -> 12288 bytes
 crisis_events_database_metadata.json |   2 +-
 flask_backend.py                     |  22 ++++++++++++++++----
 5 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/crisis-react/package.json b/crisis-react/package.json
index c5e2673..b878f70 100644
--- a/crisis-react/package.json
+++ b/crisis-react/package.json
@@ -1,6 +1,7 @@
 {
   "name": "crisis-react",
   "private": true,
+  "proxy":"http://localhost:5000/",
   "version": "0.0.0",
   "type": "module",
   "scripts": {
diff --git a/crisis-react/src/login.jsx b/crisis-react/src/login.jsx
index 1fd6e6a..ef45c2c 100644
--- a/crisis-react/src/login.jsx
+++ b/crisis-react/src/login.jsx
@@ -1,6 +1,31 @@
 import React, { useState } from 'react'
 import './styles.css';
 
+
+//takes in signup information
+
+async function PostSignInfo(data)
+{
+
+    try 
+    {
+     const respone = await fetch("http://127.0.0.1:5000/login", {
+        method: "POST", // or 'PUT'
+        headers: {
+          "Content-Type": "application/json",
+        },
+        body: JSON.stringify(data),
+      });
+
+    
+    }
+
+    catch (error) {
+        console.error("Could not upload signup information successfully", error);
+      }
+}
+
+
 function Login() {
     const [username, setUsername] = useState('');
     const [password, setPassword] = useState('');
@@ -8,12 +33,15 @@ function Login() {
     const handleSubmit = (e) => {
         e.preventDefault();
 
+         PostSignInfo({ username, password });
+
+
     };
 
     const loginForm = (
         <div className="login-container">
             <h2>Enter Username</h2>
-            <form onSubmit="{handleSubmit}">
+            <form onSubmit={handleSubmit}>
                 <div className="input-group">
                     <label htmlFor="username">enter username</label>
                     <input
diff --git a/crisis_events.db b/crisis_events.db
index 345fbc70b40e54405907573f78b1e3c56c59bc32..018b3faf2a762a7dbea3c4a227489df8131acf34 100644
GIT binary patch
delta 86
zcmZojXh@hKEojfcz`zW|FtBN&jxnSC#)M!#Mx)7F_;MHxCoA$l=3x+EVBo*czn6aw
ffB9xXg>?SO<?_93V9|>}{x1HB0qm1c>ze`qG0zo4

delta 86
zcmZojXh@hKEy&Kmz`zW|FfeJNjxi(q#)M!#My1JH_;MH(CoA$l=3(Za!@z%^e=q+W
i{_@R&3hDfl%jJ9782K+U@LvS-ckxdQV4r+i-xL5UVHN@a

diff --git a/crisis_events_database_metadata.json b/crisis_events_database_metadata.json
index c672fa4..2fb8be4 100644
--- a/crisis_events_database_metadata.json
+++ b/crisis_events_database_metadata.json
@@ -1 +1 @@
-{"Users": 1, "Collections": 3}
\ No newline at end of file
+{"Users": 0, "Collections": 0}
\ No newline at end of file
diff --git a/flask_backend.py b/flask_backend.py
index 9fd2a2f..daac109 100644
--- a/flask_backend.py
+++ b/flask_backend.py
@@ -1,8 +1,12 @@
 from flask import Flask, request, abort
+from flask_cors import CORS
 from database_api import CrisisEventsDatabase
 from runtime_import import runtime_import
 
 app = Flask(__name__)
+#pip install flask-cors
+CORS(app) 
+
 
 database:CrisisEventsDatabase = None
 
@@ -30,6 +34,13 @@ def database_debug_view():
     </body>
     </html>
     """
+@app.route('/login', methods = ['POST'])
+def login():
+     
+    data = request.json  # Retrieve JSON data from the request
+    print(f'The login data: {data}')
+    return 'Login successful', 200  # Return a response to indicate success
+
 
 
 @app.route('/database_service', methods=['POST','GET'])
@@ -56,12 +67,15 @@ def database_service():
     else:
         abort(400)
 
+ 
+
+
 
 if __name__ == '__main__':
     database = runtime_import("database_implementation/")[0].IMPLEMENTATION()
     database.initialize()
-    database.create_user("test_user","12345")
-    database.create_collection(0,"First Collection")
-    database.create_collection(0,"Second Collection")
-    database.create_collection(0,"Third Collection")
+   # database.create_user("test_user","12345")
+    #database.create_collection(0,"First Collection")
+    #database.create_collection(0,"Second Collection")
+    #database.create_collection(0,"Third Collection")
     app.run()
\ No newline at end of file
-- 
GitLab