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 Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import React, { useState, useEffect } from "react";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import Paper from "@mui/material/Paper";
import Axios from "axios";
import { Button } from '@mui/material';
import { Button } from "@mui/material";
export const ListAllOrganizations = (props) => {
const [rows, setRows] = useState([]); // State to store the rows
......@@ -16,10 +16,12 @@ export const ListAllOrganizations = (props) => {
useEffect(() => {
const fetchOrganizations = async () => {
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
} catch (error) {
console.error('Error fetching data: ', error);
console.error("Error fetching data: ", error);
}
};
......@@ -43,15 +45,14 @@ export const ListAllOrganizations = (props) => {
{rows.map((row) => (
<TableRow
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">
{row.name}
</TableCell>
<TableCell align="right">{row.category}</TableCell>
<TableCell align="right">{row.description}</TableCell>
<TableCell align="right">{row.owner}</TableCell>
<TableCell align="right">{row.membercount}</TableCell>
<TableCell align="right">{row.ownerEmail}</TableCell>
<TableCell align="right">{row.memberCount}</TableCell>
</TableRow>
))}
</TableBody>
......@@ -59,4 +60,4 @@ export const ListAllOrganizations = (props) => {
</TableContainer>
</div>
);
}
\ No newline at end of file
};
DROP DATABASE IF EXISTS inventory;
CREATE DATABASE IF NOT EXISTS inventory;
USE inventory;
CREATE TABLE IF NOT EXISTS USER (
email VARCHAR(128) NOT NULL,
lname VARCHAR(64) NOT NULL,
......@@ -11,75 +10,92 @@ CREATE TABLE IF NOT EXISTS USER (
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 (
organization_id INT AUTO_INCREMENT,
name VARCHAR(256) NOT NULL,
email VARCHAR(128) NOT NULL,
description VARCHAR(1024),
owner VARCHAR(128),
owner_email VARCHAR(128) NOT NULL,
category ENUM('ACADEMIC', 'RECREATION', 'TECHNOLOGY', 'POLITICS', 'GREEK LIFE'),
memberCount INT DEFAULT 1,
member_count INT DEFAULT 1,
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 (
userEmail VARCHAR(128) NOT NULL,
INSERT INTO ORGANIZATION (name, email, description, owner_email, category, member_count) VALUES
('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,
PRIMARY KEY (userEmail, organization_id),
CONSTRAINT fk_user_manager FOREIGN KEY (userEmail) REFERENCES USER (email),
type ENUM('MEMBER', 'MANAGER') NOT NULL,
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)
);
CREATE TABLE IF NOT EXISTS REQUEST (
requestId INT AUTO_INCREMENT NOT NULL,
userEmail VARCHAR(128) NOT NULL,
request_id INT AUTO_INCREMENT NOT NULL,
user_email VARCHAR(128) NOT NULL,
organization_id 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 (userEmail) REFERENCES USER (email),
PRIMARY KEY (request_id),
CONSTRAINT fk_user_request FOREIGN KEY (user_email) REFERENCES USER (email),
CONSTRAINT fk_organization_request FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
);
CREATE TABLE IF NOT EXISTS LOCATION (
locationId INT AUTO_INCREMENT,
location_id INT AUTO_INCREMENT,
location VARCHAR(256),
organization_id INT NOT NULL,
PRIMARY KEY (locationId),
PRIMARY KEY (location_id),
CONSTRAINT fk_organization_location FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
);
CREATE TABLE IF NOT EXISTS ITEM (
itemId INT AUTO_INCREMENT,
item_id INT AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
description VARCHAR(256),
ownerEmail VARCHAR(128),
owner_email VARCHAR(128),
quantity INT NOT NULL,
category VARCHAR(128),
status ENUM('AVAILABLE', 'BORROWED', 'LISTED', 'SOLD') NOT NULL,
locationId INT NOT NULL,
location_id INT NOT NULL,
organization_id INT NOT NULL,
PRIMARY KEY (itemId),
CONSTRAINT fk_location_item FOREIGN KEY (locationId) REFERENCES LOCATION (locationId),
PRIMARY KEY (item_id),
CONSTRAINT fk_location_item FOREIGN KEY (location_id) REFERENCES LOCATION (location_id),
CONSTRAINT fk_organiztion_item FOREIGN KEY (organization_id) REFERENCES ORGANIZATION (organization_id)
);
CREATE TABLE IF NOT EXISTS LISTING (
listingId INT AUTO_INCREMENT,
itemId INT NOT NULL,
listing_id INT AUTO_INCREMENT,
item_id INT NOT NULL,
price DECIMAL(6,2) NOT NULL,
status ENUM('AVAILABLE', 'SOLD') NOT NULL,
dateListed TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (listingId),
CONSTRAINT fk_item_listing FOREIGN KEY (itemId) REFERENCES ITEM (itemId)
date_listed TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (listing_id),
CONSTRAINT fk_item_listing FOREIGN KEY (item_id) REFERENCES ITEM (item_id)
);
CREATE TABLE IF NOT EXISTS FAVORITE (
userEmail VARCHAR(128) NOT NULL,
listingId INT NOT NULL,
PRIMARY KEY (userEmail, listingId),
CONSTRAINT fk_user_favorite FOREIGN KEY (userEmail) REFERENCES USER (email),
CONSTRAINT fk_listing_favorite FOREIGN KEY (listingId) REFERENCES LISTING (listingId)
user_email VARCHAR(128) NOT NULL,
listing_id INT NOT NULL,
PRIMARY KEY (user_email, listing_id),
CONSTRAINT fk_user_favorite FOREIGN KEY (user_email) REFERENCES USER (email),
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 {
private String category;
private Integer membercount;
private Integer memberCount;
private String name;
private String email;
private String owner;
private String ownerEmail;
private String description;
......@@ -45,12 +45,12 @@ public class Organization {
this.category = category;
}
public Integer getMembercount() {
return membercount;
public Integer getMemberCount() {
return memberCount;
}
public void setMembercount(Integer membercount) {
this.membercount = membercount;
public void setMemberCount(Integer membercount) {
this.memberCount = membercount;
}
public String getEmail() {
......@@ -77,12 +77,12 @@ public class Organization {
this.description = description;
}
public String getOwner() {
return owner;
public String getOwnerEmail() {
return ownerEmail;
}
public void setOwner(String owner) {
this.owner = owner;
public void setOwnerEmail(String ownerEmail) {
this.ownerEmail = ownerEmail;
}
@Id
......
......@@ -2,6 +2,6 @@
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/inventory
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.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