Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a shit ton #41

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions backend/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def get_all_reservations():
try:
cursor = connection.cursor(dictionary=True)
cursor.execute("""
SELECT Reservations.ReservationID, Users.Username, Reservations.StartTime, Reservations.EndTime, Reservations.Seat
SELECT Reservations.ReservationID, Users.Username, Reservations.StartTime, Reservations.EndTime, Reservations.Seat, Reservations.TableFee, Reservations.ResDate
FROM Reservations
JOIN Users ON Reservations.UserID = Users.UserID
""")
Expand Down Expand Up @@ -239,16 +239,27 @@ def create_reservation(user_id, reservation_data):
try:
cursor = connection.cursor()
query = """
INSERT INTO Reservations (UserID, StartTime, EndTime, Seat)
VALUES (%s, %s, %s, %s)
INSERT INTO Reservations (UserID, StartTime, EndTime, Seat, TableFee, ResDate)
VALUES (%s, %s, %s, %s, %s)
"""
values = (user_id, reservation_data['starttime'], reservation_data['endtime'], reservation_data.get('seat'))
values = (
user_id,
reservation_data['starttime'],
reservation_data['endtime'],
reservation_data['seat'],
reservation_data['tablefee'],
reservation_data['resdate']
)
cursor.execute(query, values)
connection.commit()
cursor.close()
connection.close()
return {'message': 'Reservation created successfully'}
except mysql.connector.Error as err:
print(f"Error creating reservation: {err}")
connection.rollback()
return {'error': f"Error creating reservation: {err}"}


@app.route('/api/create-reservation', methods=['POST'])
def create_reservation_route():
Expand Down
10 changes: 6 additions & 4 deletions backend/db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ CREATE TABLE Users (
CREATE TABLE Reservations (
ReservationID INT AUTO_INCREMENT PRIMARY KEY,
UserID INT,
ResDate VARCHAR(225),
StartTime VARCHAR(255) NOT NULL,
EndTime VARCHAR(225) NOT NULL,
Seat VARCHAR(50),
TableFee DECIMAL(10,2) DEFAULT 0.00,
FOREIGN KEY (UserID) REFERENCES Users(UserID) ON DELETE CASCADE

);
Expand All @@ -49,8 +51,8 @@ VALUES

INSERT INTO Reservations (UserID, StartTime, EndTime, Seat)
VALUES
(1, '2023-01-01 08:00:00', '2023-01-01 12:00:00', 'A1'),
(2, '2023-01-02 09:00:00', '2023-01-02 13:00:00', 'B2'),
(1, '08:00:00', '12:00:00', 'chair1'),
(2, '09:00:00', '3:00:00', 'chair10'),

(3, '2023-01-03 10:00:00', '2023-01-03 14:00:00', 'C3'),
(4, '2023-01-04 11:00:00', '2023-01-04 15:00:00', 'D4');
(3, '2023-01-03 10:00:00', '2023-01-03 14:00:00', 'chair4'),
(4, '2023-01-04 11:00:00', '2023-01-04 15:00:00', 'chair5');
10 changes: 9 additions & 1 deletion frontend/app/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ function page() {
document.title = "Account";
}, []);

const handleLogout = () => {
// Clear user key from local storage
localStorage.removeItem("user");

// Redirect to home page
window.location.href = "/";
};

const parseJwt = (token: string) => {
try {
return JSON.parse(atob(token.split(".")[1]));
Expand Down Expand Up @@ -103,7 +111,7 @@ function page() {

<div className="mt-20"></div>

<Butt title="Log Out" Bgcolor="#FFF1E4" width="325px" height="34px" />
<Butt title="Log Out" Bgcolor="#FFF1E4" width="325px" height="34px" onClick={handleLogout} />
</div>
);
}
Expand Down
27 changes: 16 additions & 11 deletions frontend/app/admin_accounts/[userId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import TextInput from "@/app/components/text_input";
import Drop from "@/app/components/dropdown_button";
import Butt from "@/app/components/button";

import { useRouter } from "next/router";

function Page() {
const router = useRouter();

function Page() {

const handleBackButtonClick = () => {
router.back();
};
const userId = 1;
console.log("back button clicked")
}


const userId = localStorage.getItem('user_id')
console.log(userId)

const [formData, setFormData] = useState({
userName: "",
Expand All @@ -34,12 +36,15 @@ function Page() {
const response = await fetch(`http://localhost:5000/api/get-user/${userId}`);
if (response.ok) {
const userData = await response.json();
const datas = userData.user
console.log("User Data:", userData); // Log the received user data
console.log("User Data1:", datas); // Log the received user data
setFormData({
userName: userData.Username,
email: userData.Email,
phoneNumber: userData.PhoneNumber,
gender: userData.Gender,
occupation: userData.Occupation,
userName: datas.Username,
email: datas.Email,
phoneNumber: datas.PhoneNumber,
gender: datas.Gender,
occupation: datas.Occupation,
});
} else {
console.error("Error fetching user data:", await response.json());
Expand Down
187 changes: 103 additions & 84 deletions frontend/app/admin_areamap/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,30 @@ function Page() {
document.title = "Admin Area Map";
}, []);


const [isModalOpen, setModalOpen] = React.useState(false);

//now we need a function to handle the opening of the modal per chair... the funciton must contain a paramete that will be the chair id and the state of the chair if open or close

const handleChairClick = (chairId: string, isChairOpen: boolean) => {
console.log("chairId", chairId);
setModalOpen(!isModalOpen);
console.log("isChairOpen", isChairOpen);
// Toggle the modal state
if (isChairOpen) {
setModalOpen(true);
} else {
setModalOpen(false);
}
}

const handleModalOpen = () => {
setModalOpen(true);
};

const handleModalClose = () => {
setModalOpen(false);
};

const refreshPage = () => {
location.reload();
};
Expand Down Expand Up @@ -93,91 +107,96 @@ function Page() {
border: "2px solid #DC9D94",
}}
>

{/* now we need to refractor this modaladmin t only open if the parameter in the onlcick of the button is set to true */}

<ModalAdmin isOpen={isModalOpen} onClose={handleModalClose} />

<ChairRight
width="30px"
height="30px"
className="relative top-28 left-64"
onClick={handleModalOpen}
/>

<ChairRight
width="30px"
height="30px"
className="relative left-64 top-32"
onClick={handleModalOpen}
/>

<ChairLeft
width="30px"
height="30px"
className="relative bottom-5"
onClick={handleModalOpen}
/>

<ChairLeft
width="30px"
height="30px"
className="relative left-16 bottom-12"
onClick={handleModalOpen}
/>

<ChairLeft
width="30px"
height="30px"
className="relative left-10 bottom-2"
onClick={handleModalOpen}
/>

<ChairLeft
width="30px"
height="30px"
className="relative top-1 left-10"
onClick={handleModalOpen}
/>

<ChairUp
width="30px"
height="30px"
className="relative top-5 left-32"
onClick={handleModalOpen}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-44 bottom-2"
onClick={handleModalOpen}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-48 bottom-48"
onClick={handleModalOpen}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-64 bottom-56"
onClick={handleModalOpen}
/>

<ChairDown
width="30px"
height="30px"
className="relative left-32 bottom-44"
onClick={handleModalOpen}
/>

<ChairDown
width="30px"
height="30px"
className="relative left-44 bottom-52"
onClick={handleModalOpen}
/>

<ChairRight
width="30px"
height="30px"
className="relative top-28 left-64"
onClick={() => handleChairClick("chair1", true)}
/>

<ChairRight
width="30px"
height="30px"
className="relative left-64 top-32"
onClick={() => handleChairClick("chair2", true)}
/>

<ChairLeft
width="30px"
height="30px"
className="relative bottom-5"
onClick={() => handleChairClick("chair3", true)}
/>

<ChairLeft
width="30px"
height="30px"
className="relative left-16 bottom-12"
onClick={() => handleChairClick("chair4", true)}
/>

<ChairLeft
width="30px"
height="30px"
className="relative left-10 bottom-2"
onClick={() => handleChairClick("chair5", true)}
/>

<ChairLeft
width="30px"
height="30px"
className="relative top-1 left-10"
onClick={() => handleChairClick("chair6", true)}
/>

<ChairUp
width="30px"
height="30px"
className="relative top-5 left-32"
onClick={() => handleChairClick("chair7", true)}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-44 bottom-2"
onClick={() => handleChairClick("chair8", true)}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-48 bottom-48"
onClick={() => handleChairClick("chair9", true)}
/>

<ChairUp
width="30px"
height="30px"
className="relative left-64 bottom-56"
onClick={() => handleChairClick("chair10", true)}
/>

<ChairDown
width="30px"
height="30px"
className="relative left-32 bottom-44"
onClick={() => handleChairClick("chair11", true)}
/>

<ChairDown
width="30px"
height="30px"
className="relative left-44 bottom-52"
onClick={() => handleChairClick("chair12", true)}
/>

</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions frontend/app/components/data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface Reservation {
StartTime: string;
EndTime: string;
Username: string;
Price: number;
ResDate: string;
}

const columns: GridColDef[] = [
Expand All @@ -17,6 +19,8 @@ const columns: GridColDef[] = [
{ field: "Username", headerName: "Username", width: 150 },
{ field: "StartTime", headerName: "Start Time", width: 200 },
{ field: "EndTime", headerName: "End Time", width: 200 },
{ field: "ResDate", headerName: "Date", width: 150},
{ field: "Price", headerName: "Price", width: 150 },
];

export default function DataGridDemo() {
Expand Down
Loading
Loading