Did a whole ton of stuff, notably cloudflare tunnel hosting
This commit is contained in:
@@ -69,11 +69,11 @@ export enum Status {
|
||||
Accepted = "Accepted",
|
||||
Denied = "Denied",
|
||||
}
|
||||
|
||||
const addr = "localhost:3000"
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function loadApplication(id: number | string): Promise<ApplicationFull | null> {
|
||||
const res = await fetch(`http://${addr}/application/${id}`)
|
||||
const res = await fetch(`${addr}/application/${id}`)
|
||||
if (res.status === 204) return null
|
||||
if (!res.ok) throw new Error('Failed to load application')
|
||||
const json = await res.json()
|
||||
@@ -86,7 +86,7 @@ export async function postApplication(val: any) {
|
||||
let out = {
|
||||
"App": val,
|
||||
}
|
||||
const res = await fetch(`http://${addr}/application`, {
|
||||
const res = await fetch(`${addr}/application`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(out),
|
||||
@@ -100,7 +100,7 @@ export async function postChatMessage(message: any, post_id: number) {
|
||||
message: message
|
||||
}
|
||||
|
||||
const response = await fetch(`http://${addr}/application/${post_id}/comment`, {
|
||||
const response = await fetch(`${addr}/application/${post_id}/comment`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(out),
|
||||
@@ -110,7 +110,7 @@ export async function postChatMessage(message: any, post_id: number) {
|
||||
}
|
||||
|
||||
export async function getAllApplications() {
|
||||
const res = await fetch(`http://${addr}/application/all`)
|
||||
const res = await fetch(`${addr}/application/all`)
|
||||
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
@@ -120,7 +120,7 @@ export async function getAllApplications() {
|
||||
}
|
||||
|
||||
export async function approveApplication(id: Number) {
|
||||
const res = await fetch(`http://${addr}/application/approve/${id}`, { method: 'POST' })
|
||||
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST' })
|
||||
|
||||
if (!res.ok) {
|
||||
console.error("Something went wrong approving the application")
|
||||
@@ -128,9 +128,9 @@ export async function approveApplication(id: Number) {
|
||||
}
|
||||
|
||||
export async function denyApplication(id: Number) {
|
||||
const res = await fetch(`http://${addr}/application/deny/${id}`, { method: 'POST' })
|
||||
const res = await fetch(`${addr}/application/deny/${id}`, { method: 'POST' })
|
||||
|
||||
if (!res.ok) {
|
||||
console.error("Something went wrong approving the application")
|
||||
console.error("Something went wrong denying the application")
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ export type LOARequest = {
|
||||
end_date: string; // ISO 8601 string
|
||||
reason?: string;
|
||||
};
|
||||
|
||||
const addr = "localhost:3000";
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function submitLOA(request: LOARequest): Promise<{ id?: number; error?: string }> {
|
||||
const res = await fetch(`http://${addr}/loa`, {
|
||||
const res = await fetch(`${addr}/loa`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -25,7 +25,7 @@ export async function submitLOA(request: LOARequest): Promise<{ id?: number; err
|
||||
}
|
||||
|
||||
export async function getMyLOA(): Promise<LOARequest | null> {
|
||||
const res = await fetch(`http://${addr}/loa/me`, {
|
||||
const res = await fetch(`${addr}/loa/me`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -7,11 +7,11 @@ export type Member = {
|
||||
status_date: string | null;
|
||||
};
|
||||
|
||||
|
||||
const addr = "localhost:3000"
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function getMembers(): Promise<Member[]> {
|
||||
const response = await fetch(`http://${addr}/members`);
|
||||
const response = await fetch(`${addr}/members`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch members");
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ export type Rank = {
|
||||
sortOrder: number
|
||||
}
|
||||
|
||||
const addr = "localhost:3000"
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
|
||||
// Placeholder: fetch list of ranks
|
||||
export async function getRanks(): Promise<Rank[]> {
|
||||
const res = await fetch(`http://${addr}/ranks`)
|
||||
const res = await fetch(`${addr}/ranks`)
|
||||
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
@@ -22,7 +21,7 @@ export async function getRanks(): Promise<Rank[]> {
|
||||
|
||||
// Placeholder: submit a rank change
|
||||
export async function submitRankChange(memberId: number, rankId: number): Promise<{ ok: boolean }> {
|
||||
const res = await fetch(`http://${addr}/rank`, {
|
||||
const res = await fetch(`${addr}/rank`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
Reference in New Issue
Block a user