improved recruiter controls for applications
This commit is contained in:
69
api/index.js
69
api/index.js
@@ -25,7 +25,7 @@ app.post('/application', async (req, res) => {
|
||||
if (!app) return res.status(400).json({ error: 'Missing App payload' });
|
||||
|
||||
// TODO: replace with current user ID
|
||||
const memberId = 2;
|
||||
const memberId = 1;
|
||||
|
||||
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
||||
const appVersion = 1;
|
||||
@@ -43,38 +43,33 @@ app.post('/application', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/application/all', async (req, res) => {
|
||||
try {
|
||||
const sql = `SELECT
|
||||
member.name AS member_name,
|
||||
app.id,
|
||||
app.member_id,
|
||||
app.submitted_at,
|
||||
app.app_status
|
||||
FROM applications AS app
|
||||
LEFT JOIN members AS member
|
||||
ON member.id = app.member_id;`
|
||||
|
||||
// app.get('/application/me', async (req, res) => {
|
||||
// try {
|
||||
// // TODO: replace with current user ID
|
||||
// const applicationId = 1;
|
||||
const rows = await pool.query(sql);
|
||||
|
||||
// const rows = await pool.query(
|
||||
// `SELECT app.*,
|
||||
// member.name AS member_name
|
||||
// FROM applications AS app
|
||||
// INNER JOIN members AS member ON member.id = app.member_id
|
||||
// WHERE app.member_id = ?;`,
|
||||
// [applicationId]
|
||||
// );
|
||||
|
||||
// if (!Array.isArray(rows) || rows.length === 0) {
|
||||
// return res.sendStatus(204);
|
||||
// }
|
||||
|
||||
// return res.status(200).json(rows[0]);
|
||||
// } catch (err) {
|
||||
// console.error('Query failed:', err);
|
||||
// return res.status(500).json({ error: 'Failed to load application' });
|
||||
// }
|
||||
// });
|
||||
res.status(200).json(rows);
|
||||
} catch {
|
||||
console.error(err);
|
||||
res.status(500);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/application/:id', async (req, res) => {
|
||||
let appID = req.params.id;
|
||||
|
||||
//TODO: Replace with real user Authorization and whatnot
|
||||
if (appID === "me")
|
||||
appID = 1;
|
||||
appID = 2;
|
||||
|
||||
try {
|
||||
const conn = await pool.getConnection()
|
||||
@@ -84,7 +79,7 @@ app.get('/application/:id', async (req, res) => {
|
||||
member.name AS member_name
|
||||
FROM applications AS app
|
||||
INNER JOIN members AS member ON member.id = app.member_id
|
||||
WHERE app.id = 1;`,
|
||||
WHERE app.id = ?;`,
|
||||
[appID]
|
||||
);
|
||||
|
||||
@@ -118,28 +113,6 @@ app.get('/application/:id', async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
app.get('/application/all', async (req, res) => {
|
||||
try {
|
||||
|
||||
const sql = `SELECT
|
||||
member.name AS member_name,
|
||||
app.id,
|
||||
app.member_id,
|
||||
app.submitted_at,
|
||||
app.app_status
|
||||
FROM applications AS app
|
||||
LEFT JOIN members AS member
|
||||
ON member.id = app.member_id;`
|
||||
|
||||
const rows = await pool.query(sql);
|
||||
|
||||
res.status(200).json(rows);
|
||||
} catch {
|
||||
console.error(err);
|
||||
res.status(500);
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/application/approve/:id', async (req, res) => {
|
||||
const appID = req.params.id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user