set up viewing of users application history
Some checks failed
Continuous Deployment / Update Deployment (push) Failing after 1m22s
Some checks failed
Continuous Deployment / Update Deployment (push) Failing after 1m22s
This commit is contained in:
@@ -122,6 +122,26 @@ export async function getAllApplications(): Promise<ApplicationFull> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadMyApplications(): Promise<ApplicationFull> {
|
||||
const res = await fetch(`${addr}/application/meList`, { credentials: 'include' })
|
||||
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
} else {
|
||||
console.error("Something went wrong approving the application")
|
||||
}
|
||||
}
|
||||
|
||||
export async function getMyApplication(id: number): Promise<ApplicationFull> {
|
||||
const res = await fetch(`${addr}/application/me/${id}`, { credentials: 'include' })
|
||||
if (res.status === 204) return null
|
||||
if (res.status === 403) throw new Error("Unauthorized");
|
||||
if (!res.ok) throw new Error('Failed to load application')
|
||||
const json = await res.json()
|
||||
// Accept either the object at root or under `application`
|
||||
return json;
|
||||
}
|
||||
|
||||
export async function approveApplication(id: Number) {
|
||||
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST' })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user