Skip to content

Commit fcf1dec

Browse files
committed
fix: reservations
1 parent dc5e603 commit fcf1dec

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

backend/app/app.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ def perform_warehouse_process():
211211
# Add the scheduled job to run the ETL process every 168 hours or 1 week
212212
scheduler.add_job(perform_warehouse_process, 'interval', hours=168)
213213

214+
def create_reservation(user_id, reservation_data):
215+
connection = get_db_connection(db_config)
216+
if connection:
217+
try:
218+
cursor = connection.cursor()
219+
query = """
220+
INSERT INTO Reservations (UserID, StartTime, EndTime, Seat)
221+
VALUES (%s, %s, %s, %s)
222+
"""
223+
values = (user_id, reservation_data['starttime'], reservation_data['endtime'], reservation_data.get('seat'))
224+
cursor.execute(query, values)
225+
connection.commit()
226+
cursor.close()
227+
connection.close()
228+
except mysql.connector.Error as err:
229+
print(f"Error creating reservation: {err}")
230+
231+
@app.route('/api/create-reservation', methods=['POST'])
232+
def create_reservation_route():
233+
try:
234+
data = request.get_json()
235+
user_id = data.get('user_id') # Change this to fetch the user_id from your authentication mechanism
236+
create_reservation(user_id, data)
237+
return jsonify({'message': 'Reservation created successfully'}), 200
238+
except Exception as e:
239+
print(f"Error creating reservation: {e}")
240+
return jsonify(message='Error creating reservation'), 500
241+
214242
@app.route('/api/create-account', methods=['POST'])
215243
def create_account():
216244
try:

frontend/app/admin_accounts/page.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ function Page() {
5555
setFilteredData(filteredResults);
5656
};
5757
console.log(filteredData);
58-
const handleEditClick = (userId: number) => {
59-
// Navigate to the [id] folder
60-
router.push(`/${userId}`);
61-
};
6258

6359
return (
6460
<div className="flex min-h-full flex-col bg-backcolor">

frontend/app/components/modal.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function BasicModal({ isOpen, onClose }: BasicModalProps) {
3232
const router = useRouter();
3333

3434
const [formData, setFormData] = useState<{
35-
Date: string | any ;
35+
Date: string | any;
3636
StartTime: string | any;
3737
EndTime: string | any;
3838
}>({
@@ -50,11 +50,6 @@ function BasicModal({ isOpen, onClose }: BasicModalProps) {
5050
const redirectUrl = "http://localhost:3000/qr_success_reservation"; //change this to a page after ng payment so magamit yung handleCreateAccount function. Dun pa dapat ma-ce-create yung reservation
5151
const getName = "Gian"; //change get the name of user from session or local storage kung san man naka store
5252
const tableFee = 140; //change den sa calculation
53-
const proceedPayment = () => {
54-
router.push(
55-
`https://payment-gateway-weld.vercel.app/gcash/login?amountDue=${tableFee}&merchant=Brew and Brains&redirectUrl=${redirectUrl}`
56-
);
57-
};
5853

5954
const handleCreateAccount = async () => {
6055
try {
@@ -64,7 +59,9 @@ function BasicModal({ isOpen, onClose }: BasicModalProps) {
6459
starttime: formData.StartTime,
6560
endtime: formData.EndTime,
6661
};
67-
console.log(apiData)
62+
router.push(
63+
`https://payment-gateway-weld.vercel.app/gcash/login?amountDue=${tableFee}&merchant=Brew and Brains&redirectUrl=${redirectUrl}`
64+
);
6865

6966
const response = await fetch(
7067
"http://localhost:5000/api/create-reservation",
@@ -127,7 +124,7 @@ function BasicModal({ isOpen, onClose }: BasicModalProps) {
127124
</div>
128125

129126
<Butt
130-
onClick={proceedPayment}
127+
onClick={handleCreateAccount}
131128
title="Reserve"
132129
Bgcolor="#EBE0D0"
133130
width="325px"

0 commit comments

Comments
 (0)