Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 250f4ed6 authored by 65160381's avatar 65160381
Browse files

10.1

parent 7b2f9201
No related branches found
No related tags found
No related merge requests found
Pipeline #630 passed with warnings
......@@ -53,6 +53,10 @@ pool.getConnection()
// Static file serving
app.use(express.static(path.join(__dirname, 'public')));
app.get('/edit-order', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'edit-order.html'));
});
// Session และ routes
app.get('/', (req, res) => {
if (req.session.user) {
......
......@@ -26,7 +26,15 @@
// Load order details from the API
async function loadOrderDetails() {
try {
const orderId = 1; // Replace with dynamic order ID
// Get orderId from the URL query string
const urlParams = new URLSearchParams(window.location.search);
const orderId = urlParams.get('orderId'); // Get orderId from URL parameter
if (!orderId) {
alert('Order ID is missing in the URL');
return;
}
const response = await fetch(`/api/orders/${orderId}`);
const order = await response.json();
......@@ -61,7 +69,15 @@
// Update order details
async function updateOrder() {
const orderId = 1; // Replace with dynamic order ID
// Get orderId from the URL query string
const urlParams = new URLSearchParams(window.location.search);
const orderId = urlParams.get('orderId');
if (!orderId) {
alert('Order ID is missing in the URL');
return;
}
const status = document.getElementById('order-status').value;
const shippingAddress = document.getElementById('order-shipping-address').value;
......@@ -79,7 +95,7 @@
if (response.ok) {
alert('Order updated successfully!');
window.location.href = '/'; // Redirect to home page or orders page
window.location.href = '/orders'; // Redirect to orders page or home page
} else {
const errorMessage = await response.text();
alert('Error updating order: ' + errorMessage);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment