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

updated sql file names and backend to matach main

parent ad7ac9b5
No related branches found
No related tags found
No related merge requests found
import React, { useState, useEffect} from 'react'; import React, { useState, useEffect } from "react";
import Table from '@mui/material/Table'; import Table from "@mui/material/Table";
import TableBody from '@mui/material/TableBody'; import TableBody from "@mui/material/TableBody";
import TableCell from '@mui/material/TableCell'; import TableCell from "@mui/material/TableCell";
import TableContainer from '@mui/material/TableContainer'; import TableContainer from "@mui/material/TableContainer";
import TableHead from '@mui/material/TableHead'; import TableHead from "@mui/material/TableHead";
import TableRow from '@mui/material/TableRow'; import TableRow from "@mui/material/TableRow";
import Paper from '@mui/material/Paper'; import Paper from "@mui/material/Paper";
import Axios from "axios"; import Axios from "axios";
import { Button } from '@mui/material'; import { Button } from "@mui/material";
export const ListAllOrganizations = (props) => { export const ListAllOrganizations = (props) => {
const [rows, setRows] = useState([]); // State to store the rows const [rows, setRows] = useState([]); // State to store the rows
...@@ -16,10 +16,12 @@ export const ListAllOrganizations = (props) => { ...@@ -16,10 +16,12 @@ export const ListAllOrganizations = (props) => {
useEffect(() => { useEffect(() => {
const fetchOrganizations = async () => { const fetchOrganizations = async () => {
try { try {
const response = await Axios.get("http://localhost:8080/organization/all"); const response = await Axios.get(
"http://localhost:8080/organization/all"
);
setRows(response.data); // Update state with fetched data setRows(response.data); // Update state with fetched data
} catch (error) { } catch (error) {
console.error('Error fetching data: ', error); console.error("Error fetching data: ", error);
} }
}; };
...@@ -43,15 +45,14 @@ export const ListAllOrganizations = (props) => { ...@@ -43,15 +45,14 @@ export const ListAllOrganizations = (props) => {
{rows.map((row) => ( {rows.map((row) => (
<TableRow <TableRow
key={row.name} key={row.name}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }} sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
>
<TableCell component="th" scope="row"> <TableCell component="th" scope="row">
{row.name} {row.name}
</TableCell> </TableCell>
<TableCell align="right">{row.category}</TableCell> <TableCell align="right">{row.category}</TableCell>
<TableCell align="right">{row.description}</TableCell> <TableCell align="right">{row.description}</TableCell>
<TableCell align="right">{row.owner}</TableCell> <TableCell align="right">{row.ownerEmail}</TableCell>
<TableCell align="right">{row.membercount}</TableCell> <TableCell align="right">{row.memberCount}</TableCell>
</TableRow> </TableRow>
))} ))}
</TableBody> </TableBody>
...@@ -59,4 +60,4 @@ export const ListAllOrganizations = (props) => { ...@@ -59,4 +60,4 @@ export const ListAllOrganizations = (props) => {
</TableContainer> </TableContainer>
</div> </div>
); );
} };
\ No newline at end of file
DROP DATABASE IF EXISTS inventory; DROP DATABASE IF EXISTS inventory;
CREATE DATABASE IF NOT EXISTS inventory; CREATE DATABASE IF NOT EXISTS inventory;
USE inventory; USE inventory;
CREATE TABLE IF NOT EXISTS USER ( CREATE TABLE IF NOT EXISTS USER (
email VARCHAR(128) NOT NULL, email VARCHAR(128) NOT NULL,
lname VARCHAR(64) NOT NULL, lname VARCHAR(64) NOT NULL,
...@@ -11,75 +10,92 @@ CREATE TABLE IF NOT EXISTS USER ( ...@@ -11,75 +10,92 @@ CREATE TABLE IF NOT EXISTS USER (
PRIMARY KEY (email) PRIMARY KEY (email)
); );
INSERT INTO USER (email, lname, fname, password, phone_number) VALUES
('johnsmith@example.com', 'Smith', 'John', 'password123', '123-456-7890'),
('alicedoe@example.com', 'Doe', 'Alice', 'securepass', '987-654-3210'),
('emilyjohnson@example.com', 'Johnson', 'Emily', 'sciencePass', '8888888888');
SELECT * FROM USER;
DELETE FROM USER;
CREATE TABLE IF NOT EXISTS ORGANIZATION ( CREATE TABLE IF NOT EXISTS ORGANIZATION (
organization_id INT AUTO_INCREMENT, organization_id INT AUTO_INCREMENT,
name VARCHAR(256) NOT NULL, name VARCHAR(256) NOT NULL,
email VARCHAR(128) NOT NULL, email VARCHAR(128) NOT NULL,
description VARCHAR(1024), description VARCHAR(1024),
owner VARCHAR(128), owner_email VARCHAR(128) NOT NULL,
category ENUM('ACADEMIC', 'RECREATION', 'TECHNOLOGY', 'POLITICS', 'GREEK LIFE'), category ENUM('ACADEMIC', 'RECREATION', 'TECHNOLOGY', 'POLITICS', 'GREEK LIFE'),
memberCount INT DEFAULT 1, member_count INT DEFAULT 1,
PRIMARY KEY (organization_id), PRIMARY KEY (organization_id),
CONSTRAINT fk_user_organization FOREIGN KEY (owner) REFERENCES USER (email) CONSTRAINT fk_user_organization FOREIGN KEY (owner_email) REFERENCES USER (email)
); );
CREATE TABLE IF NOT EXISTS MANAGER ( INSERT INTO ORGANIZATION (name, email, description, owner_email, category, member_count) VALUES
userEmail VARCHAR(128) NOT NULL, ('Coding Club', 'coding@example.com', 'Club for programming enthusiasts', 'johnsmith@example.com', 'TECHNOLOGY', 15),
('Chess Society', 'chesssociety@example.com', 'Organization for chess lovers', 'alicedoe@example.com', 'RECREATION', 20),
('Science Association', 'science@example.com', 'Encouraging scientific exploration', 'johnsmith@example.com', 'ACADEMIC', 30),
('Political Discussion Group', 'politics@example.com', 'Discussions on current political affairs', 'alicedoe@example.com', 'POLITICS', 25),
('Greek Life Association', 'greeklife@example.com', 'Promoting Greek culture and traditions', 'emilyjohnson@example.com', 'GREEK LIFE', 40);
CREATE TABLE IF NOT EXISTS ORGANIZATION_ROSTER (
user_email VARCHAR(128) NOT NULL,
organization_id INT NOT NULL, organization_id INT NOT NULL,
PRIMARY KEY (userEmail, organization_id), type ENUM('MEMBER', 'MANAGER') NOT NULL,
CONSTRAINT fk_user_manager FOREIGN KEY (userEmail) REFERENCES USER (email), PRIMARY KEY (user_email, organization_id),
CONSTRAINT fk_user_manager FOREIGN KEY (user_email) REFERENCES USER (email),
CONSTRAINT fk_organization_manager FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id) CONSTRAINT fk_organization_manager FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
); );
CREATE TABLE IF NOT EXISTS REQUEST ( CREATE TABLE IF NOT EXISTS REQUEST (
requestId INT AUTO_INCREMENT NOT NULL, request_id INT AUTO_INCREMENT NOT NULL,
userEmail VARCHAR(128) NOT NULL, user_email VARCHAR(128) NOT NULL,
organization_id INT NOT NULL, organization_id INT NOT NULL,
status ENUM('PENDING', 'ACCEPTED', 'DECLINED') NOT NULL, status ENUM('PENDING', 'ACCEPTED', 'DECLINED') NOT NULL,
description VARCHAR(256), description VARCHAR(256),
type ENUM('JOIN', 'ITEM') NOT NULL, type ENUM('JOIN', 'ITEM') NOT NULL,
PRIMARY KEY (requestId), PRIMARY KEY (request_id),
CONSTRAINT fk_user_request FOREIGN KEY (userEmail) REFERENCES USER (email), CONSTRAINT fk_user_request FOREIGN KEY (user_email) REFERENCES USER (email),
CONSTRAINT fk_organization_request FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id) CONSTRAINT fk_organization_request FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
); );
CREATE TABLE IF NOT EXISTS LOCATION ( CREATE TABLE IF NOT EXISTS LOCATION (
locationId INT AUTO_INCREMENT, location_id INT AUTO_INCREMENT,
location VARCHAR(256), location VARCHAR(256),
organization_id INT NOT NULL, organization_id INT NOT NULL,
PRIMARY KEY (locationId), PRIMARY KEY (location_id),
CONSTRAINT fk_organization_location FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id) CONSTRAINT fk_organization_location FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
); );
CREATE TABLE IF NOT EXISTS ITEM ( CREATE TABLE IF NOT EXISTS ITEM (
itemId INT AUTO_INCREMENT, item_id INT AUTO_INCREMENT,
name VARCHAR(128) NOT NULL, name VARCHAR(128) NOT NULL,
description VARCHAR(256), description VARCHAR(256),
ownerEmail VARCHAR(128), owner_email VARCHAR(128),
quantity INT NOT NULL, quantity INT NOT NULL,
category VARCHAR(128), category VARCHAR(128),
status ENUM('AVAILABLE', 'BORROWED', 'LISTED', 'SOLD') NOT NULL, status ENUM('AVAILABLE', 'BORROWED', 'LISTED', 'SOLD') NOT NULL,
locationId INT NOT NULL, location_id INT NOT NULL,
organization_id INT NOT NULL, organization_id INT NOT NULL,
PRIMARY KEY (itemId), PRIMARY KEY (item_id),
CONSTRAINT fk_location_item FOREIGN KEY (locationId) REFERENCES LOCATION (locationId), CONSTRAINT fk_location_item FOREIGN KEY (location_id) REFERENCES LOCATION (location_id),
CONSTRAINT fk_organiztion_item FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id) CONSTRAINT fk_organiztion_item FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
); );
CREATE TABLE IF NOT EXISTS LISTING ( CREATE TABLE IF NOT EXISTS LISTING (
listingId INT AUTO_INCREMENT, listing_id INT AUTO_INCREMENT,
itemId INT NOT NULL, item_id INT NOT NULL,
price DECIMAL(6,2) NOT NULL, price DECIMAL(6,2) NOT NULL,
status ENUM('AVAILABLE', 'SOLD') NOT NULL, status ENUM('AVAILABLE', 'SOLD') NOT NULL,
dateListed TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, date_listed TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (listingId), PRIMARY KEY (listing_id),
CONSTRAINT fk_item_listing FOREIGN KEY (itemId) REFERENCES ITEM (itemId) CONSTRAINT fk_item_listing FOREIGN KEY (item_id) REFERENCES ITEM (item_id)
); );
CREATE TABLE IF NOT EXISTS FAVORITE ( CREATE TABLE IF NOT EXISTS FAVORITE (
userEmail VARCHAR(128) NOT NULL, user_email VARCHAR(128) NOT NULL,
listingId INT NOT NULL, listing_id INT NOT NULL,
PRIMARY KEY (userEmail, listingId), PRIMARY KEY (user_email, listing_id),
CONSTRAINT fk_user_favorite FOREIGN KEY (userEmail) REFERENCES USER (email), CONSTRAINT fk_user_favorite FOREIGN KEY (user_email) REFERENCES USER (email),
CONSTRAINT fk_listing_favorite FOREIGN KEY (listingId) REFERENCES LISTING (listingId) CONSTRAINT fk_listing_favorite FOREIGN KEY (listing_id) REFERENCES LISTING (listing_id)
); );
\ No newline at end of file
...@@ -19,13 +19,13 @@ public class Organization { ...@@ -19,13 +19,13 @@ public class Organization {
private String category; private String category;
private Integer membercount; private Integer memberCount;
private String name; private String name;
private String email; private String email;
private String owner; private String ownerEmail;
private String description; private String description;
...@@ -45,12 +45,12 @@ public class Organization { ...@@ -45,12 +45,12 @@ public class Organization {
this.category = category; this.category = category;
} }
public Integer getMembercount() { public Integer getMemberCount() {
return membercount; return memberCount;
} }
public void setMembercount(Integer membercount) { public void setMemberCount(Integer membercount) {
this.membercount = membercount; this.memberCount = membercount;
} }
public String getEmail() { public String getEmail() {
...@@ -77,12 +77,12 @@ public class Organization { ...@@ -77,12 +77,12 @@ public class Organization {
this.description = description; this.description = description;
} }
public String getOwner() { public String getOwnerEmail() {
return owner; return ownerEmail;
} }
public void setOwner(String owner) { public void setOwnerEmail(String ownerEmail) {
this.owner = owner; this.ownerEmail = ownerEmail;
} }
@Id @Id
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/inventory spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/inventory
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=CSD@mysql-1872 spring.datasource.password=APbmCP70!
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.jpa.show-sql: true #spring.jpa.show-sql: true
\ No newline at end of file
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