finished(?) hooking up rank system

This commit is contained in:
2025-09-20 10:09:14 -04:00
parent 799b4f4960
commit 659ce6eed7
4 changed files with 59 additions and 17 deletions

View File

@@ -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' });
}
});