2 Commits

Author SHA1 Message Date
ea52be83ef Create dossier
Some checks failed
Continuous Deployment / Update Deployment (push) Failing after 1m29s
2025-12-06 15:40:51 -06:00
9c903c9ad9 Create dossier
Some checks failed
Continuous Deployment / Update Deployment (push) Failing after 1m19s
2025-12-05 17:59:04 -06:00
10 changed files with 177 additions and 128 deletions

View File

@@ -20,8 +20,8 @@ const port = process.env.SERVER_PORT;
//glitchtip setup
const sentry = require('@sentry/node');
if (process.env.DISABLE_GLITCHTIP) {
console.log("Glitchtip disabled")
if (!process.env.DISABLE_GLITCHTIP) {
console.log("Glitchtip disabled AAAAAA")
} else {
let dsn = process.env.GLITCHTIP_DSN;
sentry.init({ dsn: dsn });

View File

@@ -2,12 +2,11 @@ const express = require('express');
const router = express.Router();
import pool from '../db';
import { approveApplication, createApplication, denyApplication, getApplicationByID, getApplicationComments, getApplicationList, getMemberApplication } from '../services/applicationService';
import { approveApplication, createApplication, getApplicationByID, getApplicationComments, getApplicationList, getMemberApplication } from '../services/applicationService';
import { MemberState, setUserState } from '../services/memberService';
import { getRankByName, insertMemberRank } from '../services/rankService';
import { ApplicationFull, CommentRow } from "@app/shared/types/application"
import { assignUserToStatus } from '../services/statusService';
import { Request, Response } from 'express';
// POST /application
router.post('/', async (req, res) => {
@@ -17,13 +16,13 @@ router.post('/', async (req, res) => {
const appVersion = 1;
await createApplication(memberID, appVersion, JSON.stringify(App))
await setUserState(memberID, MemberState.Applicant);
createApplication(memberID, appVersion, JSON.stringify(App))
setUserState(memberID, MemberState.Applicant);
res.sendStatus(201);
} catch (err) {
console.error('Failed to create application: \n', err);
res.status(500).json({ error: 'Failed to create application' });
console.error('Insert failed:', err);
res.status(500).json({ error: 'Failed to save application' });
}
});
@@ -65,6 +64,7 @@ router.get('/me', async (req, res) => {
// GET /application/:id
router.get('/:id', async (req, res) => {
let appID = req.params.id;
console.log("HELLO")
try {
const application = await getApplicationByID(appID);
if (application === undefined)
@@ -92,6 +92,9 @@ router.post('/approve/:id', async (req, res) => {
const app = await getApplicationByID(appID);
const result = await approveApplication(appID);
console.log("START");
console.log(app, result);
//guard against failures
if (result.affectedRows != 1) {
throw new Error("Something went wrong approving the application");
@@ -116,11 +119,26 @@ router.post('/approve/:id', async (req, res) => {
router.post('/deny/:id', async (req, res) => {
const appID = req.params.id;
const sql = `
UPDATE applications
SET denied_at = NOW()
WHERE id = ?
AND approved_at IS NULL
AND denied_at IS NULL
`;
try {
const app = await getApplicationByID(appID);
await denyApplication(appID);
await setUserState(app.member_id, MemberState.Denied);
res.sendStatus(200);
const result = await pool.execute(sql, appID);
console.log(result);
if (result.affectedRows === 0) {
res.status(400).json('Something went wrong denying the application');
}
if (result.affectedRows == 1) {
res.sendStatus(200);
}
} catch (err) {
console.error('Approve failed:', err);
res.status(500).json({ error: 'Failed to deny application' });
@@ -128,12 +146,10 @@ router.post('/deny/:id', async (req, res) => {
});
// POST /application/:id/comment
router.post('/:id/comment', async (req: Request, res: Response) => {
router.post('/:id/comment', async (req, res) => {
const appID = req.params.id;
const data = req.body.message;
const user = req.user;
console.log(user)
const user = 1;
const sql = `INSERT INTO application_comments(
application_id,
@@ -145,7 +161,7 @@ VALUES(?, ?, ?);`
try {
const conn = await pool.getConnection();
const result = await conn.query(sql, [appID, user.id, data])
const result = await conn.query(sql, [appID, user, data])
console.log(result)
if (result.affectedRows !== 1) {
conn.release();
@@ -170,15 +186,4 @@ VALUES(?, ?, ?);`
}
});
router.post('/restart', async (req: Request, res: Response) => {
const user = req.user.id;
try {
await setUserState(user, MemberState.Guest);
res.sendStatus(200);
} catch (error) {
console.error('Comment failed:', error);
res.status(500).json({ error: 'Could not rester application' });
}
})
module.exports = router;

View File

@@ -1,6 +1,5 @@
import { ApplicationListRow, ApplicationRow, CommentRow } from "@app/shared/types/application";
import pool from "../db";
import { error } from "console";
export async function createApplication(memberID: number, appVersion: number, app: string) {
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
@@ -45,7 +44,7 @@ export async function getApplicationList(): Promise<ApplicationListRow[]> {
return rows;
}
export async function approveApplication(id: number) {
export async function approveApplication(id) {
const sql = `
UPDATE applications
SET approved_at = NOW()
@@ -58,24 +57,6 @@ export async function approveApplication(id: number) {
return result;
}
export async function denyApplication(id: number) {
const sql = `
UPDATE applications
SET denied_at = NOW()
WHERE id = ?
AND approved_at IS NULL
AND denied_at IS NULL
`;
const result = await pool.execute(sql, id);
if (result.affectedRows == 1) {
return
} else {
throw new Error(`"Something went wrong denying application with ID ${id}`);
}
}
export async function getApplicationComments(appID: number): Promise<CommentRow[]> {
return await pool.query(`SELECT app.id AS comment_id,
app.post_content,

View File

@@ -104,7 +104,6 @@ export async function postChatMessage(message: any, post_id: number) {
const response = await fetch(`${addr}/application/${post_id}/comment`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(out),
})
@@ -136,15 +135,4 @@ export async function denyApplication(id: Number) {
if (!res.ok) {
console.error("Something went wrong denying the application")
}
}
export async function restartApplication() {
const res = await fetch(`${addr}/application/restart`, {
method: 'POST',
credentials: 'include'
})
if (!res.ok) {
console.error("Something went wrong restarting your application")
}
}

View File

@@ -20,18 +20,18 @@ import { ApplicationData } from '@/api/application';
const formSchema = toTypedSchema(z.object({
dob: z.string().refine(v => v, { message: "A date of birth is required." }),
name: z.string().nonempty(),
name: z.string(),
playtime: z.coerce.number({ invalid_type_error: "Must be a number", }).min(0, "Cannot be less than 0"),
hobbies: z.string().nonempty(),
hobbies: z.string(),
military: z.boolean(),
communities: z.string().nonempty(),
joinReason: z.string().nonempty(),
milsimAttraction: z.string().nonempty(),
referral: z.string().nonempty(),
steamProfile: z.string().nonempty(),
timezone: z.string().nonempty(),
communities: z.string(),
joinReason: z.string(),
milsimAttraction: z.string(),
referral: z.string(),
steamProfile: z.string(),
timezone: z.string(),
canAttendSaturday: z.boolean(),
interests: z.string().nonempty(),
interests: z.string(),
aknowledgeRules: z.literal(true, {
errorMap: () => ({ message: "Required" })
}),
@@ -82,9 +82,7 @@ onMounted(() => {
<FormControl>
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -96,9 +94,7 @@ onMounted(() => {
<FormControl>
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -109,9 +105,7 @@ onMounted(() => {
<FormControl>
<Input type="number" :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -123,9 +117,7 @@ onMounted(() => {
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -139,9 +131,7 @@ onMounted(() => {
<span>Yes (checked) / No (unchecked)</span>
</div>
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -152,9 +142,7 @@ onMounted(() => {
<FormControl>
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -166,9 +154,7 @@ onMounted(() => {
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -180,9 +166,7 @@ onMounted(() => {
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -194,9 +178,7 @@ onMounted(() => {
<Input placeholder="e.g., Reddit / Member: Alice" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -212,9 +194,7 @@ onMounted(() => {
<Input type="url" placeholder="https://steamcommunity.com/profiles/7656119..." :model-value="value"
@update:model-value="handleChange" :disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -226,9 +206,7 @@ onMounted(() => {
<Input placeholder="e.g., AEST, EST, UTC+10" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -242,9 +220,7 @@ onMounted(() => {
<span>Yes (checked) / No (unchecked)</span>
</div>
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -256,9 +232,7 @@ onMounted(() => {
<Input placeholder="e.g., Rifleman; Medic; Pilot" :model-value="value" @update:model-value="handleChange"
:disabled="readOnly" />
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>
@@ -269,13 +243,11 @@ onMounted(() => {
<FormControl>
<div class="flex items-center gap-2">
<Checkbox :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
<span>By checking this box, you accept the <Button variant="link" class="p-0 h-min">Code of
<span>By checking this box, you accept the <Button variant="link" class="p-0">Code of
Conduct</Button>.</span>
</div>
</FormControl>
<div class="h-4">
<FormMessage class="text-destructive" />
</div>
<FormMessage />
</FormItem>
</FormField>

View File

@@ -20,7 +20,7 @@ const app = createApp(App)
app.use(createPinia())
app.use(router)
if (!import.meta.env.VITE_DISABLE_GLITCHTIP) {
if (!!import.meta.env.VITE_DISABLE_GLITCHTIP) {
let dsn = import.meta.env.VITE_GLITCHTIP_DSN;
let environment = import.meta.env.VITE_ENVIRONMENT;

View File

@@ -162,9 +162,9 @@ async function handleDeny(id) {
<div v-else class="flex flex-row justify-between items-center py-2 mb-8">
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight">Apply to join the 17th Rangers</h3>
</div>
<ApplicationForm :read-only="readOnly" :data="appData" @submit="(e) => { postApp(e) }" class="mb-7 pb-15">
<ApplicationForm :read-only="readOnly" :data="appData" @submit="(e) => { postApp(e) }" class="mb-7">
</ApplicationForm>
<div v-if="!newApp" class="pb-15">
<div v-if="!newApp">
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
<ApplicationChat :messages="chatData" @post="postComment"></ApplicationChat>
</div>

110
ui/src/pages/Dossier.vue Normal file
View File

@@ -0,0 +1,110 @@
<script setup lang="ts">
</script>
<template>
<div class="px-10 py-6 max-w-7xl mx-auto w-full">
<!-- Header -->
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-semibold tracking-tight">Member Deployments</h1>
<div class="text-muted-foreground">Unit / Dossier / Deployments</div>
</div>
<!-- Summary Cards -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="p-5 rounded-xl border bg-card shadow-sm">
<p class="text-muted-foreground text-sm">Total Deployments</p>
<p class="text-3xl font-bold mt-2">123</p>
</div>
<div class="p-5 rounded-xl border bg-card shadow-sm">
<p class="text-muted-foreground text-sm">Total Hours</p>
<p class="text-3xl font-bold mt-2">456h</p>
</div>
<div class="p-5 rounded-xl border bg-card shadow-sm">
<p class="text-muted-foreground text-sm">Avg. Attendance</p>
<p class="text-3xl font-bold mt-2">87%</p>
</div>
</div>
<!-- Filters & Search -->
<div class="flex justify-between items-end mb-4 flex-wrap gap-4">
<div class="flex gap-4 flex-wrap">
<div>
<label class="block text-sm text-muted-foreground mb-1">Operation Type</label>
<select class="border rounded-md px-3 py-2 w-48 bg-background">
<option>All</option>
<option>Deployment</option>
<option>Training</option>
</select>
</div>
<div>
<label class="block text-sm text-muted-foreground mb-1">Sort By</label>
<select class="border rounded-md px-3 py-2 w-48 bg-background">
<option>Date (Newest)</option>
<option>Date (Oldest)</option>
<option>Longest Duration</option>
</select>
</div>
</div>
<div>
<label class="block text-sm text-muted-foreground mb-1">Search</label>
<input type="text" placeholder="Search deployments..." class="border rounded-md px-3 py-2 w-56 bg-background" />
</div>
</div>
<!-- Deployment List -->
<div class="rounded-xl border divide-y bg-card shadow-sm">
<!-- Row -->
<div class="p-5 hover:bg-accent cursor-pointer flex justify-between items-center">
<div>
<p class="font-semibold text-lg">Operation Dawn Strike</p>
<div class="text-sm text-muted-foreground flex gap-6 mt-1">
<span>Date: 2024-08-14</span>
<span>Duration: 3.4h</span>
<span>Role: Rifleman</span>
</div>
</div>
<div class="text-right">
<p class="font-medium">Status: <span class="text-green-500 font-semibold">Completed</span></p>
</div>
</div>
<div class="p-5 hover:bg-accent cursor-pointer flex justify-between items-center">
<div>
<p class="font-semibold text-lg">Operation Iron Resolve</p>
<div class="text-sm text-muted-foreground flex gap-6 mt-1">
<span>Date: 2024-08-02</span>
<span>Duration: 2.1h</span>
<span>Role: Machine Gunner</span>
</div>
</div>
<div class="text-right">
<p class="font-medium">Status: <span class="text-yellow-500 font-semibold">Partial</span></p>
</div>
</div>
<div class="p-5 hover:bg-accent cursor-pointer flex justify-between items-center">
<div>
<p class="font-semibold text-lg">Operation Midnight Gale</p>
<div class="text-sm text-muted-foreground flex gap-6 mt-1">
<span>Date: 2024-07-22</span>
<span>Duration: 4.8h</span>
<span>Role: Squad Leader</span>
</div>
</div>
<div class="text-right">
<p class="font-medium">Status: <span class="text-red-500 font-semibold">NoShow</span></p>
</div>
</div>
</div>
</div>
</template>

View File

@@ -14,7 +14,6 @@ import { useUserStore } from '@/stores/user';
import { Check, Circle, Dot, Users, X } from 'lucide-vue-next'
import { computed, ref } from 'vue';
import Application from './Application.vue';
import { restartApplication } from '@/api/application';
function goToLogin() {
const redirectUrl = encodeURIComponent(window.location.origin + '/join')
@@ -72,18 +71,10 @@ const currentStep = computed<number>(() => {
})
const finalPanel = ref<'app' | 'message'>('message');
const reloadKey = ref(0);
async function restartApp() {
await restartApplication();
await userStore.loadUser();
reloadKey.value++;
}
</script>
<template>
<div class="flex flex-col items-center mt-10 w-full" :key="reloadKey">
<div class="flex flex-col items-center mt-10 w-full">
<!-- Stepper Container -->
<div class="w-full flex justify-center">
@@ -228,8 +219,8 @@ async function restartApp() {
</div>
<!-- Denied message -->
<div v-else-if="userStore.state === 'denied'">
<div class="w-full max-w-2xl flex flex-col gap-8">
<h1 class="text-3xl sm:text-4xl font-bold text-left">
<div class="w-full max-w-2xl p-8">
<h1 class="text-3xl sm:text-4xl font-bold mb-4 text-left text-destructive">
Application Not Approved
</h1>
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
@@ -255,7 +246,6 @@ async function restartApp() {
Team</span>
</p>
</div>
<Button class="w-min" @click="restartApp">Restart Application</Button>
</div>
</div>
</div>

View File

@@ -23,6 +23,9 @@ const router = createRouter({
{ path: '/trainingReport/new', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
{ path: '/trainingReport/:id', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
// Personnel File
{ path: '/dossier', component: () => import('@/pages/Dossier.vue'), meta: { requiresAuth: false, memberOnly: false } },
// ADMIN / STAFF ROUTES
{
path: '/administration',