Skip to content

Commit 29d78b2

Browse files
authored
Merge branch 'master' into Ben
2 parents 49024e6 + 5c42226 commit 29d78b2

File tree

15 files changed

+182
-145
lines changed

15 files changed

+182
-145
lines changed

backend/app/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,4 +638,4 @@ def index():
638638

639639
if __name__ == '__main__':
640640
scheduler.start()
641-
app.run(host='0.0.0.0', debug=True)
641+
app.run(host='0.0.0.0', debug=True)

frontend/app/(site)/page.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Butt from "../components/button";
88
import Link from "next/link";
99
import { useRouter } from "next/navigation";
1010

11-
1211
// export const metadata: Metadata = {
1312
// title: "Brew & Brain",
1413
// description: "Brew * Brain",
@@ -85,12 +84,9 @@ export default function Home() {
8584
<section>
8685
<About />
8786
</section>
88-
<section>
89-
<Discounts />
90-
</section>
91-
<footer>
87+
{/* <footer>
9288
<Footer />
93-
</footer>
89+
</footer> */}
9490
</div>
9591
);
9692
}

frontend/app/account/page.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import TemporaryDrawer from "../components/side_bar";
1414
function page() {
1515
const [username, setUsername] = useState("");
1616
useEffect(() => {
17-
const accessToken = localStorage.getItem('user');
18-
setUsername(accessToken ? JSON.parse(accessToken).Username : "")
17+
const accessToken = localStorage.getItem("user");
18+
setUsername(accessToken ? JSON.parse(accessToken).Username : "");
1919
document.title = "Account";
2020
}, []);
2121

@@ -61,16 +61,6 @@ function page() {
6161
</Link>
6262
<Line></Line>
6363
</div>
64-
65-
<div className="text-sm mt-4">
66-
<Link href="#">
67-
<Dropdown
68-
title="Rewards"
69-
LeftArrow={<KeyboardArrowRightIcon style={{ fontSize: 23 }} />}
70-
/>
71-
</Link>
72-
<Line></Line>
73-
</div>
7464
</div>
7565

7666
<div className="mt-7">
@@ -97,21 +87,17 @@ function page() {
9787
</Link>
9888
<Line></Line>
9989
</div>
100-
101-
<div className="text-sm mt-4">
102-
<Link href="#">
103-
<Dropdown
104-
title="Notifications"
105-
LeftArrow={<KeyboardArrowRightIcon style={{ fontSize: 23 }} />}
106-
/>
107-
</Link>
108-
<Line></Line>
109-
</div>
11090
</div>
11191

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

114-
<Butt title="Log Out" Bgcolor="#FFF1E4" width="325px" height="34px" onClick={handleLogout} />
94+
<Butt
95+
title="Log Out"
96+
Bgcolor="#FFF1E4"
97+
width="325px"
98+
height="34px"
99+
onClick={handleLogout}
100+
/>
115101
</div>
116102
);
117103
}

frontend/app/admin_accounts/[userId]/page.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use client';
1+
"use client";
22
import React, { useState, useEffect } from "react";
33
import Teste from "@/app/components/account";
44
import CloseIcon from "@mui/icons-material/Close";
@@ -7,18 +7,15 @@ import CircleIcon from "@mui/icons-material/Circle";
77
import TextInput from "@/app/components/text_input";
88
import Drop from "@/app/components/dropdown_button";
99
import Butt from "@/app/components/button";
10-
11-
10+
import Link from "next/link";
1211

1312
function Page() {
14-
1513
const handleBackButtonClick = () => {
16-
console.log("back button clicked")
17-
}
14+
console.log("back button clicked");
15+
};
1816

19-
20-
const userId = localStorage.getItem('user_id')
21-
console.log(userId)
17+
const userId = localStorage.getItem("user_id");
18+
console.log(userId);
2219

2320
const [formData, setFormData] = useState({
2421
userName: "",
@@ -33,10 +30,12 @@ function Page() {
3330

3431
const fetchUserData = async () => {
3532
try {
36-
const response = await fetch(`http://localhost:5000/api/get-user/${userId}`);
33+
const response = await fetch(
34+
`http://localhost:5000/api/get-user/${userId}`
35+
);
3736
if (response.ok) {
3837
const userData = await response.json();
39-
const datas = userData.user
38+
const datas = userData.user;
4039
console.log("User Data:", userData); // Log the received user data
4140
console.log("User Data1:", datas); // Log the received user data
4241
setFormData({
@@ -83,6 +82,7 @@ function Page() {
8382
if (response.ok) {
8483
const updatedUserData = await response.json();
8584
console.log("Profile updated successfully:", updatedUserData);
85+
alert("Customer's profile updated.");
8686
} else {
8787
console.error("Error updating profile:", await response.json());
8888
}
@@ -163,13 +163,15 @@ function Page() {
163163

164164
<div className="mt-16"></div>
165165

166-
<Butt
167-
title="Update Profile"
168-
Bgcolor="#FFF1E4"
169-
width="325px"
170-
height="34px"
171-
onClick={handleUpdateProfile}
172-
/>
166+
<Link href="/admin_accounts">
167+
<Butt
168+
title="Update Profile"
169+
Bgcolor="#FFF1E4"
170+
width="325px"
171+
height="34px"
172+
onClick={handleUpdateProfile}
173+
/>
174+
</Link>
173175
</div>
174176
);
175177
}

frontend/app/admin_accounts/page.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ function Page() {
8181
</div>
8282

8383
<div className="container flex items-center justify-center space-x-5 text-xs text-black font-bold mt-2">
84-
<Link href="/admin_dashboard">
85-
<p>Dashboard</p>
86-
</Link>
8784
<Link href="/admin_areamap">
8885
<p>Area Map</p>
8986
</Link>
@@ -95,7 +92,6 @@ function Page() {
9592
</div>
9693

9794
<div className="container flex items-center justify-center space-x-8 text-xs text-black font-bold mb-2">
98-
<p className="text-backcolor">_________</p>
9995
<p className="text-backcolor">________</p>
10096
<p className="text-backcolor">____________</p>
10197
<p className="text-amber-500">____________</p>

frontend/app/admin_areamap/page.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function Page() {
4343

4444
}, []);
4545

46-
4746
const [isModalOpen, setModalOpen] = React.useState(false);
4847
const [chairId, setChairId] = React.useState<string | null>(null);
4948
const [ reservationData, setReservationData] = React.useState<any>(null);
@@ -70,16 +69,18 @@ function Page() {
7069
setModalOpen(!isModalOpen);
7170
console.log("isChairOpen", isChairOpen);
7271

72+
7373
await fetchReservation(chairId);
7474
console.log("reservationData", reservationData)
7575
// Toggle the modal state
7676
if (isChairOpen) {
77+
7778
setModalOpen(true);
7879
} else {
7980
setModalOpen(false);
8081
}
81-
}
82-
82+
};
83+
8384
const handleModalOpen = () => {
8485
setModalOpen(true);
8586
};
@@ -117,9 +118,6 @@ function Page() {
117118
</div>
118119

119120
<div className="container flex items-center justify-center space-x-5 text-xs text-black font-bold mt-2">
120-
<Link href="/admin_dashboard">
121-
<p>Dashboard</p>
122-
</Link>
123121
<Link href="/admin_areamap">
124122
<p className="text-amber-500">Area Map</p>
125123
</Link>
@@ -132,7 +130,6 @@ function Page() {
132130
</div>
133131

134132
<div className="container flex items-center justify-center space-x-8 text-xs text-black font-bold mb-2">
135-
<p className="text-backcolor">_________</p>
136133
<p className="text-amber-500">________</p>
137134
<p className="text-backcolor">____________</p>
138135
<p className="text-backcolor">____________</p>
@@ -151,8 +148,8 @@ function Page() {
151148
border: "2px solid #DC9D94",
152149
}}
153150
>
154-
155151
{/* now we need to refractor this modaladmin t only open if the parameter in the onlcick of the button is set to true */}
152+
156153

157154
<ModalAdmin isOpen={isModalOpen} onClose={handleModalClose} reservationData={reservationData}/>
158155
<ChairRight
@@ -238,6 +235,7 @@ function Page() {
238235
className="relative left-44 bottom-52"
239236
onClick={() => handleChairClick("chair12", true)}
240237
/>
238+
241239
</div>
242240
</div>
243241

frontend/app/admin_sales/page.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ function Page() {
3939
</div>
4040

4141
<div className="container flex items-center justify-center space-x-5 text-xs text-black font-bold mt-2">
42-
<Link href="/admin_dashboard">
43-
<p>Dashboard</p>
44-
</Link>
4542
<Link href="/admin_areamap">
4643
<p>Area Map</p>
4744
</Link>
@@ -54,7 +51,6 @@ function Page() {
5451
</div>
5552

5653
<div className="container flex items-center justify-center space-x-8 text-xs text-black font-bold mb-2">
57-
<p className="text-backcolor">_________</p>
5854
<p className="text-backcolor">________</p>
5955
<p className="text-amber-500">____________</p>
6056
<p className="text-backcolor">____________</p>
@@ -64,7 +60,7 @@ function Page() {
6460
<DataGridDemo></DataGridDemo>
6561
</div>
6662

67-
<div className="container flex space-x-5 justify-center items-center">
63+
{/* <div className="container flex space-x-5 justify-center items-center">
6864
<Butt
6965
title="Generate Report"
7066
Bgcolor="#F8D8D4"
@@ -77,7 +73,7 @@ function Page() {
7773
width="150px"
7874
height="33px"
7975
></Butt>
80-
</div>
76+
</div> */}
8177
</div>
8278
);
8379
}

frontend/app/components/data_grid.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Reservation {
99
StartTime: string;
1010
EndTime: string;
1111
Username: string;
12-
Price: number;
12+
TableFee: number;
1313
ResDate: string;
1414
}
1515

@@ -19,7 +19,9 @@ const columns: GridColDef[] = [
1919
{ field: "Username", headerName: "Username", width: 150 },
2020
{ field: "StartTime", headerName: "Start Time", width: 200 },
2121
{ field: "EndTime", headerName: "End Time", width: 200 },
22+
2223
{ field: "ResDate", headerName: "Date", width: 150},
24+
2325
{ field: "TableFee", headerName: "Price", width: 150 },
2426
];
2527

frontend/app/components/modal.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,22 @@ const style = {
2828
p: 4,
2929
};
3030

31-
const BasicModal: React.FC<BasicModalProps> = ({ isOpen, onClose, chairId }) => {
31+
const BasicModal: React.FC<BasicModalProps> = ({
32+
isOpen,
33+
onClose,
34+
chairId,
35+
}) => {
3236
const [formData, setFormData] = useState({
3337
Date: null as Date | null,
3438
StartTime: null as string | null,
3539
EndTime: null as string | null,
3640
});
3741
const router = useRouter();
3842

39-
const handleInputChange = (field: keyof typeof formData, value: Date | string | null) => {
43+
const handleInputChange = (
44+
field: keyof typeof formData,
45+
value: Date | string | null
46+
) => {
4047
setFormData((prevFormData) => ({
4148
...prevFormData,
4249
[field]: value,
@@ -48,7 +55,7 @@ const BasicModal: React.FC<BasicModalProps> = ({ isOpen, onClose, chairId }) =>
4855

4956
const handleCreateReservation = async () => {
5057
try {
51-
const storedUserData = localStorage.getItem('user');
58+
const storedUserData = localStorage.getItem("user");
5259
const parsedUserData = storedUserData ? JSON.parse(storedUserData) : null;
5360
const initialFormData = parsedUserData?.updated_user || null;
5461
let userID = initialFormData ? initialFormData.UserID : "";
@@ -58,21 +65,27 @@ const BasicModal: React.FC<BasicModalProps> = ({ isOpen, onClose, chairId }) =>
5865

5966
const startMoment = moment(formData.StartTime, "HH:mm");
6067
const endMoment = moment(formData.EndTime, "HH:mm");
61-
const durationInHours = moment.duration(endMoment.diff(startMoment)).asHours();
68+
const durationInHours = moment
69+
.duration(endMoment.diff(startMoment))
70+
.asHours();
6271
const tableFee = Math.ceil(durationInHours) * baseTableFee;
6372

6473
const apiData = {
6574
seat: chairId,
66-
resdate: formData.Date ? moment(formData.Date).format("YYYY-MM-DD") : null,
75+
resdate: formData.Date
76+
? moment(formData.Date).format("YYYY-MM-DD")
77+
: null,
6778
starttime: formData.StartTime,
6879
endtime: formData.EndTime,
6980
user_id: userID,
7081
tablefee: tableFee,
7182
};
83+
7284
console.log(apiData)
7385
console.log(tableFee)
7486

7587

88+
7689
const response = await fetch(
7790
"http://localhost:5000/api/create-reservation",
7891
{

0 commit comments

Comments
 (0)