Compare commits
6 Commits
Calendar-I
...
#54-Applic
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a65596283 | |||
| e61bd1c5a1 | |||
| df89d9bf67 | |||
| 4ab803ec72 | |||
| 6a55846f19 | |||
| c04a2b06cb |
@@ -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 AAAAAA")
|
||||
if (process.env.DISABLE_GLITCHTIP) {
|
||||
console.log("Glitchtip disabled")
|
||||
} else {
|
||||
let dsn = process.env.GLITCHTIP_DSN;
|
||||
sentry.init({ dsn: dsn });
|
||||
|
||||
@@ -2,11 +2,12 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
import pool from '../db';
|
||||
import { approveApplication, createApplication, getApplicationByID, getApplicationComments, getApplicationList, getMemberApplication } from '../services/applicationService';
|
||||
import { approveApplication, createApplication, denyApplication, 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) => {
|
||||
@@ -16,13 +17,13 @@ router.post('/', async (req, res) => {
|
||||
|
||||
const appVersion = 1;
|
||||
|
||||
createApplication(memberID, appVersion, JSON.stringify(App))
|
||||
setUserState(memberID, MemberState.Applicant);
|
||||
await createApplication(memberID, appVersion, JSON.stringify(App))
|
||||
await setUserState(memberID, MemberState.Applicant);
|
||||
|
||||
res.sendStatus(201);
|
||||
} catch (err) {
|
||||
console.error('Insert failed:', err);
|
||||
res.status(500).json({ error: 'Failed to save application' });
|
||||
console.error('Failed to create application: \n', err);
|
||||
res.status(500).json({ error: 'Failed to create application' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,7 +65,6 @@ 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,9 +92,6 @@ 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");
|
||||
@@ -119,26 +116,11 @@ 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 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);
|
||||
}
|
||||
|
||||
const app = await getApplicationByID(appID);
|
||||
await denyApplication(appID);
|
||||
await setUserState(app.member_id, MemberState.Denied);
|
||||
res.sendStatus(200);
|
||||
} catch (err) {
|
||||
console.error('Approve failed:', err);
|
||||
res.status(500).json({ error: 'Failed to deny application' });
|
||||
@@ -146,10 +128,12 @@ router.post('/deny/:id', async (req, res) => {
|
||||
});
|
||||
|
||||
// POST /application/:id/comment
|
||||
router.post('/:id/comment', async (req, res) => {
|
||||
router.post('/:id/comment', async (req: Request, res: Response) => {
|
||||
const appID = req.params.id;
|
||||
const data = req.body.message;
|
||||
const user = 1;
|
||||
const user = req.user;
|
||||
|
||||
console.log(user)
|
||||
|
||||
const sql = `INSERT INTO application_comments(
|
||||
application_id,
|
||||
@@ -161,7 +145,7 @@ VALUES(?, ?, ?);`
|
||||
try {
|
||||
const conn = await pool.getConnection();
|
||||
|
||||
const result = await conn.query(sql, [appID, user, data])
|
||||
const result = await conn.query(sql, [appID, user.id, data])
|
||||
console.log(result)
|
||||
if (result.affectedRows !== 1) {
|
||||
conn.release();
|
||||
@@ -186,4 +170,15 @@ 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;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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 (?, ?, ?);`;
|
||||
@@ -12,12 +13,16 @@ export async function getMemberApplication(memberID: number): Promise<Applicatio
|
||||
member.name AS member_name
|
||||
FROM applications AS app
|
||||
INNER JOIN members AS member ON member.id = app.member_id
|
||||
WHERE app.member_id = ?;`;
|
||||
WHERE app.member_id = ? ORDER BY submitted_at DESC LIMIT 1;`;
|
||||
|
||||
let app: ApplicationRow[] = await pool.query(sql, [memberID]);
|
||||
return app[0];
|
||||
}
|
||||
|
||||
// export async function getAllMemberApplications(memberID: number): Promise<ApplicationListRow[]> {
|
||||
|
||||
// }
|
||||
|
||||
export async function getApplicationByID(appID: number): Promise<ApplicationRow> {
|
||||
const sql =
|
||||
`SELECT app.*,
|
||||
@@ -44,7 +49,7 @@ export async function getApplicationList(): Promise<ApplicationListRow[]> {
|
||||
return rows;
|
||||
}
|
||||
|
||||
export async function approveApplication(id) {
|
||||
export async function approveApplication(id: number) {
|
||||
const sql = `
|
||||
UPDATE applications
|
||||
SET approved_at = NOW()
|
||||
@@ -57,6 +62,24 @@ export async function approveApplication(id) {
|
||||
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,
|
||||
|
||||
@@ -123,9 +123,15 @@ export async function setAttendanceStatus(memberID: number, eventID: number, sta
|
||||
}
|
||||
|
||||
export async function getEventAttendance(eventID: number): Promise<CalendarSignup[]> {
|
||||
const sql = `
|
||||
SELECT
|
||||
s.member_id,
|
||||
s.status,
|
||||
m.name AS member_name
|
||||
FROM calendar_events_signups s
|
||||
LEFT JOIN members m ON s.member_id = m.id
|
||||
WHERE s.event_id = ?
|
||||
`;
|
||||
|
||||
const sql = "CALL `sp_GetCalendarEventSignups`(?)"
|
||||
const res = await pool.query(sql, [eventID]);
|
||||
console.log(res[0]);
|
||||
return res[0];
|
||||
return await pool.query(sql, [eventID]);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export interface CalendarSignup {
|
||||
eventID: number;
|
||||
status: CalendarAttendance;
|
||||
member_name?: string;
|
||||
member_unit?: string;
|
||||
}
|
||||
|
||||
export interface CalendarEventShort {
|
||||
|
||||
@@ -104,6 +104,7 @@ 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),
|
||||
})
|
||||
@@ -135,4 +136,15 @@ 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")
|
||||
}
|
||||
}
|
||||
@@ -156,12 +156,6 @@ function blurAfter() {
|
||||
<RouterLink to="/join" @click="blurAfter">Join</RouterLink>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<!-- Calendar -->
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||
<RouterLink to="/calendar" @click="blurAfter">Calendar</RouterLink>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
</NavigationMenuList>
|
||||
</NavigationMenu>
|
||||
</div>
|
||||
|
||||
@@ -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(),
|
||||
name: z.string().nonempty(),
|
||||
playtime: z.coerce.number({ invalid_type_error: "Must be a number", }).min(0, "Cannot be less than 0"),
|
||||
hobbies: z.string(),
|
||||
hobbies: z.string().nonempty(),
|
||||
military: z.boolean(),
|
||||
communities: z.string(),
|
||||
joinReason: z.string(),
|
||||
milsimAttraction: z.string(),
|
||||
referral: z.string(),
|
||||
steamProfile: z.string(),
|
||||
timezone: z.string(),
|
||||
communities: z.string().nonempty(),
|
||||
joinReason: z.string().nonempty(),
|
||||
milsimAttraction: z.string().nonempty(),
|
||||
referral: z.string().nonempty(),
|
||||
steamProfile: z.string().nonempty(),
|
||||
timezone: z.string().nonempty(),
|
||||
canAttendSaturday: z.boolean(),
|
||||
interests: z.string(),
|
||||
interests: z.string().nonempty(),
|
||||
aknowledgeRules: z.literal(true, {
|
||||
errorMap: () => ({ message: "Required" })
|
||||
}),
|
||||
@@ -82,7 +82,9 @@ onMounted(() => {
|
||||
<FormControl>
|
||||
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -94,7 +96,9 @@ onMounted(() => {
|
||||
<FormControl>
|
||||
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -105,7 +109,9 @@ onMounted(() => {
|
||||
<FormControl>
|
||||
<Input type="number" :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -117,7 +123,9 @@ onMounted(() => {
|
||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -131,7 +139,9 @@ onMounted(() => {
|
||||
<span>Yes (checked) / No (unchecked)</span>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -142,7 +152,9 @@ onMounted(() => {
|
||||
<FormControl>
|
||||
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -154,7 +166,9 @@ onMounted(() => {
|
||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -166,7 +180,9 @@ onMounted(() => {
|
||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -178,7 +194,9 @@ onMounted(() => {
|
||||
<Input placeholder="e.g., Reddit / Member: Alice" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -194,7 +212,9 @@ onMounted(() => {
|
||||
<Input type="url" placeholder="https://steamcommunity.com/profiles/7656119..." :model-value="value"
|
||||
@update:model-value="handleChange" :disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -206,7 +226,9 @@ onMounted(() => {
|
||||
<Input placeholder="e.g., AEST, EST, UTC+10" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -220,7 +242,9 @@ onMounted(() => {
|
||||
<span>Yes (checked) / No (unchecked)</span>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -232,7 +256,9 @@ onMounted(() => {
|
||||
<Input placeholder="e.g., Rifleman; Medic; Pilot" :model-value="value" @update:model-value="handleChange"
|
||||
:disabled="readOnly" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
@@ -243,11 +269,13 @@ 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">Code of
|
||||
<span>By checking this box, you accept the <Button variant="link" class="p-0 h-min">Code of
|
||||
Conduct</Button>.</span>
|
||||
</div>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
<div class="h-4">
|
||||
<FormMessage class="text-destructive" />
|
||||
</div>
|
||||
</FormItem>
|
||||
</FormField>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { CalendarEvent, CalendarSignup } from '@shared/types/calendar'
|
||||
import { CircleAlert, Clock4, EllipsisVertical, MapPin, User, X } from 'lucide-vue-next';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { CircleAlert, Clock, EllipsisVertical, MapPin, User, X } from 'lucide-vue-next';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import ButtonGroup from '../ui/button-group/ButtonGroup.vue';
|
||||
import Button from '../ui/button/Button.vue';
|
||||
import { CalendarAttendance, getCalendarEvent, setCalendarEventAttendance, setCancelCalendarEvent } from '@/api/calendar';
|
||||
@@ -11,13 +11,24 @@ import DropdownMenu from '../ui/dropdown-menu/DropdownMenu.vue';
|
||||
import DropdownMenuTrigger from '../ui/dropdown-menu/DropdownMenuTrigger.vue';
|
||||
import DropdownMenuContent from '../ui/dropdown-menu/DropdownMenuContent.vue';
|
||||
import DropdownMenuItem from '../ui/dropdown-menu/DropdownMenuItem.vue';
|
||||
import { Calendar } from 'lucide-vue-next';
|
||||
|
||||
const route = useRoute();
|
||||
// const eventID = computed(() => {
|
||||
// const id = route.params.id;
|
||||
// if (typeof id === 'string') return id;
|
||||
// return undefined;
|
||||
// });
|
||||
|
||||
const loaded = ref<boolean>(false);
|
||||
const activeEvent = ref<CalendarEvent | null>(null);
|
||||
|
||||
// onMounted(async () => {
|
||||
// let eventID = route.params.id;
|
||||
// console.log(eventID);
|
||||
// activeEvent.value = await getCalendarEvent(Number(eventID));
|
||||
// loaded.value = true;
|
||||
// });
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async (id) => {
|
||||
@@ -34,27 +45,23 @@ const emit = defineEmits<{
|
||||
(e: 'edit', event: CalendarEvent): void
|
||||
}>()
|
||||
|
||||
const dateFmt = new Intl.DateTimeFormat(undefined, {
|
||||
weekday: 'long', month: 'short', day: 'numeric',
|
||||
})
|
||||
// const activeEvent = computed(() => props.event)
|
||||
|
||||
const timeFmt = new Intl.DateTimeFormat(undefined, {
|
||||
const startFmt = new Intl.DateTimeFormat(undefined, {
|
||||
weekday: 'short', year: 'numeric', month: 'short', day: 'numeric',
|
||||
hour: 'numeric', minute: '2-digit'
|
||||
})
|
||||
const endFmt = new Intl.DateTimeFormat(undefined, {
|
||||
hour: 'numeric', minute: '2-digit'
|
||||
})
|
||||
|
||||
const dateText = computed(() => {
|
||||
let start = dateFmt.format(new Date(activeEvent.value.start));
|
||||
let end = dateFmt.format(new Date(activeEvent.value.end));
|
||||
if (start === end)
|
||||
return start;
|
||||
else
|
||||
return `${start} - ${end}`;
|
||||
})
|
||||
|
||||
const timeText = computed(() => {
|
||||
let startTime = timeFmt.format(new Date(activeEvent.value.start))
|
||||
let endTime = timeFmt.format(new Date(activeEvent.value.end))
|
||||
return [startTime, endTime]
|
||||
const whenText = computed(() => {
|
||||
if (!activeEvent.value?.start) return ''
|
||||
const s = new Date(activeEvent.value.start)
|
||||
const e = activeEvent.value?.end ? new Date(activeEvent.value.end) : null
|
||||
return e
|
||||
? `${startFmt.format(s)} – ${endFmt.format(e)}`
|
||||
: `${startFmt.format(s)}`
|
||||
})
|
||||
|
||||
const attending = computed<CalendarSignup[]>(() => { return activeEvent.value.eventSignups.filter((s) => s.status == CalendarAttendance.Attending) })
|
||||
@@ -64,7 +71,6 @@ const viewedState = ref<CalendarAttendance>(CalendarAttendance.Attending);
|
||||
|
||||
let user = useUserStore();
|
||||
const myAttendance = computed<CalendarSignup | null>(() => {
|
||||
if (!user.isLoggedIn) return null;
|
||||
return activeEvent.value.eventSignups.find(
|
||||
(s) => s.member_id === user.user.id
|
||||
) || null;
|
||||
@@ -77,7 +83,6 @@ async function setAttendance(state: CalendarAttendance) {
|
||||
}
|
||||
|
||||
const canEditEvent = computed(() => {
|
||||
if (!user.isLoggedIn) return false;
|
||||
if (user.user.id == activeEvent.value.creator_id)
|
||||
return true;
|
||||
});
|
||||
@@ -92,94 +97,17 @@ async function forceReload() {
|
||||
activeEvent.value = await getCalendarEvent(activeEvent.value.id);
|
||||
}
|
||||
|
||||
const isPast = computed(() => {
|
||||
const end = new Date(activeEvent.value.end)
|
||||
// is current date later than end date
|
||||
return new Date() < end;
|
||||
})
|
||||
|
||||
const attendanceTab = ref<"Alpha" | "Echo" | "Other">("Alpha");
|
||||
const attendanceList = computed<CalendarSignup[]>(() => {
|
||||
let out: CalendarSignup[] = [];
|
||||
if (attendanceTab.value === 'Alpha') {
|
||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Alpha Company');
|
||||
} else if (attendanceTab.value === 'Echo') {
|
||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Echo Company')
|
||||
} else {
|
||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit != 'Alpha Company' && s.member_unit != 'Echo Company')
|
||||
}
|
||||
|
||||
const statusOrder: Record<CalendarAttendance, number> = {
|
||||
[CalendarAttendance.Attending]: 1,
|
||||
[CalendarAttendance.Maybe]: 2,
|
||||
[CalendarAttendance.NotAttending]: 3,
|
||||
};
|
||||
|
||||
out.sort((a, b) => statusOrder[a.status] - statusOrder[b.status]);
|
||||
|
||||
return out;
|
||||
})
|
||||
|
||||
const attendanceCountsByGroup = computed(() => {
|
||||
const signups = activeEvent.value.eventSignups ?? [];
|
||||
|
||||
return {
|
||||
Alpha: signups.filter(s => s.member_unit === "Alpha Company").length,
|
||||
Echo: signups.filter(s => s.member_unit === "Echo Company").length,
|
||||
Other: signups.filter(s =>
|
||||
s.member_unit !== "Alpha Company" &&
|
||||
s.member_unit !== "Echo Company"
|
||||
).length,
|
||||
};
|
||||
});
|
||||
|
||||
const attendanceStatusSummary = computed(() => {
|
||||
const signups = activeEvent.value.eventSignups ?? [];
|
||||
|
||||
return {
|
||||
attending: signups.filter(s => s.status === CalendarAttendance.Attending).length,
|
||||
maybe: signups.filter(s => s.status === CalendarAttendance.Maybe).length,
|
||||
notAttending: signups.filter(s => s.status === CalendarAttendance.NotAttending).length,
|
||||
};
|
||||
});
|
||||
|
||||
const statusColor = (status: CalendarAttendance) => {
|
||||
switch (status) {
|
||||
case CalendarAttendance.Attending:
|
||||
return "text-success";
|
||||
case CalendarAttendance.Maybe:
|
||||
return "text-yellow-600";
|
||||
case CalendarAttendance.NotAttending:
|
||||
return "text-destructive";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
const displayStatus = (status: CalendarAttendance) => {
|
||||
switch (status) {
|
||||
case CalendarAttendance.Attending:
|
||||
return "Attending";
|
||||
case CalendarAttendance.Maybe:
|
||||
return "Maybe";
|
||||
case CalendarAttendance.NotAttending:
|
||||
return "Declined";
|
||||
default:
|
||||
return status;
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({ forceReload })
|
||||
defineExpose({forceReload})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="loaded">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between gap-3 border-b px-4 py-3 h-14">
|
||||
<div class="flex items-center justify-between gap-3 border-b px-4 py-3">
|
||||
<h2 class="text-lg font-semibold break-all">
|
||||
{{ activeEvent?.name || 'Event' }}
|
||||
</h2>
|
||||
<div class="flex gap-4 items-center">
|
||||
<div class="flex gap-4">
|
||||
<DropdownMenu v-if="canEditEvent">
|
||||
<DropdownMenuTrigger>
|
||||
<button
|
||||
@@ -191,7 +119,8 @@ defineExpose({ forceReload })
|
||||
<DropdownMenuItem @click="emit('edit', activeEvent)">
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="activeEvent.cancelled" @click="setCancel(false)">
|
||||
<DropdownMenuItem v-if="activeEvent.cancelled"
|
||||
@click="setCancel(false)">
|
||||
Un-Cancel
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem v-else @click="setCancel(true)">
|
||||
@@ -213,7 +142,7 @@ defineExpose({ forceReload })
|
||||
<CircleAlert></CircleAlert> This event has been cancelled
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="isPast && user.isLoggedIn" class="w-full">
|
||||
<section class="w-full">
|
||||
<ButtonGroup class="flex w-full">
|
||||
<Button variant="outline"
|
||||
:class="myAttendance?.status === CalendarAttendance.Attending ? 'border-2 border-primary text-primary' : ''"
|
||||
@@ -226,22 +155,25 @@ defineExpose({ forceReload })
|
||||
@click="setAttendance(CalendarAttendance.NotAttending)">Declined</Button>
|
||||
</ButtonGroup>
|
||||
</section>
|
||||
<!-- Meta -->
|
||||
<section class="space-y-3 w-full">
|
||||
<p class="text-lg font-semibold">Details</p>
|
||||
<div class="text-foreground/80 flex gap-3 items-center">
|
||||
<Calendar :size="20"></Calendar> {{ dateText }}
|
||||
</div>
|
||||
<div class="text-foreground/80 flex gap-3 items-center">
|
||||
<Clock4 :size="20"></Clock4> {{ timeText[0] }} - {{ timeText[1] }}
|
||||
</div>
|
||||
<div class="text-foreground/80 flex gap-3 items-center">
|
||||
<MapPin :size="20"></MapPin> {{ activeEvent.location || "Unknown" }}
|
||||
</div>
|
||||
<div class="text-foreground/80 flex gap-3 items-center">
|
||||
<User :size="20"></User> {{ activeEvent.creator_name || "Unknown User" }}
|
||||
<!-- When -->
|
||||
<section v-if="whenText" class="space-y-2 w-full">
|
||||
<div class="inline-flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm">
|
||||
<Clock class="size-4 opacity-80" />
|
||||
<span class="font-medium">{{ whenText }}</span>
|
||||
</div>
|
||||
</section>
|
||||
<!-- Quick meta chips -->
|
||||
<section class="flex flex-wrap gap-2 w-full">
|
||||
<span class="inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs">
|
||||
<MapPin class="size-3.5 opacity-80" />
|
||||
<span class="font-medium">{{ activeEvent.location || "Unknown" }}</span>
|
||||
</span>
|
||||
<span class="inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs">
|
||||
<User class="size-3.5 opacity-80" />
|
||||
<span class="font-medium">Created by: {{ activeEvent.creator_name || "Unknown User"
|
||||
}}</span>
|
||||
</span>
|
||||
</section>
|
||||
<!-- Description -->
|
||||
<section class="space-y-2 w-full">
|
||||
<p class="text-lg font-semibold">Description</p>
|
||||
@@ -249,41 +181,46 @@ defineExpose({ forceReload })
|
||||
{{ activeEvent.description }}
|
||||
</p>
|
||||
</section>
|
||||
<!-- attendance -->
|
||||
<!-- Attendance -->
|
||||
<section class="space-y-2 w-full">
|
||||
<div class="flex items-center gap-5">
|
||||
<p class="text-lg font-semibold">Attendance</p>
|
||||
<!-- <div class="text-muted-foreground flex gap-6">
|
||||
<p>Going <span class="ml-1">{{ attendanceStatusSummary.attending }}</span></p>
|
||||
<p>Maybe <span class="ml-1">{{ attendanceStatusSummary.maybe }}</span></p>
|
||||
<p>Declined <span class="ml-1">{{ attendanceStatusSummary.notAttending }}</span></p>
|
||||
</div> -->
|
||||
</div>
|
||||
<p class="text-lg font-semibold">Attendance</p>
|
||||
<div class="flex flex-col border bg-muted/50 rounded-lg min-h-24 my-2">
|
||||
<div class="flex w-full pt-2 border-b *:w-full *:text-center *:pb-1 *:cursor-pointer">
|
||||
<label :class="attendanceTab === 'Alpha' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="attendanceTab = 'Alpha'">Alpha {{ attendanceCountsByGroup.Alpha }}</label>
|
||||
<label :class="attendanceTab === 'Echo' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="attendanceTab = 'Echo'">Echo {{ attendanceCountsByGroup.Echo }}</label>
|
||||
<label :class="attendanceTab === 'Other' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="attendanceTab = 'Other'">Other {{ attendanceCountsByGroup.Other }}</label>
|
||||
<label
|
||||
:class="viewedState === CalendarAttendance.Attending ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="viewedState = CalendarAttendance.Attending">Going {{ attending.length }}</label>
|
||||
<label
|
||||
:class="viewedState === CalendarAttendance.Maybe ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="viewedState = CalendarAttendance.Maybe">Maybe {{ maybe.length }}</label>
|
||||
<label
|
||||
:class="viewedState === CalendarAttendance.NotAttending ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
@click="viewedState = CalendarAttendance.NotAttending">Declined {{ declined.length
|
||||
}}</label>
|
||||
</div>
|
||||
<div class="pb-1 min-h-48">
|
||||
<div class="grid grid-cols-2 font-semibold text-muted-foreground border-b py-1 px-3 mb-2">
|
||||
<p>Name</p>
|
||||
<p class="text-right">Status</p>
|
||||
</div>
|
||||
|
||||
<div v-for="person in attendanceList" :key="person.member_id"
|
||||
class="grid grid-cols-2 py-1 *:px-3 hover:bg-muted">
|
||||
<div class="px-5 py-4 min-h-28">
|
||||
<div v-if="viewedState === CalendarAttendance.Attending" v-for="person in attending">
|
||||
<p>{{ person.member_name }}</p>
|
||||
</div>
|
||||
<div v-if="viewedState === CalendarAttendance.Maybe" v-for="person in maybe">
|
||||
<p>{{ person.member_name }}</p>
|
||||
</div>
|
||||
<div v-if="viewedState === CalendarAttendance.NotAttending" v-for="person in declined">
|
||||
<p>{{ person.member_name }}</p>
|
||||
<p :class="statusColor(person.status)" class="text-right">
|
||||
{{ displayStatus(person.status) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- Footer (optional actions) -->
|
||||
<!-- <div class="border-t px-4 py-3 flex items-center justify-end gap-2">
|
||||
<button class="rounded-md border px-3 py-1.5 text-sm hover:bg-muted/40 transition">
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
class="rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-sm hover:opacity-90 transition">
|
||||
Open details
|
||||
</button>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -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">
|
||||
<ApplicationForm :read-only="readOnly" :data="appData" @submit="(e) => { postApp(e) }" class="mb-7 pb-15">
|
||||
</ApplicationForm>
|
||||
<div v-if="!newApp">
|
||||
<div v-if="!newApp" class="pb-15">
|
||||
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
|
||||
<ApplicationChat :messages="chatData" @post="postComment"></ApplicationChat>
|
||||
</div>
|
||||
|
||||
@@ -3,14 +3,15 @@ import { ref, watch, nextTick, computed, onMounted } from 'vue'
|
||||
import FullCalendar from '@fullcalendar/vue3'
|
||||
import dayGridPlugin from '@fullcalendar/daygrid'
|
||||
import interactionPlugin from '@fullcalendar/interaction'
|
||||
import { ChevronLeft, ChevronRight, Plus } from 'lucide-vue-next'
|
||||
import { X, Clock, MapPin, User, ListTodo, ChevronLeft, ChevronRight, Plus } from 'lucide-vue-next'
|
||||
import CreateCalendarEvent from '@/components/calendar/CreateCalendarEvent.vue'
|
||||
import { CalendarEvent } from '@shared/types/calendar'
|
||||
import { getCalendarEvent, getMonthCalendarEvents } from '@/api/calendar'
|
||||
import { CalendarEvent, CalendarEventShort } from '@shared/types/calendar'
|
||||
import { Calendar } from '@fullcalendar/core'
|
||||
import ViewCalendarEvent from '@/components/calendar/ViewCalendarEvent.vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { useCalendarEvents } from '@/composables/useCalendarEvents'
|
||||
import { useCalendarNavigation } from '@/composables/useCalendarNavigation'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const monthLabels = [
|
||||
'January', 'February', 'March', 'April', 'May', 'June',
|
||||
@@ -23,14 +24,13 @@ function api() {
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const userStore = useUserStore();
|
||||
|
||||
function buildFullDate(month: number, year: number): Date {
|
||||
return new Date(year, month, 1); //default to first of month
|
||||
}
|
||||
|
||||
const { selectedMonth, selectedYear, years, goPrev, goNext, goToday, onDatesSet, goToSelectedDate } = useCalendarNavigation(api)
|
||||
const { events, loadEvents } = useCalendarEvents(selectedMonth, selectedYear);
|
||||
const { events, loadEvents} = useCalendarEvents(selectedMonth, selectedYear);
|
||||
|
||||
const panelOpen = ref(false)
|
||||
const activeEvent = ref<CalendarEvent | null>(null)
|
||||
@@ -48,7 +48,6 @@ const dialogRef = ref<any>(null)
|
||||
|
||||
// NEW: handle day/time slot clicks to start creating an event
|
||||
function onDateClick(arg: { dateStr: string }) {
|
||||
if (!userStore.isLoggedIn) return;
|
||||
dialogRef.value?.openDialog(arg.dateStr);
|
||||
// For now, just open the panel with a draft payload.
|
||||
// activeEvent.value = {
|
||||
@@ -203,7 +202,7 @@ onMounted(() => {
|
||||
@click="goToday">
|
||||
Today
|
||||
</button>
|
||||
<button v-if="userStore.isLoggedIn"
|
||||
<button
|
||||
class="cursor-pointer ml-1 inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:opacity-90"
|
||||
@click="onCreateEvent">
|
||||
<Plus class="h-4 w-4" />
|
||||
@@ -217,8 +216,7 @@ onMounted(() => {
|
||||
<aside v-if="panelOpen"
|
||||
class="3xl:w-lg 2xl:w-md border-l bg-card text-foreground flex flex-col overflow-auto scrollbar-themed"
|
||||
:style="{ height: 'calc(100vh - 61px)', position: 'sticky', top: '64px' }">
|
||||
<ViewCalendarEvent ref="eventViewRef" @close="() => { router.push('/calendar'); }"
|
||||
@reload="loadEvents()" @edit="(val) => { dialogRef.openDialog(null, 'edit', val) }">
|
||||
<ViewCalendarEvent ref="eventViewRef" @close="() => { router.push('/calendar'); }" @reload="loadEvents()" @edit="(val) => {dialogRef.openDialog(null, 'edit', val)}">
|
||||
</ViewCalendarEvent>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,7 @@ 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')
|
||||
@@ -71,10 +72,18 @@ 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">
|
||||
<div class="flex flex-col items-center mt-10 w-full" :key="reloadKey">
|
||||
|
||||
<!-- Stepper Container -->
|
||||
<div class="w-full flex justify-center">
|
||||
@@ -219,8 +228,8 @@ const finalPanel = ref<'app' | 'message'>('message');
|
||||
</div>
|
||||
<!-- Denied message -->
|
||||
<div v-else-if="userStore.state === 'denied'">
|
||||
<div class="w-full max-w-2xl p-8">
|
||||
<h1 class="text-3xl sm:text-4xl font-bold mb-4 text-left text-destructive">
|
||||
<div class="w-full max-w-2xl flex flex-col gap-8">
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-left">
|
||||
Application Not Approved
|
||||
</h1>
|
||||
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
|
||||
@@ -246,6 +255,7 @@ const finalPanel = ref<'app' | 'message'>('message');
|
||||
Team</span>
|
||||
</p>
|
||||
</div>
|
||||
<Button class="w-min" @click="restartApp">Restart Application</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,8 +16,8 @@ const router = createRouter({
|
||||
{ path: '/loa', component: () => import('@/pages/SubmitLOA.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||
{ path: '/transfer', component: () => import('@/pages/Transfer.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||
|
||||
{ path: '/calendar', component: () => import('@/pages/Calendar.vue'), meta: { }, },
|
||||
{ path: '/calendar/event/:id', component: () => import('@/pages/Calendar.vue'), meta: { }, },
|
||||
{ path: '/calendar', component: () => import('@/pages/Calendar.vue'), meta: { requiresAuth: true, memberOnly: true }, },
|
||||
{ path: '/calendar/event/:id', component: () => import('@/pages/Calendar.vue'), meta: { requiresAuth: true, memberOnly: true }, },
|
||||
|
||||
{ path: '/trainingReport', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||
{ path: '/trainingReport/new', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||
|
||||
Reference in New Issue
Block a user