finished(?) hooking up rank system
This commit is contained in:
@@ -7,24 +7,19 @@ const pool = require('../db');
|
||||
//insert a new latest rank for a user
|
||||
ur.post('/', async (req, res) => {
|
||||
try {
|
||||
const App = req.body?.App || {};
|
||||
const change = req.body?.change;
|
||||
console.log(change);
|
||||
|
||||
// TODO: replace with current user ID
|
||||
const memberId = 1;
|
||||
const sql = `INSERT INTO members_ranks (member_id, rank_id, event_date) VALUES (?, ?, ?);`;
|
||||
|
||||
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
||||
const appVersion = 1;
|
||||
|
||||
const params = [memberId, appVersion, JSON.stringify(App)]
|
||||
|
||||
console.log(params)
|
||||
const params = [change.member_id, change.rank_id, change.event_date]
|
||||
|
||||
await pool.query(sql, params);
|
||||
|
||||
res.sendStatus(201);
|
||||
} catch (err) {
|
||||
console.error('Insert failed:', err);
|
||||
res.status(500).json({ error: 'Failed to save application' });
|
||||
res.status(500).json({ error: 'Failed to update ranks' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user