Skip to content
Snippets Groups Projects
Commit 59fde02e authored by Shrey Patel's avatar Shrey Patel
Browse files

added form for GUI

parent 0c6cc8ac
No related branches found
No related tags found
No related merge requests found
......@@ -31,4 +31,6 @@ build/
!**/src/test/**/build/
### VS Code ###
.vscode/
\ No newline at end of file
.vscode/
src/main/resources/application.properties
src/main/resources/application.properties
......@@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.18.0",
......@@ -5315,6 +5316,29 @@
"node": ">=4"
}
},
"node_modules/axios": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.0.tgz",
"integrity": "sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/axobject-query": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
......@@ -14420,6 +14444,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
......
......@@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.6.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.18.0",
......
......@@ -6,16 +6,6 @@
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
......
import React, { useState } from "react";
import Axios from "axios";
export const Register = (props) => {
const [email, setEmail] = useState("");
const [pid, setPid] = useState("");
const [pass, setPass] = useState("");
const [fname, setFname] = useState("");
const [lname, setLname] = useState("");
const [email, setEmail] = useState("");
const [phoneNumber, setPhoneNumber] = useState("");
const [pass, setPass] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
console.log(fname);
console.log(lname);
console.log(email);
console.log(phoneNumber);
console.log(pass);
Axios.post("http://localhost:8080/user/add", {
email: email,
lname: lname,
fname: fname,
phoneNumber: phoneNumber,
password: pass,
});
};
return (
......@@ -46,22 +59,13 @@ export const Register = (props) => {
<label htmlFor="phoneNumber">Phone Number</label>
<input
value={pid}
onChange={(e) => setPid(e.target.value)}
value={phoneNumber}
onChange={(e) => setPhoneNumber(e.target.value)}
id="phoneNumber"
name="phoneNumber"
placeholder="###-###-####"
/>
<label htmlFor="pid">PID</label>
<input
value={pid}
onChange={(e) => setPid(e.target.value)}
name="pid"
id="pid"
placeholder="Your PID"
/>
<label htmlFor="password">Password</label>
<input
value={pass}
......
-- DROP DATABASE IF EXISTS inventory;
-- CREATE DATABASE IF NOT EXISTS inventory;
DROP DATABASE IF EXISTS inventory;
CREATE DATABASE IF NOT EXISTS inventory;
CREATE TABLE IF NOT EXISTS USER (
pid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
lname VARCHAR(64) NOT NULL,
fname VARCHAR(64) NOT NULL,
password VARCHAR(32) NOT NULL,
phone_number VARCHAR(14),
email VARCHAR(128) NOT NULL,
PRIMARY KEY (pid)
PRIMARY KEY (email)
);
CREATE TABLE IF NOT EXISTS ORGANIZATION (
......@@ -16,28 +15,28 @@ CREATE TABLE IF NOT EXISTS ORGANIZATION (
name VARCHAR(256) NOT NULL,
email VARCHAR(128) NOT NULL,
description VARCHAR(1024),
ownerPid INT NOT NULL,
ownerEmail VARCHAR(128) NOT NULL,
PRIMARY KEY (organizationId),
CONSTRAINT fk_user_organization FOREIGN KEY (ownerPid) REFERENCES USER (pid)
CONSTRAINT fk_user_organization FOREIGN KEY (ownerEmail) REFERENCES USER (email)
);
CREATE TABLE IF NOT EXISTS MANAGER (
userPid INT NOT NULL,
userEmail VARCHAR(128) NOT NULL,
organizationId INT NOT NULL,
PRIMARY KEY (userPid, organizationId),
CONSTRAINT fk_user_manager FOREIGN KEY (userPid) REFERENCES USER (pid),
CONSTRAINT fk_user_manager FOREIGN KEY (userEmail) REFERENCES USER (email),
CONSTRAINT fk_organization_manager FOREIGN KEY (organizationId) REFERENCES ORGANIZATION (organizationId)
);
CREATE TABLE IF NOT EXISTS REQUEST (
requestId INT AUTO_INCREMENT NOT NULL,
userPid INT NOT NULL,
userEmail VARCHAR(128) NOT NULL,
organizationId INT NOT NULL,
status ENUM('PENDING', 'ACCEPTED', 'DECLINED') NOT NULL,
description VARCHAR(256),
type ENUM('JOIN', 'ITEM') NOT NULL,
PRIMARY KEY (requestId),
CONSTRAINT fk_user_request FOREIGN KEY (userPid) REFERENCES USER (pid),
CONSTRAINT fk_user_request FOREIGN KEY (userEmail) REFERENCES USER (email),
CONSTRAINT fk_organization_request FOREIGN KEY (organizationId) REFERENCES ORGANIZATION (organizationId)
);
......@@ -75,10 +74,10 @@ CREATE TABLE IF NOT EXISTS LISTING (
);
CREATE TABLE IF NOT EXISTS FAVORITE (
userPid INT NOT NULL,
userEmail VARCHAR(128) NOT NULL,
listingId INT NOT NULL,
PRIMARY KEY (userPid, listingId),
CONSTRAINT fk_user_favorite FOREIGN KEY (userPid) REFERENCES USER (pid),
PRIMARY KEY (userEmail, listingId),
CONSTRAINT fk_user_favorite FOREIGN KEY (userEmail) REFERENCES USER (email),
CONSTRAINT fk_listing_favorite FOREIGN KEY (listingId) REFERENCES LISTING (listingId)
);
......
......@@ -7,7 +7,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller // This means that this class is a Controller
@RequestMapping(path="/demo") // This means URL's start with /demo (after Application path)
@RequestMapping(path="/user") // This means URL's start with /demo (after Application path)
public class MainController {
@Autowired // This means to get the bean called userRepository
// Which is auto-generated by Spring, we will use it to handle the data
......
......@@ -6,13 +6,6 @@ import jakarta.persistence.*;
@Entity // This tells Hibernate to make a table out of this class
@Table(name = "USER")
public class User {
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public String getFname() {
return fname;
......@@ -46,9 +39,6 @@ public class User {
this.phoneNumber = phoneNumber;
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer pid;
private String fname;
......@@ -58,7 +48,8 @@ public class User {
private Integer phoneNumber;
@Id
@Column(nullable = false)
private String email;
public String getEmail() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment