Supported public vs internal application comments, and moved some type dependencies to the shared lib
This commit is contained in:
@@ -1,80 +1,11 @@
|
||||
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
|
||||
}>
|
||||
|
||||
export interface ApplicationData {
|
||||
dob: string;
|
||||
name: string;
|
||||
playtime: number;
|
||||
hobbies: string;
|
||||
military: boolean;
|
||||
communities: string;
|
||||
joinReason: string;
|
||||
milsimAttraction: string;
|
||||
referral: string;
|
||||
steamProfile: string;
|
||||
timezone: string;
|
||||
canAttendSaturday: boolean;
|
||||
interests: string;
|
||||
aknowledgeRules: boolean;
|
||||
}
|
||||
|
||||
//reflects how applications are stored in the database
|
||||
export interface ApplicationRow {
|
||||
id: number;
|
||||
member_id: number;
|
||||
app_version: number;
|
||||
app_data: ApplicationData;
|
||||
|
||||
submitted_at: string; // ISO datetime from DB (e.g., "2025-08-25T18:04:29.000Z")
|
||||
updated_at: string | null;
|
||||
approved_at: string | null;
|
||||
denied_at: string | null;
|
||||
|
||||
app_status: ApplicationStatus; // generated column
|
||||
decision_at: string | null; // generated column
|
||||
|
||||
// present when you join members (e.g., SELECT a.*, m.name AS member_name)
|
||||
member_name: string;
|
||||
}
|
||||
export interface CommentRow {
|
||||
comment_id: number;
|
||||
post_content: string;
|
||||
poster_id: number;
|
||||
post_time: string;
|
||||
last_modified: string | null;
|
||||
poster_name: string;
|
||||
}
|
||||
|
||||
export interface ApplicationFull {
|
||||
application: ApplicationRow;
|
||||
comments: CommentRow[];
|
||||
}
|
||||
import { ApplicationFull } from "@shared/types/application";
|
||||
|
||||
|
||||
export enum ApplicationStatus {
|
||||
Pending = "Pending",
|
||||
Accepted = "Accepted",
|
||||
Denied = "Denied",
|
||||
}
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
export async function loadApplication(id: number | string): Promise<ApplicationFull | null> {
|
||||
const res = await fetch(`${addr}/application/${id}`, { credentials: 'include' })
|
||||
export async function loadApplication(id: number | string, asAdmin: boolean = false): Promise<ApplicationFull | null> {
|
||||
const res = await fetch(`${addr}/application/${id}?admin=${asAdmin}`, { credentials: 'include' })
|
||||
if (res.status === 204) return null
|
||||
if (!res.ok) throw new Error('Failed to load application')
|
||||
const json = await res.json()
|
||||
@@ -112,6 +43,21 @@ export async function postChatMessage(message: any, post_id: number) {
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function postAdminChatMessage(message: any, post_id: number) {
|
||||
const out = {
|
||||
message: message
|
||||
}
|
||||
|
||||
const response = await fetch(`${addr}/application/${post_id}/adminComment`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(out),
|
||||
})
|
||||
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function getAllApplications(): Promise<ApplicationFull> {
|
||||
const res = await fetch(`${addr}/application/all`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user