Compare commits
2 Commits
f6d4be1afb
...
8be7dbbe06
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8be7dbbe06 | ||
|
|
d4fad9f6c1 |
@@ -41,6 +41,10 @@ const initDB = async () => {
|
||||
|
||||
await pool.query(`ALTER TABLE orders ADD COLUMN IF NOT EXISTS pedido_id VARCHAR(100);`).catch(() => {});
|
||||
|
||||
await pool.query(`CREATE UNIQUE INDEX IF NOT EXISTS unique_order_product ON orders (pedido_id, produto_id);`).catch(err => {
|
||||
console.error("Notice: Could not create unique index (might already exist or there are duplicates):", err.message);
|
||||
});
|
||||
|
||||
console.log("Database initialized successfully.");
|
||||
} catch (err) {
|
||||
console.error("Failed to initialize database:", err);
|
||||
@@ -159,6 +163,11 @@ app.post('/api/data', authenticateAPIKey, async (req, res) => {
|
||||
})();
|
||||
});
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Nexstar Backend running at http://localhost:${PORT}`);
|
||||
console.log(`Endpoint for n8n: POST http://localhost:${PORT}/api/data`);
|
||||
});;
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Nexstar Backend running at http://localhost:${PORT}`);
|
||||
console.log(`Endpoint for n8n: POST http://localhost:${PORT}/api/data`);
|
||||
|
||||
@@ -113,22 +113,11 @@ const ClientDetails = () => {
|
||||
<Tag className="w-3 h-3 text-zinc-400 dark:text-dark-muted" />
|
||||
<span className="text-[10px] font-bold text-zinc-400 dark:text-dark-muted">ID: {order.ID_Produto}</span>
|
||||
</div>
|
||||
{order.Recebido_Em && (
|
||||
{order.Data_Pedido && (
|
||||
<div className="flex items-center gap-1 ml-2">
|
||||
<Clock className="w-3 h-3 text-zinc-400 dark:text-dark-muted" />
|
||||
<span className="text-[10px] font-bold text-zinc-400 dark:text-dark-muted">
|
||||
Recebido: {
|
||||
(() => {
|
||||
const d = new Date(order.Recebido_Em);
|
||||
const day = String(d.getDate()).padStart(2, '0');
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const year = d.getFullYear();
|
||||
const hours = String(d.getHours()).padStart(2, '0');
|
||||
const minutes = String(d.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(d.getSeconds()).padStart(2, '0');
|
||||
return `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
|
||||
})()
|
||||
}
|
||||
Comprado: {order.Data_Pedido}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user