wrapped up most of the application stuff for now (pending database integration)

This commit is contained in:
2025-08-17 17:11:55 -04:00
parent 7913b45629
commit fe12c820ee
4 changed files with 123 additions and 61 deletions

55
ui/src/api/application.ts Normal file
View File

@@ -0,0 +1,55 @@
export type ApplicationDto = Partial<{
age: number | string
name: string
playtime: number | string
hobbies: string
military: boolean
communities: string
joinReason: string
milsimAttraction: string
referral: string
steamProfile: string
timezone: string
canAttendSaturday: boolean
interests: string
aknowledgeRules: boolean
}>
type ApplicationFull = Partial<{
app: ApplicationDto,
messages: object[]
}>
const addr = "localhost:3000"
export async function loadApplication(): Promise<ApplicationFull | null> {
const res = await fetch(`http://${addr}/me/application`)
if (res.status === 204) return null
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 postApplication(val: any) {
await fetch(`http://${addr}/application`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(val),
})
}
export async function postChatMessage(val: any) {
let output = {
message: val,
sender: 1,
timestamp: Date.now(),
}
await fetch(`http://${addr}/application/message`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(output),
})
}