From caa6ffd41a7c97033f5169d78231362d7cd04486 Mon Sep 17 00:00:00 2001 From: ajdj100 Date: Tue, 2 Sep 2025 12:11:58 -0400 Subject: [PATCH] improved recruiter controls for applications --- api/index.js | 69 +++++++++-------------------- ui/src/App.vue | 3 +- ui/src/api/application.ts | 3 +- ui/src/pages/Application.vue | 14 +++++- ui/src/pages/ManageApplications.vue | 23 ++++++---- 5 files changed, 52 insertions(+), 60 deletions(-) diff --git a/api/index.js b/api/index.js index cbb0307..60b656e 100644 --- a/api/index.js +++ b/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; diff --git a/ui/src/App.vue b/ui/src/App.vue index 178e2e0..736b1e4 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -16,9 +16,10 @@ import ManageApplications from './pages/ManageApplications.vue'; - + + diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index ea920aa..9b1c50d 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -86,11 +86,12 @@ export async function postApplication(val: any) { let out = { "App": val, } - await fetch(`http://${addr}/application`, { + const res = await fetch(`http://${addr}/application`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(out), }) + return res; } export async function postChatMessage(message: any, post_id: number) { diff --git a/ui/src/pages/Application.vue b/ui/src/pages/Application.vue index 66bd46f..b94b2d3 100644 --- a/ui/src/pages/Application.vue +++ b/ui/src/pages/Application.vue @@ -46,6 +46,15 @@ async function postComment(comment) { chatData.value.push(await postChatMessage(comment, appID.value)); } +async function postApp(appData) { + const res = await postApplication(appData); + if (res.ok) { + readOnly.value = true; + newApp.value = false; + } + // TODO: Handle fail to post +} + \ No newline at end of file diff --git a/ui/src/pages/ManageApplications.vue b/ui/src/pages/ManageApplications.vue index 45fa535..0e71aee 100644 --- a/ui/src/pages/ManageApplications.vue +++ b/ui/src/pages/ManageApplications.vue @@ -11,6 +11,7 @@ import { } from '@/components/ui/table' import Button from '@/components/ui/button/Button.vue'; import { onMounted, ref } from 'vue'; +import { useRouter } from 'vue-router'; const appList = ref([]); const now = Date.now(); @@ -57,6 +58,9 @@ async function handleDeny(id) { appList.value = await getAllApplications(); } +function openApplication(id) { + useRouter().push('/hi') +} onMounted(async () => { appList.value = await getAllApplications(); @@ -69,25 +73,28 @@ onMounted(async () => { User Date Submitted + Status - + {{ app.member_name }} {{ formatAgo(app.submitted_at) }} - + + + + + {{ app.app_status }} - - - -