diff --git a/api/index.js b/api/index.js index 60b656e..d09027a 100644 --- a/api/index.js +++ b/api/index.js @@ -68,6 +68,7 @@ app.get('/application/:id', async (req, res) => { let appID = req.params.id; //TODO: Replace with real user Authorization and whatnot + // if the application is not "me" and I am not a recruiter, deny access to the application (return 403 or whatever) if (appID === "me") appID = 2; diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index 9b1c50d..31fb3e2 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -69,11 +69,11 @@ export enum Status { Accepted = "Accepted", Denied = "Denied", } - + const addr = "localhost:3000" -export async function loadApplication(): Promise { - const res = await fetch(`http://${addr}/application/me`) +export async function loadApplication(id: number | string): Promise { + const res = await fetch(`http://${addr}/application/${id}`) if (res.status === 204) return null if (!res.ok) throw new Error('Failed to load application') const json = await res.json() diff --git a/ui/src/pages/Application.vue b/ui/src/pages/Application.vue index b94b2d3..8c2738d 100644 --- a/ui/src/pages/Application.vue +++ b/ui/src/pages/Application.vue @@ -3,6 +3,7 @@ import ApplicationChat from '@/components/application/ApplicationChat.vue'; import ApplicationForm from '@/components/application/ApplicationForm.vue'; import { onMounted, ref } from 'vue'; import { ApplicationData, loadApplication, postApplication, postChatMessage, Status } from '@/api/application'; +import { useRoute } from 'vue-router'; const appData = ref(null); const appID = ref(null); @@ -16,7 +17,10 @@ const loading = ref(true); const member_name = ref(); onMounted(async () => { try { - const raw = await loadApplication() + //get app ID from URL param + const router = useRoute(); + const appIDRaw = router.params.id.toString(); + const raw = await loadApplication(appIDRaw); if (raw === null) { //new app appData.value = null diff --git a/ui/src/pages/ManageApplications.vue b/ui/src/pages/ManageApplications.vue index 0e71aee..b01c77e 100644 --- a/ui/src/pages/ManageApplications.vue +++ b/ui/src/pages/ManageApplications.vue @@ -58,8 +58,9 @@ async function handleDeny(id) { appList.value = await getAllApplications(); } +const router = useRouter(); function openApplication(id) { - useRouter().push('/hi') + router.push(`/applications/${id}`) } onMounted(async () => { diff --git a/ui/src/router/index.js b/ui/src/router/index.js index 752cf35..169bbbe 100644 --- a/ui/src/router/index.js +++ b/ui/src/router/index.js @@ -1,9 +1,14 @@ import { createRouter, createWebHistory } from 'vue-router' +import ManageApplications from '@/pages/ManageApplications.vue' +import Application from '@/pages/Application.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ - ], + { path: '/applications', component: ManageApplications }, + { path: '/applications/:id', component: Application }, + ] + }) export default router