Compare commits
59 Commits
0.3.0
...
homepage/w
| Author | SHA1 | Date | |
|---|---|---|---|
| f2acf86dd8 | |||
| 2127a48a83 | |||
| 6cb53deee3 | |||
| b6a9b6f855 | |||
| 2f7eb37771 | |||
| 0cfc5ce12b | |||
| 044dc78122 | |||
| 2e31b9bce4 | |||
| fd6a1822f4 | |||
| d484c357fb | |||
| 0a2c6785c6 | |||
| dac4de236b | |||
| 5e1351d033 | |||
| 5f6c17361b | |||
| eca4a75a6e | |||
| 9196a86570 | |||
| 05e6030626 | |||
| d01881f0af | |||
| 5f03820891 | |||
| e9cce2571a | |||
| 905a975327 | |||
| 5659f053ba | |||
| 52b0e3e86d | |||
| e949e32189 | |||
| e9fadc724e | |||
| 7dc93c9802 | |||
| 0969d96e82 | |||
| 89ee1899e0 | |||
| 754ddd11d4 | |||
| 2902404d2e | |||
| 8006f4f737 | |||
| f7f2d1be8b | |||
| 5cbe0e6c7f | |||
| 04ad7a8f14 | |||
| cf37e5d01c | |||
| ee7d70bbe0 | |||
| 9e469013c7 | |||
| 627f6bfe3d | |||
| 94fac645af | |||
| 1eef9145a4 | |||
| fd94a5f261 | |||
| 2a0d7c2ff2 | |||
| 8aaaea5ed0 | |||
| 45aa59d54a | |||
| cf8113000f | |||
| 90e7a925ec | |||
| 10fea0982f | |||
| cdabd66986 | |||
| fd99ec73b3 | |||
| bc51ca1fcf | |||
| 826943c1a3 | |||
| 8409d971c1 | |||
| 6e2edc0096 | |||
| 1dfdb6bd0e | |||
| 618c290318 | |||
| 7f98d52634 | |||
| a73431f622 | |||
| 4670b568a5 | |||
| 82c9681dfa |
@@ -7,7 +7,7 @@ import morgan = require('morgan');
|
|||||||
const app = express()
|
const app = express()
|
||||||
app.use(morgan('dev', {
|
app.use(morgan('dev', {
|
||||||
skip: (req) => {
|
skip: (req) => {
|
||||||
return req.path === '/members/me';
|
return req.originalUrl === '/members/me';
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -64,6 +64,7 @@ import { authRouter } from './routes/auth';
|
|||||||
import { roles, memberRoles } from './routes/roles';
|
import { roles, memberRoles } from './routes/roles';
|
||||||
import { courseRouter, eventRouter } from './routes/course';
|
import { courseRouter, eventRouter } from './routes/course';
|
||||||
import { calendarRouter } from './routes/calendar';
|
import { calendarRouter } from './routes/calendar';
|
||||||
|
import { docsRouter } from './routes/docs';
|
||||||
|
|
||||||
app.use('/application', applicationRouter);
|
app.use('/application', applicationRouter);
|
||||||
app.use('/ranks', ranks);
|
app.use('/ranks', ranks);
|
||||||
@@ -77,6 +78,7 @@ app.use('/memberRoles', memberRoles)
|
|||||||
app.use('/course', courseRouter)
|
app.use('/course', courseRouter)
|
||||||
app.use('/courseEvent', eventRouter)
|
app.use('/courseEvent', eventRouter)
|
||||||
app.use('/calendar', calendarRouter)
|
app.use('/calendar', calendarRouter)
|
||||||
|
app.use('/docs', docsRouter)
|
||||||
app.use('/', authRouter)
|
app.use('/', authRouter)
|
||||||
|
|
||||||
app.get('/ping', (req, res) => {
|
app.get('/ping', (req, res) => {
|
||||||
|
|||||||
@@ -155,21 +155,13 @@ router.post('/approve/:id', [requireLogin, requireRole("Recruiter")], async (req
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const app = await getApplicationByID(appID);
|
const app = await getApplicationByID(appID);
|
||||||
const result = await approveApplication(appID);
|
await approveApplication(appID, approved_by);
|
||||||
|
|
||||||
//guard against failures
|
|
||||||
if (result.affectedRows != 1) {
|
|
||||||
throw new Error("Something went wrong approving the application");
|
|
||||||
}
|
|
||||||
|
|
||||||
//update user profile
|
//update user profile
|
||||||
await setUserState(app.member_id, MemberState.Member);
|
await setUserState(app.member_id, MemberState.Member);
|
||||||
|
|
||||||
await pool.query('CALL sp_accept_new_recruit_validation(?, ?, ?, ?)', [Number(process.env.CONFIG_ID), app.member_id, approved_by, approved_by])
|
await pool.query('CALL sp_accept_new_recruit_validation(?, ?, ?, ?)', [Number(process.env.CONFIG_ID), app.member_id, approved_by, approved_by])
|
||||||
// let nextRank = await getRankByName('Recruit')
|
|
||||||
// await insertMemberRank(app.member_id, nextRank.id);
|
|
||||||
// //assign user to "pending basic"
|
|
||||||
// await assignUserToStatus(app.member_id, 1);
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Approve failed:', err);
|
console.error('Approve failed:', err);
|
||||||
@@ -178,12 +170,13 @@ router.post('/approve/:id', [requireLogin, requireRole("Recruiter")], async (req
|
|||||||
});
|
});
|
||||||
|
|
||||||
// POST /application/deny/:id
|
// POST /application/deny/:id
|
||||||
router.post('/deny/:id', [requireLogin, requireRole("Recruiter")], async (req, res) => {
|
router.post('/deny/:id', [requireLogin, requireRole("Recruiter")], async (req: Request, res: Response) => {
|
||||||
const appID = req.params.id;
|
const appID = Number(req.params.id);
|
||||||
|
const approver = Number(req.user.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const app = await getApplicationByID(appID);
|
const app = await getApplicationByID(appID);
|
||||||
await denyApplication(appID);
|
await denyApplication(appID, approver);
|
||||||
await setUserState(app.member_id, MemberState.Denied);
|
await setUserState(app.member_id, MemberState.Denied);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -33,23 +33,26 @@ cr.get('/roles', async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
er.get('/', async (req: Request, res: Response) => {
|
er.get('/', async (req: Request, res: Response) => {
|
||||||
const allowedSorts = new Map([
|
|
||||||
["ascending", "ASC"],
|
|
||||||
["descending", "DESC"]
|
|
||||||
]);
|
|
||||||
|
|
||||||
const sort = String(req.query.sort || "").toLowerCase();
|
|
||||||
const search = String(req.query.search || "").toLowerCase();
|
|
||||||
if (!allowedSorts.has(sort)) {
|
|
||||||
return res.status(400).json({
|
|
||||||
message: `Invalid sort direction '${req.query.sort}'. Allowed values are 'ascending' or 'descending'.`
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortDir = allowedSorts.get(sort);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let events = await getCourseEvents(sortDir, search);
|
const allowedSorts = new Map([
|
||||||
|
["ascending", "ASC"],
|
||||||
|
["descending", "DESC"]
|
||||||
|
]);
|
||||||
|
|
||||||
|
const page = Number(req.query.page) || undefined;
|
||||||
|
const pageSize = Number(req.query.pageSize) || undefined;
|
||||||
|
|
||||||
|
const sort = String(req.query.sort || "").toLowerCase();
|
||||||
|
const search = String(req.query.search || "").toLowerCase();
|
||||||
|
if (!allowedSorts.has(sort)) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: `Invalid sort direction '${req.query.sort}'. Allowed values are 'ascending' or 'descending'.`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortDir = allowedSorts.get(sort);
|
||||||
|
|
||||||
|
let events = await getCourseEvents(sortDir, search, page, pageSize);
|
||||||
res.status(200).json(events);
|
res.status(200).json(events);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('failed to fetch reports', error);
|
console.error('failed to fetch reports', error);
|
||||||
|
|||||||
24
api/src/routes/docs.ts
Normal file
24
api/src/routes/docs.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { requireLogin } from '../middleware/auth';
|
||||||
|
|
||||||
|
router.get('/welcome', [requireLogin], async (req: Request, res: Response) => {
|
||||||
|
const output = await fetch(`${process.env.DOC_HOST}/api/pages/717`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Token ${process.env.DOC_TOKEN_ID}:${process.env.DOC_TOKEN_SECRET}`,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (output.ok) {
|
||||||
|
const out = await output.json();
|
||||||
|
res.status(200).json(out.html);
|
||||||
|
} else {
|
||||||
|
console.error("Failed to fetch LOA policy from bookstack");
|
||||||
|
res.sendStatus(500);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
export const docsRouter = router;
|
||||||
@@ -56,9 +56,13 @@ router.get("/me", async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
//get my LOA history
|
//get my LOA history
|
||||||
router.get("/history", async (req: Request, res: Response) => {
|
router.get("/history", async (req: Request, res: Response) => {
|
||||||
const user = req.user.id;
|
|
||||||
try {
|
try {
|
||||||
const result = await getUserLOA(user);
|
const user = req.user.id;
|
||||||
|
|
||||||
|
const page = Number(req.query.page) || undefined;
|
||||||
|
const pageSize = Number(req.query.pageSize) || undefined;
|
||||||
|
|
||||||
|
const result = await getUserLOA(user, page, pageSize);
|
||||||
res.status(200).json(result)
|
res.status(200).json(result)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -66,9 +70,11 @@ router.get("/history", async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/all', [requireRole("17th Administrator")], async (req, res) => {
|
router.get('/all', [requireRole("17th Administrator")], async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const result = await getAllLOA();
|
const page = Number(req.query.page) || undefined;
|
||||||
|
const pageSize = Number(req.query.pageSize) || undefined;
|
||||||
|
const result = await getAllLOA(page, pageSize);
|
||||||
res.status(200).json(result)
|
res.status(200).json(result)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { Request, Response } from 'express';
|
|||||||
import pool from '../db';
|
import pool from '../db';
|
||||||
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
||||||
import { getUserActiveLOA } from '../services/loaService';
|
import { getUserActiveLOA } from '../services/loaService';
|
||||||
import { getMemberSettings, getMembersFull, getMembersLite, getUserData, setUserSettings } from '../services/memberService';
|
import { getAllMembersLite, getMemberSettings, getMembersFull, getMembersLite, getUserData, getUserState, setUserSettings } from '../services/memberService';
|
||||||
import { getUserRoles } from '../services/rolesService';
|
import { getUserRoles } from '../services/rolesService';
|
||||||
import { memberSettings, MemberState } from '@app/shared/types/member';
|
import { memberSettings, MemberState, myData } from '@app/shared/types/member';
|
||||||
|
|
||||||
//get all users
|
//get all users
|
||||||
router.get('/', [requireLogin, requireMemberState(MemberState.Member)], async (req, res) => {
|
router.get('/', [requireLogin, requireMemberState(MemberState.Member)], async (req, res) => {
|
||||||
@@ -37,12 +37,12 @@ router.get('/me', [requireLogin], async (req, res) => {
|
|||||||
return res.sendStatus(401)
|
return res.sendStatus(401)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id, name, state } = await getUserData(req.user.id);
|
const memData = await getUserData(req.user.id);
|
||||||
const LOAData = await getUserActiveLOA(req.user.id);
|
const LOAData = await getUserActiveLOA(req.user.id);
|
||||||
|
const memState = await getUserState(req.user.id);
|
||||||
const roleData = await getUserRoles(req.user.id);
|
const roleData = await getUserRoles(req.user.id);
|
||||||
|
|
||||||
const userDataFull = { id, name, state, LOAData, roleData };
|
const userDataFull: myData = { member: memData, LOAs: LOAData, roles: roleData, state: memState };
|
||||||
res.status(200).json(userDataFull);
|
res.status(200).json(userDataFull);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching user data:', error);
|
console.error('Error fetching user data:', error);
|
||||||
@@ -75,6 +75,16 @@ router.put('/settings', [requireLogin], async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.get('/lite', [requireLogin], async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
let out = await getAllMembersLite();
|
||||||
|
res.status(200).json(out);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
res.status(500).json(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
router.post('/lite/bulk', async (req: Request, res: Response) => {
|
router.post('/lite/bulk', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
let ids = req.body.ids;
|
let ids = req.body.ids;
|
||||||
@@ -86,6 +96,7 @@ router.post('/lite/bulk', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
router.post('/full/bulk', async (req: Request, res: Response) => {
|
router.post('/full/bulk', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
let ids = req.body.ids;
|
let ids = req.body.ids;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import pool from "../db"
|
import pool from "../db"
|
||||||
import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails, CourseEventSummary, RawAttendeeRow } from "@app/shared/types/course"
|
import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails, CourseEventSummary, RawAttendeeRow } from "@app/shared/types/course"
|
||||||
|
import { PagedData } from "@app/shared/types/pagination";
|
||||||
import { toDateTime } from "@app/shared/utils/time";
|
import { toDateTime } from "@app/shared/utils/time";
|
||||||
export async function getAllCourses(): Promise<Course[]> {
|
export async function getAllCourses(): Promise<Course[]> {
|
||||||
const sql = "SELECT * FROM courses WHERE deleted = false ORDER BY name ASC;"
|
const sql = "SELECT * FROM courses WHERE deleted = false ORDER BY name ASC;"
|
||||||
@@ -107,7 +108,8 @@ export async function insertCourseEvent(event: CourseEventDetails): Promise<numb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCourseEvents(sortDir: string, search: string = ""): Promise<CourseEventSummary[]> {
|
export async function getCourseEvents(sortDir: string, search: string = "", page = 1, pageSize = 10): Promise<PagedData<CourseEventSummary>> {
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
let params = [];
|
let params = [];
|
||||||
let searchString = "";
|
let searchString = "";
|
||||||
@@ -133,11 +135,23 @@ export async function getCourseEvents(sortDir: string, search: string = ""): Pro
|
|||||||
LEFT JOIN members AS M
|
LEFT JOIN members AS M
|
||||||
ON E.created_by = M.id
|
ON E.created_by = M.id
|
||||||
${searchString}
|
${searchString}
|
||||||
ORDER BY E.event_date ${sortDir};`;
|
ORDER BY E.event_date ${sortDir}
|
||||||
console.log(sql)
|
LIMIT ? OFFSET ?;`;
|
||||||
console.log(params)
|
|
||||||
let events: CourseEventSummary[] = await pool.query(sql, params);
|
let countSQL = `SELECT COUNT(*) AS count
|
||||||
return events;
|
FROM course_events AS E
|
||||||
|
LEFT JOIN courses AS C
|
||||||
|
ON E.course_id = C.id
|
||||||
|
LEFT JOIN members AS M
|
||||||
|
ON E.created_by = M.id ${searchString};`
|
||||||
|
let recordCount = Number((await pool.query(countSQL, [...params]))[0].count);
|
||||||
|
let pageCount = recordCount / pageSize;
|
||||||
|
|
||||||
|
let events: CourseEventSummary[] = await pool.query(sql, [...params, pageSize, offset]);
|
||||||
|
|
||||||
|
let output: PagedData<CourseEventSummary> = { data: events, pagination: { page: page, pageSize: pageSize, total: recordCount, totalPages: pageCount } }
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCourseEventRoles(): Promise<CourseAttendeeRole[]> {
|
export async function getCourseEventRoles(): Promise<CourseAttendeeRole[]> {
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ export async function getApplicationByID(appID: number): Promise<ApplicationRow>
|
|||||||
return app[0];
|
return app[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getApplicationList(): Promise<ApplicationListRow[]> {
|
export async function getApplicationList(page: number = 1, pageSize: number = 25): Promise<ApplicationListRow[]> {
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
const sql = `SELECT
|
const sql = `SELECT
|
||||||
member.name AS member_name,
|
member.name AS member_name,
|
||||||
app.id,
|
app.id,
|
||||||
@@ -40,9 +42,11 @@ export async function getApplicationList(): Promise<ApplicationListRow[]> {
|
|||||||
app.app_status
|
app.app_status
|
||||||
FROM applications AS app
|
FROM applications AS app
|
||||||
LEFT JOIN members AS member
|
LEFT JOIN members AS member
|
||||||
ON member.id = app.member_id;`
|
ON member.id = app.member_id
|
||||||
|
ORDER BY app.submitted_at DESC
|
||||||
|
LIMIT ? OFFSET ?;`
|
||||||
|
|
||||||
const rows: ApplicationListRow[] = await pool.query(sql);
|
const rows: ApplicationListRow[] = await pool.query(sql, [pageSize, offset]);
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,30 +63,35 @@ export async function getAllMemberApplications(memberID: number): Promise<Applic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function approveApplication(id: number) {
|
export async function approveApplication(id: number, approver: number) {
|
||||||
const sql = `
|
const sql = `
|
||||||
UPDATE applications
|
UPDATE applications
|
||||||
SET approved_at = NOW()
|
SET approved_at = NOW(), approved_by = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
AND approved_at IS NULL
|
AND approved_at IS NULL
|
||||||
AND denied_at IS NULL
|
AND denied_at IS NULL
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const result = await pool.execute(sql, id);
|
const result = await pool.execute(sql, [approver, id]);
|
||||||
return result;
|
console.log(result);
|
||||||
|
if (result.affectedRows == 1) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
throw new Error(`"Something went wrong approving application with ID ${id}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function denyApplication(id: number) {
|
export async function denyApplication(id: number, approver: number) {
|
||||||
const sql = `
|
const sql = `
|
||||||
UPDATE applications
|
UPDATE applications
|
||||||
SET denied_at = NOW()
|
SET denied_at = NOW(), approved_by = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
AND approved_at IS NULL
|
AND approved_at IS NULL
|
||||||
AND denied_at IS NULL
|
AND denied_at IS NULL
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const result = await pool.execute(sql, id);
|
const result = await pool.execute(sql, [approver, id]);
|
||||||
|
console.log(result);
|
||||||
if (result.affectedRows == 1) {
|
if (result.affectedRows == 1) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { toDateTime } from "@app/shared/utils/time";
|
import { toDateTime } from "@app/shared/utils/time";
|
||||||
import pool from "../db";
|
import pool from "../db";
|
||||||
import { LOARequest, LOAType } from '@app/shared/types/loa'
|
import { LOARequest, LOAType } from '@app/shared/types/loa'
|
||||||
|
import { PagedData } from '@app/shared/types/pagination'
|
||||||
|
|
||||||
export async function getLoaTypes(): Promise<LOAType[]> {
|
export async function getLoaTypes(): Promise<LOAType[]> {
|
||||||
return await pool.query('SELECT * FROM leave_of_absences_types;');
|
return await pool.query('SELECT * FROM leave_of_absences_types;');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllLOA(page = 1, pageSize = 20): Promise<LOARequest[]> {
|
export async function getAllLOA(page = 1, pageSize = 10): Promise<PagedData<LOARequest>> {
|
||||||
const offset = (page - 1) * pageSize;
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
const sql = `
|
const sql = `
|
||||||
@@ -26,12 +27,19 @@ export async function getAllLOA(page = 1, pageSize = 20): Promise<LOARequest[]>
|
|||||||
loa.start_date DESC
|
loa.start_date DESC
|
||||||
LIMIT ? OFFSET ?;
|
LIMIT ? OFFSET ?;
|
||||||
`;
|
`;
|
||||||
|
let loaList: LOARequest[] = await pool.query(sql, [pageSize, offset]) as LOARequest[];
|
||||||
|
|
||||||
let res: LOARequest[] = await pool.query(sql, [pageSize, offset]) as LOARequest[];
|
let loaCount = Number((await pool.query(`SELECT COUNT(*) as count FROM leave_of_absences;`))[0].count);
|
||||||
return res;
|
let pageCount = loaCount / pageSize;
|
||||||
|
|
||||||
|
let output: PagedData<LOARequest> = { data: loaList, pagination: { page: page, pageSize: pageSize, total: loaCount, totalPages: pageCount } }
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserLOA(userId: number): Promise<LOARequest[]> {
|
export async function getUserLOA(userId: number, page = 1, pageSize = 10): Promise<PagedData<LOARequest>> {
|
||||||
|
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
const result: LOARequest[] = await pool.query(`
|
const result: LOARequest[] = await pool.query(`
|
||||||
SELECT loa.*, members.name, t.name AS type_name
|
SELECT loa.*, members.name, t.name AS type_name
|
||||||
FROM leave_of_absences AS loa
|
FROM leave_of_absences AS loa
|
||||||
@@ -48,8 +56,12 @@ export async function getUserLOA(userId: number): Promise<LOARequest[]> {
|
|||||||
WHEN loa.closed IS NOT NULL THEN 4
|
WHEN loa.closed IS NOT NULL THEN 4
|
||||||
END,
|
END,
|
||||||
loa.start_date DESC
|
loa.start_date DESC
|
||||||
`, [userId])
|
LIMIT ? OFFSET ?;`, [userId, pageSize, offset])
|
||||||
return result;
|
|
||||||
|
let loaCount = Number((await pool.query(`SELECT COUNT(*) as count FROM leave_of_absences WHERE member_id = ?;`, [userId]))[0].count);
|
||||||
|
let pageCount = loaCount / pageSize;
|
||||||
|
let output: PagedData<LOARequest> = { data: result, pagination: { page: page, pageSize: pageSize, total: loaCount, totalPages: pageCount } }
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserActiveLOA(userId: number): Promise<LOARequest[]> {
|
export async function getUserActiveLOA(userId: number): Promise<LOARequest[]> {
|
||||||
@@ -73,7 +85,8 @@ export async function createNewLOA(data: LOARequest) {
|
|||||||
export async function closeLOA(id: number, closer: number) {
|
export async function closeLOA(id: number, closer: number) {
|
||||||
const sql = `UPDATE leave_of_absences
|
const sql = `UPDATE leave_of_absences
|
||||||
SET closed = 1,
|
SET closed = 1,
|
||||||
closed_by = ?
|
closed_by = ?,
|
||||||
|
ended_at = NOW()
|
||||||
WHERE leave_of_absences.id = ?`;
|
WHERE leave_of_absences.id = ?`;
|
||||||
let out = await pool.query(sql, [closer, id]);
|
let out = await pool.query(sql, [closer, id]);
|
||||||
console.log(out);
|
console.log(out);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import pool from "../db";
|
import pool from "../db";
|
||||||
import { Member, MemberLight, memberSettings, MemberState } from '@app/shared/types/member'
|
import { Member, MemberLight, memberSettings, MemberState } from '@app/shared/types/member'
|
||||||
|
|
||||||
export async function getUserData(userID: number) {
|
export async function getUserData(userID: number): Promise<Member> {
|
||||||
const sql = `SELECT * FROM members WHERE id = ?`;
|
const sql = `SELECT * FROM view_member_rank_unit_status_latest WHERE member_id = ?`;
|
||||||
const res = await pool.query(sql, [userID]);
|
const res: Member = await pool.query(sql, [userID]);
|
||||||
return res[0] ?? null;
|
return res[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +49,18 @@ export async function getMembersLite(ids: number[]): Promise<MemberLight[]> {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllMembersLite(): Promise<MemberLight[]> {
|
||||||
|
const sql = `SELECT m.member_id AS id,
|
||||||
|
m.member_name AS username,
|
||||||
|
m.displayName,
|
||||||
|
u.color
|
||||||
|
FROM view_member_rank_unit_status_latest m
|
||||||
|
LEFT JOIN units u ON u.name = m.unit;`;
|
||||||
|
|
||||||
|
const res: MemberLight[] = await pool.query(sql);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getMembersFull(ids: number[]): Promise<Member[]> {
|
export async function getMembersFull(ids: number[]): Promise<Member[]> {
|
||||||
const sql = `SELECT * FROM view_member_rank_unit_status_latest WHERE member_id IN (?);`;
|
const sql = `SELECT * FROM view_member_rank_unit_status_latest WHERE member_id IN (?);`;
|
||||||
const res: Member[] = await pool.query(sql, [ids]);
|
const res: Member[] = await pool.query(sql, [ids]);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export interface CalendarSignup {
|
|||||||
eventID: number;
|
eventID: number;
|
||||||
status: CalendarAttendance;
|
status: CalendarAttendance;
|
||||||
member_name?: string;
|
member_name?: string;
|
||||||
member_unit?: string;
|
unit_name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CalendarEventShort {
|
export interface CalendarEventShort {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { LOARequest } from "./loa";
|
||||||
|
import { Role } from "./roles";
|
||||||
|
|
||||||
export interface memberSettings {
|
export interface memberSettings {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
}
|
}
|
||||||
@@ -14,6 +17,7 @@ export enum MemberState {
|
|||||||
export type Member = {
|
export type Member = {
|
||||||
member_id: number;
|
member_id: number;
|
||||||
member_name: string;
|
member_name: string;
|
||||||
|
displayName?: string;
|
||||||
rank: string | null;
|
rank: string | null;
|
||||||
rank_date: string | null;
|
rank_date: string | null;
|
||||||
unit: string | null;
|
unit: string | null;
|
||||||
@@ -28,4 +32,11 @@ export interface MemberLight {
|
|||||||
displayName: string
|
displayName: string
|
||||||
username: string
|
username: string
|
||||||
color: string
|
color: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface myData {
|
||||||
|
member: Member;
|
||||||
|
LOAs: LOARequest[];
|
||||||
|
roles: Role[];
|
||||||
|
state: MemberState;
|
||||||
}
|
}
|
||||||
11
shared/types/pagination.ts
Normal file
11
shared/types/pagination.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export interface PagedData<T> {
|
||||||
|
data: T[]
|
||||||
|
pagination: pagination
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface pagination {
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
total: number
|
||||||
|
totalPages: number
|
||||||
|
}
|
||||||
@@ -12,4 +12,4 @@ export function toDateTime(date: Date): string {
|
|||||||
const second = date.getSeconds().toString().padStart(2, "0");
|
const second = date.getSeconds().toString().padStart(2, "0");
|
||||||
|
|
||||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
ui/public/bg.jpg
Normal file
BIN
ui/public/bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 543 KiB |
@@ -22,7 +22,10 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col min-h-screen">
|
<div class="flex flex-col min-h-screen" style="background-image: linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)), url('/bg.jpg');
|
||||||
|
background-size: contain;
|
||||||
|
background-attachment: fixed;
|
||||||
|
background-position: center;">
|
||||||
<div class="sticky top-0 bg-background z-50">
|
<div class="sticky top-0 bg-background z-50">
|
||||||
<Navbar class="flex"></Navbar>
|
<Navbar class="flex"></Navbar>
|
||||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
||||||
@@ -30,10 +33,12 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
<Alert v-if="userStore.user?.LOAData?.[0]" class="m-2 mx-auto w-5xl" variant="info">
|
<Alert v-if="userStore.user?.LOAs?.[0]" class="m-2 mx-auto w-5xl" variant="info">
|
||||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||||
<p>You are on LOA until <strong>{{ formatDate(userStore.user?.LOAData?.[0].end_date) }}</strong></p>
|
<p>You are on LOA until <strong>{{ formatDate(userStore.user?.LOAs?.[0].extended_till ||
|
||||||
<Button variant="secondary" @click="async () => { await cancelLOA(userStore.user?.LOAData?.[0].id); userStore.loadUser(); }">End
|
userStore.user?.LOAs?.[0].end_date) }}</strong></p>
|
||||||
|
<Button variant="secondary"
|
||||||
|
@click="async () => { await cancelLOA(userStore.user.LOAs?.[0].id); userStore.loadUser(); }">End
|
||||||
LOA</Button>
|
LOA</Button>
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|||||||
@@ -94,16 +94,18 @@ export async function approveApplication(id: Number) {
|
|||||||
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST', credentials: 'include' })
|
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST', credentials: 'include' })
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
console.error("Something went wrong approving the application")
|
throw new Error("Something went wrong approving the application");
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function denyApplication(id: Number) {
|
export async function denyApplication(id: Number) {
|
||||||
const res = await fetch(`${addr}/application/deny/${id}`, { method: 'POST', credentials: 'include' })
|
const res = await fetch(`${addr}/application/deny/${id}`, { method: 'POST', credentials: 'include' })
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
console.error("Something went wrong denying the application")
|
throw new Error("Something went wrong denyting the application");
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function restartApplication() {
|
export async function restartApplication() {
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ export async function editCalendarEvent(eventData: CalendarEvent) {
|
|||||||
export async function setCancelCalendarEvent(eventID: number, cancel: boolean) {
|
export async function setCancelCalendarEvent(eventID: number, cancel: boolean) {
|
||||||
let route = cancel ? "cancel" : "uncancel";
|
let route = cancel ? "cancel" : "uncancel";
|
||||||
|
|
||||||
console.log(route);
|
|
||||||
let res = await fetch(`${addr}/calendar/${eventID}/${route}`, {
|
let res = await fetch(`${addr}/calendar/${eventID}/${route}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
|
|||||||
18
ui/src/api/docs.ts
Normal file
18
ui/src/api/docs.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
|
export async function getWelcomeMessage(): Promise<string> {
|
||||||
|
const res = await fetch(`${addr}/docs/welcome`, {
|
||||||
|
method: "GET",
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
if (res.ok) {
|
||||||
|
const out = res.json();
|
||||||
|
if (!out) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { LOARequest, LOAType } from '@shared/types/loa'
|
import { LOARequest, LOAType } from '@shared/types/loa'
|
||||||
|
import { PagedData } from '@shared/types/pagination'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const addr = import.meta.env.VITE_APIHOST;
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
@@ -30,9 +31,9 @@ export async function adminSubmitLOA(request: LOARequest): Promise<{ id?: number
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
return res.json();
|
return
|
||||||
} else {
|
} else {
|
||||||
return { error: "Failed to submit LOA" };
|
throw new Error("Failed to submit LOA");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,8 +59,18 @@ export async function getMyLOA(): Promise<LOARequest | null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAllLOAs(): Promise<LOARequest[]> {
|
export async function getAllLOAs(page?: number, pageSize?: number): Promise<PagedData<LOARequest>> {
|
||||||
return fetch(`${addr}/loa/all`, {
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (page !== undefined) {
|
||||||
|
params.set("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageSize !== undefined) {
|
||||||
|
params.set("pageSize", pageSize.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetch(`${addr}/loa/all?${params}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -74,8 +85,18 @@ export function getAllLOAs(): Promise<LOARequest[]> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMyLOAs(): Promise<LOARequest[]> {
|
export function getMyLOAs(page?: number, pageSize?: number): Promise<PagedData<LOARequest>> {
|
||||||
return fetch(`${addr}/loa/history`, {
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (page !== undefined) {
|
||||||
|
params.set("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageSize !== undefined) {
|
||||||
|
params.set("pageSize", pageSize.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetch(`${addr}/loa/history?${params}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ export async function setMemberSettings(settings: memberSettings) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllLightMembers(): Promise<MemberLight[]> {
|
||||||
|
const response = await fetch(`${addr}/members/lite`, {
|
||||||
|
credentials: 'include',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Failed to fetch light members");
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
export async function getLightMembers(ids: number[]): Promise<MemberLight[]> {
|
export async function getLightMembers(ids: number[]): Promise<MemberLight[]> {
|
||||||
|
|
||||||
if (ids.length === 0) return [];
|
if (ids.length === 0) return [];
|
||||||
|
|||||||
@@ -1,15 +1,34 @@
|
|||||||
import { Course, CourseAttendeeRole, CourseEventDetails, CourseEventSummary } from '@shared/types/course'
|
import { Course, CourseAttendeeRole, CourseEventDetails, CourseEventSummary } from '@shared/types/course'
|
||||||
|
import { PagedData } from '@shared/types/pagination';
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const addr = import.meta.env.VITE_APIHOST;
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
export async function getTrainingReports(sortMode: string, search: string): Promise<CourseEventSummary[]> {
|
export async function getTrainingReports(sortMode?: string, search?: string, page?: number, pageSize?: number): Promise<PagedData<CourseEventSummary>> {
|
||||||
const res = await fetch(`${addr}/courseEvent?sort=${sortMode}&search=${search}`, {
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (page !== undefined) {
|
||||||
|
params.set("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageSize !== undefined) {
|
||||||
|
params.set("pageSize", pageSize.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortMode !== undefined) {
|
||||||
|
params.set("sort", sortMode.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (search !== undefined || search !== "") {
|
||||||
|
params.set("search", search.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch(`${addr}/courseEvent?${params}`, {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
return await res.json() as Promise<CourseEventSummary[]>;
|
return await res.json() as Promise<PagedData<CourseEventSummary>>;
|
||||||
} else {
|
} else {
|
||||||
console.error("Something went wrong");
|
console.error("Something went wrong");
|
||||||
throw new Error("Failed to load training reports");
|
throw new Error("Failed to load training reports");
|
||||||
@@ -31,7 +50,7 @@ export async function getTrainingReport(id: number): Promise<CourseEventDetails>
|
|||||||
|
|
||||||
export async function getAllTrainings(): Promise<Course[]> {
|
export async function getAllTrainings(): Promise<Course[]> {
|
||||||
const res = await fetch(`${addr}/course`, {
|
const res = await fetch(`${addr}/course`, {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--background: oklch(0.2046 0 0);
|
--background: oklch(19.125% 0.00002 271.152);
|
||||||
--foreground: oklch(0.9219 0 0);
|
--foreground: oklch(0.9219 0 0);
|
||||||
--card: oklch(23.075% 0.00003 271.152);
|
--card: oklch(23.075% 0.00003 271.152);
|
||||||
--card-foreground: oklch(0.9219 0 0);
|
--card-foreground: oklch(0.9219 0 0);
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ function blurAfter() {
|
|||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
|
|
||||||
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
<!-- <NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
<RouterLink to="/transfer" @click="blurAfter">
|
<RouterLink to="/transfer" @click="blurAfter">
|
||||||
Transfer Request
|
Transfer Request
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink> -->
|
||||||
|
|
||||||
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
<RouterLink to="/trainingReport" @click="blurAfter">
|
<RouterLink to="/trainingReport" @click="blurAfter">
|
||||||
@@ -107,13 +107,13 @@ function blurAfter() {
|
|||||||
<NavigationMenuContent
|
<NavigationMenuContent
|
||||||
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
|
||||||
<NavigationMenuLink
|
<!-- <NavigationMenuLink
|
||||||
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
as-child :class="navigationMenuTriggerStyle()">
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
<RouterLink to="/administration/rankChange" @click="blurAfter">
|
<RouterLink to="/administration/rankChange" @click="blurAfter">
|
||||||
Promotions
|
Promotions
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink> -->
|
||||||
|
|
||||||
<NavigationMenuLink
|
<NavigationMenuLink
|
||||||
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
@@ -123,13 +123,13 @@ function blurAfter() {
|
|||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
|
|
||||||
<NavigationMenuLink
|
<!-- <NavigationMenuLink
|
||||||
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
as-child :class="navigationMenuTriggerStyle()">
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
<RouterLink to="/administration/transfer" @click="blurAfter">
|
<RouterLink to="/administration/transfer" @click="blurAfter">
|
||||||
Transfer Requests
|
Transfer Requests
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink> -->
|
||||||
|
|
||||||
<NavigationMenuLink v-if="auth.hasRole('Recruiter')" as-child
|
<NavigationMenuLink v-if="auth.hasRole('Recruiter')" as-child
|
||||||
:class="navigationMenuTriggerStyle()">
|
:class="navigationMenuTriggerStyle()">
|
||||||
@@ -147,11 +147,11 @@ function blurAfter() {
|
|||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
|
|
||||||
<NavigationMenuItem as-child :class="navigationMenuTriggerStyle()">
|
<!-- <NavigationMenuItem as-child :class="navigationMenuTriggerStyle()">
|
||||||
<RouterLink to="/members" @click="blurAfter">
|
<RouterLink to="/members" @click="blurAfter">
|
||||||
Members (debug)
|
Members (debug)
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem> -->
|
||||||
|
|
||||||
</NavigationMenuList>
|
</NavigationMenuList>
|
||||||
</NavigationMenu>
|
</NavigationMenu>
|
||||||
@@ -179,7 +179,9 @@ function blurAfter() {
|
|||||||
<div>
|
<div>
|
||||||
<DropdownMenu v-if="userStore.isLoggedIn">
|
<DropdownMenu v-if="userStore.isLoggedIn">
|
||||||
<DropdownMenuTrigger class="cursor-pointer">
|
<DropdownMenuTrigger class="cursor-pointer">
|
||||||
<p>{{ userStore.user.name }}</p>
|
<Button variant="ghost" class="px-4">
|
||||||
|
{{ userStore.displayName }}
|
||||||
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="$router.push('/profile')">My Profile</DropdownMenuItem>
|
<DropdownMenuItem @click="$router.push('/profile')">My Profile</DropdownMenuItem>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function onSubmit(values: { text: string }, { resetForm }: { resetForm: () => vo
|
|||||||
<!-- Button below, right-aligned -->
|
<!-- Button below, right-aligned -->
|
||||||
<div class="mt-2 flex justify-end gap-2">
|
<div class="mt-2 flex justify-end gap-2">
|
||||||
<Button v-if="adminMode" type="submit" @click="submitMode = 'internal'" variant="outline">Post (Internal)</Button>
|
<Button v-if="adminMode" type="submit" @click="submitMode = 'internal'" variant="outline">Post (Internal)</Button>
|
||||||
<Button type="submit" @click="submitMode = 'public'">Post (Public)</Button>
|
<Button type="submit" @click="submitMode = 'public'">{{ adminMode ? 'Post (Public)' : 'Post' }}</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const regexB = /^https?:\/\/steamcommunity\.com\/profiles\/\d+\/?$/;
|
|||||||
const formSchema = toTypedSchema(z.object({
|
const formSchema = toTypedSchema(z.object({
|
||||||
dob: z.string().refine(v => v, { message: "A date of birth is required." }),
|
dob: z.string().refine(v => v, { message: "A date of birth is required." }),
|
||||||
name: z.string().nonempty(),
|
name: z.string().nonempty(),
|
||||||
playtime: z.coerce.number({ invalid_type_error: "Must be a number", }).min(0, "Cannot be less than 0"),
|
playtime: z.preprocess((v) => (v === "" ? undefined : String(v)),z.string({ required_error: "Required" }).regex(/^\d+(\.\d+)?$/, "Must be a number").transform(Number).refine((n) => n >= 0, "Cannot be less than 0")),
|
||||||
hobbies: z.string().nonempty(),
|
hobbies: z.string().nonempty(),
|
||||||
military: z.boolean(),
|
military: z.boolean(),
|
||||||
communities: z.string().nonempty(),
|
communities: z.string().nonempty(),
|
||||||
@@ -174,7 +174,7 @@ watch(() => showCoC.value, async () => {
|
|||||||
<FormLabel>Have you ever served in the military?</FormLabel>
|
<FormLabel>Have you ever served in the military?</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox :checked="value ?? false" @update:checked="handleChange" :disabled="readOnly" />
|
<Checkbox :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||||
<span>Yes (checked) / No (unchecked)</span>
|
<span>Yes (checked) / No (unchecked)</span>
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import DropdownMenuContent from '../ui/dropdown-menu/DropdownMenuContent.vue';
|
|||||||
import DropdownMenuItem from '../ui/dropdown-menu/DropdownMenuItem.vue';
|
import DropdownMenuItem from '../ui/dropdown-menu/DropdownMenuItem.vue';
|
||||||
import { Calendar } from 'lucide-vue-next';
|
import { Calendar } from 'lucide-vue-next';
|
||||||
import MemberCard from '../members/MemberCard.vue';
|
import MemberCard from '../members/MemberCard.vue';
|
||||||
|
import Spinner from '../ui/spinner/Spinner.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
@@ -63,11 +64,11 @@ const maybe = computed<CalendarSignup[]>(() => { return activeEvent.value.eventS
|
|||||||
const declined = computed<CalendarSignup[]>(() => { return activeEvent.value.eventSignups.filter((s) => s.status == CalendarAttendance.NotAttending) })
|
const declined = computed<CalendarSignup[]>(() => { return activeEvent.value.eventSignups.filter((s) => s.status == CalendarAttendance.NotAttending) })
|
||||||
const viewedState = ref<CalendarAttendance>(CalendarAttendance.Attending);
|
const viewedState = ref<CalendarAttendance>(CalendarAttendance.Attending);
|
||||||
|
|
||||||
let user = useUserStore();
|
let userStore = useUserStore();
|
||||||
const myAttendance = computed<CalendarSignup | null>(() => {
|
const myAttendance = computed<CalendarSignup | null>(() => {
|
||||||
if (!user.isLoggedIn) return null;
|
if (!userStore.isLoggedIn) return null;
|
||||||
return activeEvent.value.eventSignups.find(
|
return activeEvent.value.eventSignups.find(
|
||||||
(s) => s.member_id === user.user.id
|
(s) => s.member_id === userStore.user.member.member_id
|
||||||
) || null;
|
) || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -78,8 +79,9 @@ async function setAttendance(state: CalendarAttendance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const canEditEvent = computed(() => {
|
const canEditEvent = computed(() => {
|
||||||
if (!user.isLoggedIn) return false;
|
if (!userStore.isLoggedIn) return false;
|
||||||
if (user.user.id == activeEvent.value.creator_id)
|
if (userStore.state !== 'member') return false;
|
||||||
|
if (userStore.user.member.member_id == activeEvent.value.creator_id)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,11 +105,11 @@ const attendanceTab = ref<"Alpha" | "Echo" | "Other">("Alpha");
|
|||||||
const attendanceList = computed<CalendarSignup[]>(() => {
|
const attendanceList = computed<CalendarSignup[]>(() => {
|
||||||
let out: CalendarSignup[] = [];
|
let out: CalendarSignup[] = [];
|
||||||
if (attendanceTab.value === 'Alpha') {
|
if (attendanceTab.value === 'Alpha') {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Alpha Company');
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name === 'Alpha Company');
|
||||||
} else if (attendanceTab.value === 'Echo') {
|
} else if (attendanceTab.value === 'Echo') {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit === 'Echo Company')
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name === 'Echo Company')
|
||||||
} else {
|
} else {
|
||||||
out = activeEvent.value.eventSignups?.filter((s) => s.member_unit != 'Alpha Company' && s.member_unit != 'Echo Company')
|
out = activeEvent.value.eventSignups?.filter((s) => s.unit_name != 'Alpha Company' && s.unit_name != 'Echo Company')
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusOrder: Record<CalendarAttendance, number> = {
|
const statusOrder: Record<CalendarAttendance, number> = {
|
||||||
@@ -125,11 +127,11 @@ const attendanceCountsByGroup = computed(() => {
|
|||||||
const signups = activeEvent.value.eventSignups ?? [];
|
const signups = activeEvent.value.eventSignups ?? [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Alpha: signups.filter(s => s.member_unit === "Alpha Company").length,
|
Alpha: signups.filter(s => s.unit_name === "Alpha Company").length,
|
||||||
Echo: signups.filter(s => s.member_unit === "Echo Company").length,
|
Echo: signups.filter(s => s.unit_name === "Echo Company").length,
|
||||||
Other: signups.filter(s =>
|
Other: signups.filter(s =>
|
||||||
s.member_unit !== "Alpha Company" &&
|
s.unit_name !== "Alpha Company" &&
|
||||||
s.member_unit !== "Echo Company"
|
s.unit_name !== "Echo Company"
|
||||||
).length,
|
).length,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -214,7 +216,7 @@ defineExpose({ forceReload })
|
|||||||
<CircleAlert></CircleAlert> This event has been cancelled
|
<CircleAlert></CircleAlert> This event has been cancelled
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section v-if="isPast && user.isLoggedIn" class="w-full">
|
<section v-if="isPast && userStore.state === 'member'" class="w-full">
|
||||||
<ButtonGroup class="flex w-full">
|
<ButtonGroup class="flex w-full">
|
||||||
<Button variant="outline"
|
<Button variant="outline"
|
||||||
:class="myAttendance?.status === CalendarAttendance.Attending ? 'border-2 border-primary text-primary' : ''"
|
:class="myAttendance?.status === CalendarAttendance.Attending ? 'border-2 border-primary text-primary' : ''"
|
||||||
@@ -240,7 +242,8 @@ defineExpose({ forceReload })
|
|||||||
<MapPin :size="20"></MapPin> {{ activeEvent.location || "Unknown" }}
|
<MapPin :size="20"></MapPin> {{ activeEvent.location || "Unknown" }}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-foreground/80 flex gap-3 items-center">
|
<div class="text-foreground/80 flex gap-3 items-center">
|
||||||
<User :size="20"></User> <MemberCard :member-id="activeEvent.creator_id"></MemberCard>
|
<User :size="20"></User>
|
||||||
|
<MemberCard :member-id="activeEvent.creator_id"></MemberCard>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!-- Description -->
|
<!-- Description -->
|
||||||
@@ -289,4 +292,13 @@ defineExpose({ forceReload })
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="flex justify-center h-full items-center">
|
||||||
|
<button
|
||||||
|
class="absolute top-4 right-4 inline-flex flex-none size-8 items-center justify-center rounded-md border hover:bg-muted/40 transition cursor-pointer z-50"
|
||||||
|
aria-label="Close" @click="emit('close')">
|
||||||
|
<X class="size-4" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Spinner class="size-8"></Spinner>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
import { Check, Search } from "lucide-vue-next"
|
import { Check, Search } from "lucide-vue-next"
|
||||||
import { ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
import { ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { Member, getMembers } from "@/api/member";
|
import { getMembers } from "@/api/member";
|
||||||
|
import { Member } from "@shared/types/member";
|
||||||
import Button from "@/components/ui/button/Button.vue";
|
import Button from "@/components/ui/button/Button.vue";
|
||||||
import {
|
import {
|
||||||
CalendarDate,
|
CalendarDate,
|
||||||
@@ -70,6 +71,8 @@ const { handleSubmit, values, resetForm } = useForm({
|
|||||||
validationSchema: toTypedSchema(loaSchema),
|
validationSchema: toTypedSchema(loaSchema),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const formSubmitted = ref(false);
|
||||||
|
|
||||||
const onSubmit = handleSubmit(async (values) => {
|
const onSubmit = handleSubmit(async (values) => {
|
||||||
console.log(values);
|
console.log(values);
|
||||||
const out: LOARequest = {
|
const out: LOARequest = {
|
||||||
@@ -85,6 +88,7 @@ const onSubmit = handleSubmit(async (values) => {
|
|||||||
await submitLOA(out);
|
await submitLOA(out);
|
||||||
userStore.loadUser();
|
userStore.loadUser();
|
||||||
}
|
}
|
||||||
|
formSubmitted.value = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -101,7 +105,11 @@ onMounted(async () => {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
members.value = await getMembers();
|
if (props.adminMode) {
|
||||||
|
members.value = await getMembers();
|
||||||
|
} else {
|
||||||
|
members.value.push(props.member);
|
||||||
|
}
|
||||||
loaTypes.value = await getLoaTypes();
|
loaTypes.value = await getLoaTypes();
|
||||||
resetForm({ values: { member_id: currentMember.value?.member_id } });
|
resetForm({ values: { member_id: currentMember.value?.member_id } });
|
||||||
});
|
});
|
||||||
@@ -126,6 +134,22 @@ const maxEndDate = computed(() => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const memberFilter = ref('');
|
||||||
|
|
||||||
|
const filteredMembers = computed(() => {
|
||||||
|
const q = memberFilter?.value?.toLowerCase() ?? ""
|
||||||
|
const results: Member[] = []
|
||||||
|
|
||||||
|
for (const m of members.value ?? []) {
|
||||||
|
if (!q || (m.displayName || m.member_name).toLowerCase().includes(q)) {
|
||||||
|
results.push(m)
|
||||||
|
if (results.length >= 50) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -137,7 +161,7 @@ const maxEndDate = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 flex flex-col gap-5">
|
<div class="flex-1 flex flex-col gap-5">
|
||||||
<form @submit="onSubmit" class="flex flex-col gap-2">
|
<form v-if="!formSubmitted" @submit="onSubmit" class="flex flex-col gap-2">
|
||||||
<div class="flex w-full gap-5">
|
<div class="flex w-full gap-5">
|
||||||
<VeeField v-slot="{ field, errors }" name="member_id">
|
<VeeField v-slot="{ field, errors }" name="member_id">
|
||||||
<Field>
|
<Field>
|
||||||
@@ -149,22 +173,24 @@ const maxEndDate = computed(() => {
|
|||||||
<ComboboxInput placeholder="Search members..." class="w-full pl-3"
|
<ComboboxInput placeholder="Search members..." class="w-full pl-3"
|
||||||
:display-value="(id) => {
|
:display-value="(id) => {
|
||||||
const m = members.find(mem => mem.member_id === id)
|
const m = members.find(mem => mem.member_id === id)
|
||||||
return m ? m.member_name : ''
|
return m ? m.displayName || m.member_name : ''
|
||||||
}" />
|
}" @input="memberFilter = $event.target.value" />
|
||||||
</ComboboxAnchor>
|
</ComboboxAnchor>
|
||||||
<ComboboxList class="*:w-64">
|
<ComboboxList class="*:w-64">
|
||||||
<ComboboxEmpty class="text-muted-foreground w-full">No results</ComboboxEmpty>
|
<ComboboxEmpty class="text-muted-foreground w-full">No results</ComboboxEmpty>
|
||||||
<ComboboxGroup>
|
<ComboboxGroup>
|
||||||
<template v-for="member in members" :key="member.member_id">
|
<div class="max-h-80 overflow-y-scroll scrollbar-themed min-w-3xs">
|
||||||
<ComboboxItem :value="member.member_id"
|
<template v-for="member in filteredMembers" :key="member.member_id">
|
||||||
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
<ComboboxItem :value="member.member_id"
|
||||||
{{ member.member_name }}
|
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
||||||
<ComboboxItemIndicator
|
{{ member.displayName || member.member_name }}
|
||||||
class="absolute left-2 inline-flex items-center">
|
<ComboboxItemIndicator
|
||||||
<Check class="h-4 w-4" />
|
class="absolute left-2 inline-flex items-center">
|
||||||
</ComboboxItemIndicator>
|
<Check class="h-4 w-4" />
|
||||||
</ComboboxItem>
|
</ComboboxItemIndicator>
|
||||||
</template>
|
</ComboboxItem>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</ComboboxGroup>
|
</ComboboxGroup>
|
||||||
</ComboboxList>
|
</ComboboxList>
|
||||||
</Combobox>
|
</Combobox>
|
||||||
@@ -272,6 +298,26 @@ const maxEndDate = computed(() => {
|
|||||||
<Button type="submit">Submit</Button>
|
<Button type="submit">Submit</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div v-else class="flex flex-col gap-4 py-8 text-left">
|
||||||
|
<h2 class="text-xl font-semibold">
|
||||||
|
LOA Request Submitted
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p class="max-w-md text-muted-foreground">
|
||||||
|
{{ adminMode ? 'You have successfully submitted a Leave of Absence on behalf of another member.' :
|
||||||
|
`Your Leave
|
||||||
|
of Absence request has been submitted successfully.
|
||||||
|
It will take effect on your selected start date.` }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flex gap-3 mt-4">
|
||||||
|
<Button variant="secondary" @click="formSubmitted = false">
|
||||||
|
Submit another request
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu"
|
} from "@/components/ui/dropdown-menu"
|
||||||
import { Ellipsis } from "lucide-vue-next";
|
import { ChevronDown, ChevronUp, Ellipsis, X } from "lucide-vue-next";
|
||||||
import { cancelLOA, extendLOA, getAllLOAs, getMyLOAs } from "@/api/loa";
|
import { cancelLOA, extendLOA, getAllLOAs, getMyLOAs } from "@/api/loa";
|
||||||
import { onMounted, ref, computed } from "vue";
|
import { onMounted, ref, computed } from "vue";
|
||||||
import { LOARequest } from "@shared/types/loa";
|
import { LOARequest } from "@shared/types/loa";
|
||||||
@@ -33,6 +33,15 @@ import {
|
|||||||
} from "@internationalized/date"
|
} from "@internationalized/date"
|
||||||
import { el } from "@fullcalendar/core/internal-common";
|
import { el } from "@fullcalendar/core/internal-common";
|
||||||
import MemberCard from "../members/MemberCard.vue";
|
import MemberCard from "../members/MemberCard.vue";
|
||||||
|
import {
|
||||||
|
Pagination,
|
||||||
|
PaginationContent,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationItem,
|
||||||
|
PaginationNext,
|
||||||
|
PaginationPrevious,
|
||||||
|
} from '@/components/ui/pagination'
|
||||||
|
import { pagination } from "@shared/types/pagination";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
adminMode?: boolean
|
adminMode?: boolean
|
||||||
@@ -46,9 +55,13 @@ onMounted(async () => {
|
|||||||
|
|
||||||
async function loadLOAs() {
|
async function loadLOAs() {
|
||||||
if (props.adminMode) {
|
if (props.adminMode) {
|
||||||
LOAList.value = await getAllLOAs();
|
let result = await getAllLOAs(pageNum.value, pageSize.value);
|
||||||
|
LOAList.value = result.data;
|
||||||
|
pageData.value = result.pagination;
|
||||||
} else {
|
} else {
|
||||||
LOAList.value = await getMyLOAs();
|
let result = await getMyLOAs(pageNum.value, pageSize.value);
|
||||||
|
LOAList.value = result.data;
|
||||||
|
pageData.value = result.pagination;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +89,6 @@ function loaStatus(loa: LOARequest): "Upcoming" | "Active" | "Overdue" | "Closed
|
|||||||
return "Overdue"; // fallback
|
return "Overdue"; // fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByStartDate(loas: LOARequest[]): LOARequest[] {
|
|
||||||
return [...loas].sort(
|
|
||||||
(a, b) => new Date(b.start_date).getTime() - new Date(a.start_date).getTime()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cancelAndReload(id: number) {
|
async function cancelAndReload(id: number) {
|
||||||
await cancelLOA(id, props.adminMode);
|
await cancelLOA(id, props.adminMode);
|
||||||
await loadLOAs();
|
await loadLOAs();
|
||||||
@@ -104,6 +111,26 @@ async function commitExtend() {
|
|||||||
isExtending.value = false;
|
isExtending.value = false;
|
||||||
await loadLOAs();
|
await loadLOAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expanded = ref<number | null>(null);
|
||||||
|
const hoverID = ref<number | null>(null);
|
||||||
|
|
||||||
|
const pageNum = ref<number>(1);
|
||||||
|
const pageData = ref<pagination>();
|
||||||
|
|
||||||
|
const pageSize = ref<number>(15)
|
||||||
|
const pageSizeOptions = [10, 15, 30]
|
||||||
|
|
||||||
|
function setPageSize(size: number) {
|
||||||
|
pageSize.value = size
|
||||||
|
pageNum.value = 1;
|
||||||
|
loadLOAs();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPage(pagenum: number) {
|
||||||
|
pageNum.value = pagenum;
|
||||||
|
loadLOAs();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -139,51 +166,121 @@ async function commitExtend() {
|
|||||||
<TableHead>Type</TableHead>
|
<TableHead>Type</TableHead>
|
||||||
<TableHead>Start</TableHead>
|
<TableHead>Start</TableHead>
|
||||||
<TableHead>End</TableHead>
|
<TableHead>End</TableHead>
|
||||||
<TableHead class="w-[500px]">Reason</TableHead>
|
<!-- <TableHead class="w-[500px]">Reason</TableHead> -->
|
||||||
<TableHead>Posted on</TableHead>
|
<TableHead>Posted on</TableHead>
|
||||||
<TableHead>Status</TableHead>
|
<TableHead>Status</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow v-for="post in LOAList" :key="post.id" class="hover:bg-muted/50">
|
<template v-for="post in LOAList" :key="post.id">
|
||||||
<TableCell class="font-medium">
|
<TableRow class="hover:bg-muted/50 cursor-pointer" @click="expanded = post.id"
|
||||||
<MemberCard :member-id="post.member_id"></MemberCard>
|
@mouseenter="hoverID = post.id" @mouseleave="hoverID = null" :class="{
|
||||||
</TableCell>
|
'border-b-0': expanded === post.id,
|
||||||
<TableCell>{{ post.type_name }}</TableCell>
|
'bg-muted/50': hoverID === post.id
|
||||||
<TableCell>{{ formatDate(post.start_date) }}</TableCell>
|
}">
|
||||||
<TableCell>{{ post.extended_till ? formatDate(post.extended_till) : formatDate(post.end_date) }}
|
<TableCell class="font-medium">
|
||||||
</TableCell>
|
<MemberCard :member-id="post.member_id"></MemberCard>
|
||||||
<TableCell>{{ post.reason }}</TableCell>
|
</TableCell>
|
||||||
<TableCell>{{ formatDate(post.filed_date) }}</TableCell>
|
<TableCell>{{ post.type_name }}</TableCell>
|
||||||
<TableCell>
|
<TableCell>{{ formatDate(post.start_date) }}</TableCell>
|
||||||
<Badge v-if="loaStatus(post) === 'Upcoming'" class="bg-blue-400">Upcoming</Badge>
|
<TableCell>{{ post.extended_till ? formatDate(post.extended_till) :
|
||||||
<Badge v-else-if="loaStatus(post) === 'Active'" class="bg-green-500">Active</Badge>
|
formatDate(post.end_date) }}
|
||||||
<Badge v-else-if="loaStatus(post) === 'Overdue'" class="bg-yellow-400">Overdue</Badge>
|
</TableCell>
|
||||||
<Badge v-else class="bg-gray-400">Ended</Badge>
|
<!-- <TableCell>{{ post.reason }}</TableCell> -->
|
||||||
</TableCell>
|
<TableCell>{{ formatDate(post.filed_date) }}</TableCell>
|
||||||
<TableCell @click.stop="" class="text-right">
|
<TableCell>
|
||||||
<DropdownMenu>
|
<Badge v-if="loaStatus(post) === 'Upcoming'" class="bg-blue-400">Upcoming</Badge>
|
||||||
<DropdownMenuTrigger class="cursor-pointer">
|
<Badge v-else-if="loaStatus(post) === 'Active'" class="bg-green-500">Active</Badge>
|
||||||
<Ellipsis></Ellipsis>
|
<Badge v-else-if="loaStatus(post) === 'Overdue'" class="bg-yellow-400">Overdue</Badge>
|
||||||
</DropdownMenuTrigger>
|
<Badge v-else class="bg-gray-400">Ended</Badge>
|
||||||
<DropdownMenuContent>
|
</TableCell>
|
||||||
<DropdownMenuItem v-if="!post.closed && props.adminMode"
|
<TableCell @click.stop="" class="text-right">
|
||||||
@click="isExtending = true; targetLOA = post">
|
<DropdownMenu>
|
||||||
Extend
|
<DropdownMenuTrigger class="cursor-pointer">
|
||||||
</DropdownMenuItem>
|
<Button variant="ghost">
|
||||||
<DropdownMenuItem v-if="!post.closed" :variant="'destructive'"
|
<Ellipsis class="size-6"></Ellipsis>
|
||||||
@click="cancelAndReload(post.id)">End
|
</Button>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuTrigger>
|
||||||
<!-- Fallback: no actions available -->
|
<DropdownMenuContent>
|
||||||
<p v-if="post.closed || (!props.adminMode && post.closed)" class="p-2 text-center text-sm">
|
<DropdownMenuItem v-if="!post.closed && props.adminMode"
|
||||||
No actions
|
@click="isExtending = true; targetLOA = post">
|
||||||
</p>
|
Extend
|
||||||
</DropdownMenuContent>
|
</DropdownMenuItem>
|
||||||
</DropdownMenu>
|
<DropdownMenuItem v-if="!post.closed" :variant="'destructive'"
|
||||||
</TableCell>
|
@click="cancelAndReload(post.id)">{{ loaStatus(post) === 'Upcoming' ?
|
||||||
</TableRow>
|
'Cancel' :
|
||||||
|
'End' }}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<!-- Fallback: no actions available -->
|
||||||
|
<p v-if="post.closed || (!props.adminMode && post.closed)"
|
||||||
|
class="p-2 text-center text-sm">
|
||||||
|
No actions
|
||||||
|
</p>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Button v-if="expanded === post.id" @click.stop="expanded = null" variant="ghost">
|
||||||
|
<ChevronUp class="size-6" />
|
||||||
|
</Button>
|
||||||
|
<Button v-else @click.stop="expanded = post.id" variant="ghost">
|
||||||
|
<ChevronDown class="size-6" />
|
||||||
|
</Button>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow v-if="expanded === post.id" @mouseenter="hoverID = post.id"
|
||||||
|
@mouseleave="hoverID = null" :class="{ 'bg-muted/50 border-t-0': hoverID === post.id }">
|
||||||
|
<TableCell :colspan="8" class="p-0">
|
||||||
|
<div class="w-full p-3 mb-6 space-y-3">
|
||||||
|
<div class="flex justify-between items-start gap-4">
|
||||||
|
<div class="flex-1">
|
||||||
|
<!-- Title -->
|
||||||
|
<p class="text-md font-semibold text-foreground">
|
||||||
|
Reason
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<p
|
||||||
|
class="mt-1 text-md whitespace-pre-wrap leading-relaxed text-muted-foreground">
|
||||||
|
{{ post.reason }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</template>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
<div class="mt-5 flex justify-between">
|
||||||
|
<div></div>
|
||||||
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
|
<PaginationContent v-slot="{ items }">
|
||||||
|
<PaginationPrevious />
|
||||||
|
<template v-for="(item, index) in items" :key="index">
|
||||||
|
<PaginationItem v-if="item.type === 'page'" :value="item.value"
|
||||||
|
:is-active="item.value === page">
|
||||||
|
{{ item.value }}
|
||||||
|
</PaginationItem>
|
||||||
|
</template>
|
||||||
|
<PaginationEllipsis :index="4" />
|
||||||
|
<PaginationNext />
|
||||||
|
</PaginationContent>
|
||||||
|
</Pagination>
|
||||||
|
<div class="flex items-center gap-3 text-sm">
|
||||||
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
|
|
||||||
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
|
class="px-2 py-1 rounded transition-colors" :class="{
|
||||||
|
'bg-muted font-semibold': pageSize === size,
|
||||||
|
'hover:bg-muted/50': pageSize !== size
|
||||||
|
}">
|
||||||
|
{{ size }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import PopoverContent from '../ui/popover/PopoverContent.vue';
|
|||||||
import { cn } from '@/lib/utils.js'
|
import { cn } from '@/lib/utils.js'
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
import { format } from 'path';
|
import { format } from 'path';
|
||||||
|
import Spinner from '../ui/spinner/Spinner.vue';
|
||||||
|
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
@@ -91,8 +92,8 @@ function formatDate(date: Date): string {
|
|||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent class="w-72 p-0 overflow-hidden">
|
<PopoverContent class="w-72 p-0 overflow-hidden">
|
||||||
<!-- Loading -->
|
<!-- Loading -->
|
||||||
<div v-if="loadingFull" class="p-4 text-sm text-muted-foreground">
|
<div v-if="loadingFull" class="p-4 text-sm text-muted-foreground mx-auto flex justify-center my-5">
|
||||||
Loading profile…
|
<Spinner></Spinner>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Profile -->
|
<!-- Profile -->
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { trainingReportSchema, courseEventAttendeeSchema } from '@shared/schemas
|
|||||||
import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails } from '@shared/types/course'
|
import { Course, CourseAttendee, CourseAttendeeRole, CourseEventDetails } from '@shared/types/course'
|
||||||
import { useForm, useFieldArray, FieldArray as VeeFieldArray, ErrorMessage, Field as VeeField } from 'vee-validate'
|
import { useForm, useFieldArray, FieldArray as VeeFieldArray, ErrorMessage, Field as VeeField } from 'vee-validate'
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { getAllAttendeeRoles, getAllTrainings, postTrainingReport } from '@/api/trainingReport'
|
import { getAllAttendeeRoles, getAllTrainings, postTrainingReport } from '@/api/trainingReport'
|
||||||
import { getMembers, Member } from '@/api/member'
|
import { getAllLightMembers, getLightMembers, getMembers } from '@/api/member'
|
||||||
|
import { Member, MemberLight } from '@shared/types/member'
|
||||||
|
|
||||||
import FieldGroup from '../ui/field/FieldGroup.vue'
|
import FieldGroup from '../ui/field/FieldGroup.vue'
|
||||||
import Field from '../ui/field/Field.vue'
|
import Field from '../ui/field/Field.vue'
|
||||||
@@ -13,12 +14,17 @@ import FieldLabel from '../ui/field/FieldLabel.vue'
|
|||||||
import FieldError from '../ui/field/FieldError.vue'
|
import FieldError from '../ui/field/FieldError.vue'
|
||||||
import Button from '../ui/button/Button.vue'
|
import Button from '../ui/button/Button.vue'
|
||||||
import Textarea from '../ui/textarea/Textarea.vue'
|
import Textarea from '../ui/textarea/Textarea.vue'
|
||||||
import { Plus, X } from 'lucide-vue-next';
|
import { Check, Plus, X } from 'lucide-vue-next';
|
||||||
import FieldSet from '../ui/field/FieldSet.vue'
|
import FieldSet from '../ui/field/FieldSet.vue'
|
||||||
import FieldLegend from '../ui/field/FieldLegend.vue'
|
import FieldLegend from '../ui/field/FieldLegend.vue'
|
||||||
import FieldDescription from '../ui/field/FieldDescription.vue'
|
import FieldDescription from '../ui/field/FieldDescription.vue'
|
||||||
import Checkbox from '../ui/checkbox/Checkbox.vue'
|
import Checkbox from '../ui/checkbox/Checkbox.vue'
|
||||||
import { configure } from 'vee-validate'
|
import { configure } from 'vee-validate'
|
||||||
|
import { ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
||||||
|
import Popover from "@/components/ui/popover/Popover.vue";
|
||||||
|
import PopoverTrigger from "@/components/ui/popover/PopoverTrigger.vue";
|
||||||
|
import PopoverContent from "@/components/ui/popover/PopoverContent.vue";
|
||||||
|
import Combobox from '../ui/combobox/Combobox.vue'
|
||||||
|
|
||||||
|
|
||||||
const { handleSubmit, resetForm, errors, values, setFieldValue } = useForm({
|
const { handleSubmit, resetForm, errors, values, setFieldValue } = useForm({
|
||||||
@@ -79,16 +85,44 @@ const { remove, push, fields } = useFieldArray('attendees');
|
|||||||
const selectedCourse = computed<Course | undefined>(() => { return trainings.value?.find(c => c.id == values.course_id) })
|
const selectedCourse = computed<Course | undefined>(() => { return trainings.value?.find(c => c.id == values.course_id) })
|
||||||
|
|
||||||
const trainings = ref<Course[] | null>(null);
|
const trainings = ref<Course[] | null>(null);
|
||||||
const members = ref<Member[] | null>(null);
|
const members = ref<MemberLight[] | null>(null);
|
||||||
const eventRoles = ref<CourseAttendeeRole[] | null>(null);
|
const eventRoles = ref<CourseAttendeeRole[] | null>(null);
|
||||||
|
|
||||||
const emit = defineEmits(['submit'])
|
const emit = defineEmits(['submit'])
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
trainings.value = await getAllTrainings();
|
trainings.value = await getAllTrainings();
|
||||||
members.value = await getMembers();
|
members.value = await getAllLightMembers();
|
||||||
eventRoles.value = await getAllAttendeeRoles();
|
eventRoles.value = await getAllAttendeeRoles();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const selectCourse = ref(false);
|
||||||
|
const openMap = reactive<Record<string, boolean>>({})
|
||||||
|
|
||||||
|
const memberMap = computed(() =>
|
||||||
|
Object.fromEntries(
|
||||||
|
members.value?.map(m => [m.id, m.displayName || m.username]) ?? []
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const memberSearch = ref('')
|
||||||
|
|
||||||
|
const MAX_RESULTS = 50
|
||||||
|
|
||||||
|
const filteredMembers = computed(() => {
|
||||||
|
const q = memberSearch?.value?.toLowerCase() ?? ""
|
||||||
|
const results: MemberLight[] = []
|
||||||
|
|
||||||
|
for (const m of members.value ?? []) {
|
||||||
|
if (!q || (m.displayName || m.username).toLowerCase().includes(q)) {
|
||||||
|
results.push(m)
|
||||||
|
if (results.length >= MAX_RESULTS) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<form id="trainingForm" @submit.prevent="submitForm" class="flex flex-col gap-5">
|
<form id="trainingForm" @submit.prevent="submitForm" class="flex flex-col gap-5">
|
||||||
@@ -99,13 +133,37 @@ onMounted(async () => {
|
|||||||
<VeeField v-slot="{ field, errors }" name="course_id">
|
<VeeField v-slot="{ field, errors }" name="course_id">
|
||||||
<Field :data-invalid="!!errors.length">
|
<Field :data-invalid="!!errors.length">
|
||||||
<FieldLabel class="scroll-m-20 text-lg tracking-tight">Training Course</FieldLabel>
|
<FieldLabel class="scroll-m-20 text-lg tracking-tight">Training Course</FieldLabel>
|
||||||
<select v-bind="field"
|
<Combobox :model-value="field.value" @update:open="selectCourse = $event"
|
||||||
class="h-9 border rounded p-2 w-auto focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] bg-background outline-none">
|
:open="selectCourse" @update:model-value="(v) => {
|
||||||
<option value="" disabled>Select a course</option>
|
field.onChange(v);
|
||||||
<option v-for="course in trainings" :key="course.id" :value="course.id">
|
selectCourse = false
|
||||||
{{ course.name }}
|
}" class="w-full">
|
||||||
</option>
|
<ComboboxAnchor class="w-full">
|
||||||
</select>
|
<ComboboxInput @focus="selectCourse = true" placeholder="Search courses..."
|
||||||
|
class="w-full pl-3" :display-value="(id) => {
|
||||||
|
const c = trainings?.find(t => t.id === id)
|
||||||
|
return c ? c.name : '';
|
||||||
|
}" />
|
||||||
|
</ComboboxAnchor>
|
||||||
|
|
||||||
|
<ComboboxList class="w-full">
|
||||||
|
<ComboboxEmpty class="text-muted-foreground w-full">No results</ComboboxEmpty>
|
||||||
|
<ComboboxGroup>
|
||||||
|
<div class="max-h-80 overflow-y-scroll scrollbar-themed min-w-md">
|
||||||
|
<template v-for="course in trainings" :key="course.id">
|
||||||
|
<ComboboxItem :value="course.id"
|
||||||
|
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
||||||
|
{{ course.name }}
|
||||||
|
<ComboboxItemIndicator
|
||||||
|
class="absolute left-2 inline-flex items-center">
|
||||||
|
<Check class="h-4 w-4" />
|
||||||
|
</ComboboxItemIndicator>
|
||||||
|
</ComboboxItem>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</ComboboxGroup>
|
||||||
|
</ComboboxList>
|
||||||
|
</Combobox>
|
||||||
<div class="h-4">
|
<div class="h-4">
|
||||||
<FieldError v-if="errors.length" :errors="errors" />
|
<FieldError v-if="errors.length" :errors="errors" />
|
||||||
</div>
|
</div>
|
||||||
@@ -113,6 +171,7 @@ onMounted(async () => {
|
|||||||
</VeeField>
|
</VeeField>
|
||||||
</FieldGroup>
|
</FieldGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-[150px]">
|
<div class="w-[150px]">
|
||||||
<FieldGroup>
|
<FieldGroup>
|
||||||
<VeeField v-slot="{ field, errors }" name="event_date">
|
<VeeField v-slot="{ field, errors }" name="event_date">
|
||||||
@@ -180,13 +239,38 @@ onMounted(async () => {
|
|||||||
<!-- Member Select -->
|
<!-- Member Select -->
|
||||||
<VeeField :name="`attendees[${index}].attendee_id`" v-slot="{ field: f, errors: e }">
|
<VeeField :name="`attendees[${index}].attendee_id`" v-slot="{ field: f, errors: e }">
|
||||||
<div>
|
<div>
|
||||||
<select v-bind="f"
|
<Combobox :model-value="f.value"
|
||||||
class="border rounded p-2 w-full focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] bg-background outline-none">
|
@update:open="openMap['member-' + field.key] = $event"
|
||||||
<option value="">Select member...</option>
|
:open="openMap['member-' + field.key]" @update:model-value="(v) => {
|
||||||
<option v-for="m in members" :key="m.member_id" :value="m.member_id">
|
f.onChange(v);
|
||||||
{{ m.member_name }}
|
openMap['member-' + field.key] = false
|
||||||
</option>
|
}" class="w-full">
|
||||||
</select>
|
<ComboboxAnchor class="w-full">
|
||||||
|
<ComboboxInput
|
||||||
|
@focus="() => { openMap['member-' + field.key] = true; memberSearch = memberMap[f.value] }"
|
||||||
|
placeholder="Search members..." class="w-full pl-3"
|
||||||
|
:display-value="(id) => memberMap[id] || ''"
|
||||||
|
@input="memberSearch = $event.target.value" />
|
||||||
|
</ComboboxAnchor>
|
||||||
|
<ComboboxList class="w-full">
|
||||||
|
<ComboboxEmpty class="text-muted-foreground w-full">No results
|
||||||
|
</ComboboxEmpty>
|
||||||
|
<ComboboxGroup>
|
||||||
|
<div class="max-h-80 overflow-y-scroll scrollbar-themed min-w-3xs">
|
||||||
|
<template v-for="m in filteredMembers" :key="m.id">
|
||||||
|
<ComboboxItem :value="m.id"
|
||||||
|
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
||||||
|
{{ m.displayName || m.username }}
|
||||||
|
<ComboboxItemIndicator
|
||||||
|
class="absolute left-2 inline-flex items-center">
|
||||||
|
<Check class="h-4 w-4" />
|
||||||
|
</ComboboxItemIndicator>
|
||||||
|
</ComboboxItem>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</ComboboxGroup>
|
||||||
|
</ComboboxList>
|
||||||
|
</Combobox>
|
||||||
<div class="h-4">
|
<div class="h-4">
|
||||||
<FieldError v-if="e.length" :errors="e" />
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
</div>
|
</div>
|
||||||
@@ -196,13 +280,42 @@ onMounted(async () => {
|
|||||||
<!-- Role Select -->
|
<!-- Role Select -->
|
||||||
<VeeField :name="`attendees[${index}].attendee_role_id`" v-slot="{ field: f, errors: e }">
|
<VeeField :name="`attendees[${index}].attendee_role_id`" v-slot="{ field: f, errors: e }">
|
||||||
<div>
|
<div>
|
||||||
<select v-bind="f"
|
<Combobox :model-value="f.value"
|
||||||
class="border rounded p-2 w-full focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] bg-background outline-none">
|
@update:open="openMap['role-' + field.key] = $event"
|
||||||
<option value="">Select role...</option>
|
:open="openMap['role-' + field.key]" @update:model-value="(v) => {
|
||||||
<option v-for="r in eventRoles" :key="r.id" :value="r.id">
|
f.onChange(v);
|
||||||
{{ r.name }}
|
openMap['role-' + field.key] = false
|
||||||
</option>
|
}" class="w-full">
|
||||||
</select>
|
<ComboboxAnchor class="w-full">
|
||||||
|
<ComboboxInput @focus="openMap['role-' + field.key] = true"
|
||||||
|
placeholder="Search roles..." class="w-full pl-3" :display-value="(id) => {
|
||||||
|
const er = eventRoles?.find(t => t.id === id)
|
||||||
|
return er?.name;
|
||||||
|
}" />
|
||||||
|
</ComboboxAnchor>
|
||||||
|
<ComboboxList class="w-full">
|
||||||
|
<ComboboxEmpty class="text-muted-foreground w-full">No results
|
||||||
|
</ComboboxEmpty>
|
||||||
|
<ComboboxGroup>
|
||||||
|
<div class="max-h-80 overflow-y-scroll scrollbar-themed min-w-3xs">
|
||||||
|
<template v-for="r in eventRoles" :key="r.id">
|
||||||
|
<ComboboxItem :value="r.id"
|
||||||
|
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
||||||
|
<div class="flex justify-between w-full gap-8">
|
||||||
|
<p>{{ r.name }}</p>
|
||||||
|
<p class="text-muted-foreground">{{ r.description }}</p>
|
||||||
|
</div>
|
||||||
|
<ComboboxItemIndicator
|
||||||
|
class="absolute left-2 inline-flex items-center">
|
||||||
|
<Check class="h-4 w-4" />
|
||||||
|
</ComboboxItemIndicator>
|
||||||
|
</ComboboxItem>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</ComboboxGroup>
|
||||||
|
</ComboboxList>
|
||||||
|
</Combobox>
|
||||||
|
|
||||||
<div class="h-4">
|
<div class="h-4">
|
||||||
<FieldError v-if="e.length" :errors="e" />
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const buttonVariants = cva(
|
|||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default:
|
default:
|
||||||
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/70",
|
||||||
destructive:
|
destructive:
|
||||||
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||||
outline:
|
outline:
|
||||||
|
|||||||
33
ui/src/components/ui/pagination/Pagination.vue
Normal file
33
ui/src/components/ui/pagination/Pagination.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { PaginationRoot, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
page: { type: Number, required: false },
|
||||||
|
defaultPage: { type: Number, required: false },
|
||||||
|
itemsPerPage: { type: Number, required: true },
|
||||||
|
total: { type: Number, required: false },
|
||||||
|
siblingCount: { type: Number, required: false },
|
||||||
|
disabled: { type: Boolean, required: false },
|
||||||
|
showEdges: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:page"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationRoot
|
||||||
|
v-slot="slotProps"
|
||||||
|
data-slot="pagination"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="cn('mx-auto flex w-full justify-center', props.class)"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</PaginationRoot>
|
||||||
|
</template>
|
||||||
24
ui/src/components/ui/pagination/PaginationContent.vue
Normal file
24
ui/src/components/ui/pagination/PaginationContent.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { PaginationList } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationList
|
||||||
|
v-slot="slotProps"
|
||||||
|
data-slot="pagination-content"
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="cn('flex flex-row items-center gap-1', props.class)"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</PaginationList>
|
||||||
|
</template>
|
||||||
27
ui/src/components/ui/pagination/PaginationEllipsis.vue
Normal file
27
ui/src/components/ui/pagination/PaginationEllipsis.vue
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { MoreHorizontal } from "lucide-vue-next";
|
||||||
|
import { PaginationEllipsis } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationEllipsis
|
||||||
|
data-slot="pagination-ellipsis"
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="cn('flex size-9 items-center justify-center', props.class)"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<MoreHorizontal class="size-4" />
|
||||||
|
<span class="sr-only">More pages</span>
|
||||||
|
</slot>
|
||||||
|
</PaginationEllipsis>
|
||||||
|
</template>
|
||||||
36
ui/src/components/ui/pagination/PaginationFirst.vue
Normal file
36
ui/src/components/ui/pagination/PaginationFirst.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronLeftIcon } from "lucide-vue-next";
|
||||||
|
import { PaginationFirst, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
size: { type: null, required: false, default: "default" },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "size");
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationFirst
|
||||||
|
data-slot="pagination-first"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
buttonVariants({ variant: 'ghost', size }),
|
||||||
|
'gap-1 px-2.5 sm:pr-2.5',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
v-bind="forwarded"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<ChevronLeftIcon />
|
||||||
|
<span class="hidden sm:block">First</span>
|
||||||
|
</slot>
|
||||||
|
</PaginationFirst>
|
||||||
|
</template>
|
||||||
35
ui/src/components/ui/pagination/PaginationItem.vue
Normal file
35
ui/src/components/ui/pagination/PaginationItem.vue
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { PaginationListItem } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
value: { type: Number, required: true },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
size: { type: null, required: false, default: "icon" },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
isActive: { type: Boolean, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "size", "isActive");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationListItem
|
||||||
|
data-slot="pagination-item"
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
buttonVariants({
|
||||||
|
variant: isActive ? 'outline' : 'ghost',
|
||||||
|
size,
|
||||||
|
}),
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</PaginationListItem>
|
||||||
|
</template>
|
||||||
36
ui/src/components/ui/pagination/PaginationLast.vue
Normal file
36
ui/src/components/ui/pagination/PaginationLast.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronRightIcon } from "lucide-vue-next";
|
||||||
|
import { PaginationLast, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
size: { type: null, required: false, default: "default" },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "size");
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationLast
|
||||||
|
data-slot="pagination-last"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
buttonVariants({ variant: 'ghost', size }),
|
||||||
|
'gap-1 px-2.5 sm:pr-2.5',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
v-bind="forwarded"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<span class="hidden sm:block">Last</span>
|
||||||
|
<ChevronRightIcon />
|
||||||
|
</slot>
|
||||||
|
</PaginationLast>
|
||||||
|
</template>
|
||||||
36
ui/src/components/ui/pagination/PaginationNext.vue
Normal file
36
ui/src/components/ui/pagination/PaginationNext.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronRightIcon } from "lucide-vue-next";
|
||||||
|
import { PaginationNext, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
size: { type: null, required: false, default: "default" },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "size");
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationNext
|
||||||
|
data-slot="pagination-next"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
buttonVariants({ variant: 'ghost', size }),
|
||||||
|
'gap-1 px-2.5 sm:pr-2.5',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
v-bind="forwarded"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<span class="hidden sm:block">Next</span>
|
||||||
|
<ChevronRightIcon />
|
||||||
|
</slot>
|
||||||
|
</PaginationNext>
|
||||||
|
</template>
|
||||||
36
ui/src/components/ui/pagination/PaginationPrevious.vue
Normal file
36
ui/src/components/ui/pagination/PaginationPrevious.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronLeftIcon } from "lucide-vue-next";
|
||||||
|
import { PaginationPrev, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { buttonVariants } from '@/components/ui/button';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
size: { type: null, required: false, default: "default" },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "size");
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationPrev
|
||||||
|
data-slot="pagination-previous"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
buttonVariants({ variant: 'ghost', size }),
|
||||||
|
'gap-1 px-2.5 sm:pr-2.5',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
v-bind="forwarded"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<ChevronLeftIcon />
|
||||||
|
<span class="hidden sm:block">Previous</span>
|
||||||
|
</slot>
|
||||||
|
</PaginationPrev>
|
||||||
|
</template>
|
||||||
8
ui/src/components/ui/pagination/index.js
Normal file
8
ui/src/components/ui/pagination/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export { default as Pagination } from "./Pagination.vue";
|
||||||
|
export { default as PaginationContent } from "./PaginationContent.vue";
|
||||||
|
export { default as PaginationEllipsis } from "./PaginationEllipsis.vue";
|
||||||
|
export { default as PaginationFirst } from "./PaginationFirst.vue";
|
||||||
|
export { default as PaginationItem } from "./PaginationItem.vue";
|
||||||
|
export { default as PaginationLast } from "./PaginationLast.vue";
|
||||||
|
export { default as PaginationNext } from "./PaginationNext.vue";
|
||||||
|
export { default as PaginationPrevious } from "./PaginationPrevious.vue";
|
||||||
@@ -6,11 +6,11 @@ export function useAuth() {
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// Account status control
|
// Account status control
|
||||||
const accountStatus = computed(() => userStore.state);
|
const accountStatus = computed(() => userStore.user?.state);
|
||||||
|
|
||||||
// RBAC
|
// RBAC
|
||||||
const roles = computed<string[]>(() => {
|
const roles = computed<string[]>(() => {
|
||||||
return userStore.user?.roleData?.map((r: Role) => r.name) ?? [];
|
return userStore.user?.roles?.map((r: Role) => r.name) ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
function isDev() {
|
function isDev() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Button from '@/components/ui/button/Button.vue';
|
|||||||
import { CheckIcon, XIcon } from 'lucide-vue-next';
|
import { CheckIcon, XIcon } from 'lucide-vue-next';
|
||||||
import Unauthorized from './Unauthorized.vue';
|
import Unauthorized from './Unauthorized.vue';
|
||||||
import { ApplicationData, ApplicationFull, ApplicationStatus, CommentRow } from '@shared/types/application';
|
import { ApplicationData, ApplicationFull, ApplicationStatus, CommentRow } from '@shared/types/application';
|
||||||
|
import Spinner from '@/components/ui/spinner/Spinner.vue';
|
||||||
|
|
||||||
const appData = ref<ApplicationData>(null);
|
const appData = ref<ApplicationData>(null);
|
||||||
const appID = ref<number | null>(null);
|
const appID = ref<number | null>(null);
|
||||||
@@ -105,17 +106,26 @@ async function postApp(appData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleApprove(id) {
|
async function handleApprove(id) {
|
||||||
console.log("hi");
|
try {
|
||||||
await approveApplication(id);
|
await approveApplication(id);
|
||||||
|
loadData(await loadApplication(Number(route.params.id), true))
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDeny(id) {
|
async function handleDeny(id) {
|
||||||
await denyApplication(id);
|
try {
|
||||||
|
await denyApplication(id);
|
||||||
|
loadData(await loadApplication(Number(route.params.id), true))
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="!loading" class="w-full h-20">
|
<div v-if="!loading" class="w-full">
|
||||||
<div v-if="unauthorized" class="flex justify-center w-full my-10">
|
<div v-if="unauthorized" class="flex justify-center w-full my-10">
|
||||||
You do not have permission to view this application.
|
You do not have permission to view this application.
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +134,7 @@ async function handleDeny(id) {
|
|||||||
<!-- Application header -->
|
<!-- Application header -->
|
||||||
<div>
|
<div>
|
||||||
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight">{{ member_name }}</h3>
|
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight">{{ member_name }}</h3>
|
||||||
<p class="text-muted-foreground">Submitted: {{ submitDate.toLocaleString("en-US", {
|
<p class="text-muted-foreground">Submitted: {{ submitDate?.toLocaleString("en-US", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
@@ -164,12 +174,15 @@ async function handleDeny(id) {
|
|||||||
</ApplicationForm>
|
</ApplicationForm>
|
||||||
<div v-if="!newApp" class="pb-15">
|
<div v-if="!newApp" class="pb-15">
|
||||||
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
|
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
|
||||||
<ApplicationChat :messages="chatData" @post="postComment" @post-internal="postCommentInternal" :admin-mode="finalMode === 'view-recruiter'">
|
<ApplicationChat :messages="chatData" @post="postComment" @post-internal="postCommentInternal"
|
||||||
|
:admin-mode="finalMode === 'view-recruiter'">
|
||||||
</ApplicationChat>
|
</ApplicationChat>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- TODO: Implement some kinda loading screen -->
|
<!-- TODO: Implement some kinda loading screen -->
|
||||||
<div v-else class="flex items-center justify-center h-full">Loading</div>
|
<div v-else class="flex items-center justify-center h-full">
|
||||||
|
<Spinner class="size-8"/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -49,15 +49,8 @@ const dialogRef = ref<any>(null)
|
|||||||
// NEW: handle day/time slot clicks to start creating an event
|
// NEW: handle day/time slot clicks to start creating an event
|
||||||
function onDateClick(arg: { dateStr: string }) {
|
function onDateClick(arg: { dateStr: string }) {
|
||||||
if (!userStore.isLoggedIn) return;
|
if (!userStore.isLoggedIn) return;
|
||||||
|
if (userStore.state !== 'member') return;
|
||||||
dialogRef.value?.openDialog(arg.dateStr);
|
dialogRef.value?.openDialog(arg.dateStr);
|
||||||
// For now, just open the panel with a draft payload.
|
|
||||||
// activeEvent.value = {
|
|
||||||
// id: '__draft__',
|
|
||||||
// title: 'New event',
|
|
||||||
// start: arg.dateStr,
|
|
||||||
// extendedProps: { draft: true }
|
|
||||||
// }
|
|
||||||
// panelOpen.value = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const calendarOptions = ref({
|
const calendarOptions = ref({
|
||||||
@@ -203,7 +196,7 @@ onMounted(() => {
|
|||||||
@click="goToday">
|
@click="goToday">
|
||||||
Today
|
Today
|
||||||
</button>
|
</button>
|
||||||
<button v-if="userStore.isLoggedIn"
|
<button v-if="userStore.isLoggedIn && userStore.state === 'member'"
|
||||||
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"
|
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">
|
@click="onCreateEvent">
|
||||||
<Plus class="h-4 w-4" />
|
<Plus class="h-4 w-4" />
|
||||||
@@ -217,7 +210,7 @@ onMounted(() => {
|
|||||||
<aside v-if="panelOpen"
|
<aside v-if="panelOpen"
|
||||||
class="3xl:w-lg 2xl:w-md border-l bg-card text-foreground flex flex-col overflow-auto scrollbar-themed"
|
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' }">
|
:style="{ height: 'calc(100vh - 61px)', position: 'sticky', top: '64px' }">
|
||||||
<ViewCalendarEvent ref="eventViewRef" @close="() => { router.push('/calendar'); }"
|
<ViewCalendarEvent ref="eventViewRef" :key="currentEventID" @close="() => { router.push('/calendar'); }"
|
||||||
@reload="loadEvents()" @edit="(val) => { dialogRef.openDialog(null, 'edit', val) }">
|
@reload="loadEvents()" @edit="(val) => { dialogRef.openDialog(null, 'edit', val) }">
|
||||||
</ViewCalendarEvent>
|
</ViewCalendarEvent>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { getWelcomeMessage } from '@/api/docs';
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -8,23 +10,126 @@ const router = useRouter()
|
|||||||
const user = useUserStore();
|
const user = useUserStore();
|
||||||
|
|
||||||
function goToApplication() {
|
function goToApplication() {
|
||||||
router.push('/apply') // change to your form route
|
router.push('/join') // change to your form route
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (user.state == 'member') {
|
||||||
|
let policy = await getWelcomeMessage() as any;
|
||||||
|
welcomeRef.value.innerHTML = policy;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const welcomeRef = ref<HTMLElement>(null);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div v-if="user.state == 'guest'" class="flex flex-col items-center justify-center">
|
<div v-if="user.state == 'member'" class="mt-10">
|
||||||
<h1 class="text-4xl font-bold mb-4">Welcome to the 17th</h1>
|
<div ref="welcomeRef" class="bookstack-container">
|
||||||
<p class="text-neutral-400 mb-8 max-w-md">
|
<!-- bookstack -->
|
||||||
To join our unit, please fill out an application to continue.
|
</div>
|
||||||
</p>
|
|
||||||
<Button @click="goToApplication" class="px-6 py-3 text-lg">
|
|
||||||
Begin Application
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else class="text-foreground px-6 py-12 selection:bg-primary/10">
|
||||||
HOMEPAGEEEEEEEEEEEEEEEEEEE
|
<div class="max-w-5xl mx-auto space-y-8">
|
||||||
|
|
||||||
|
<header class="space-y-4">
|
||||||
|
<div class="flex flex-col md:flex-row md:items-end justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<h1 class="text-4xl font-semibold tracking-tight">17th Ranger Battalion</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="h-px bg-border w-full"></div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 lg:grid-cols-12 gap-12">
|
||||||
|
|
||||||
|
<div class="lg:col-span-7 space-y-6">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<h2 class="text-sm font-medium uppercase tracking-wider text-primary">Unit Philosophy</h2>
|
||||||
|
<p class="text-lg leading-relaxed font-normal">
|
||||||
|
The 17th RBN emphasizes high-skill gameplay through real-world tactics, stripped of
|
||||||
|
traditional military formalities. We prioritize effective coordination over enforced
|
||||||
|
etiquette.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted-foreground leading-relaxed">
|
||||||
|
Our "Real Life First" mindset ensures participation remains a hobby, not a second job. With
|
||||||
|
a consistent roster of 40–50 members for Saturday operations, we focus on effective
|
||||||
|
coordination and mission success without the requirement of "Yes sir, no sir" protocols.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap items-center gap-6 pt-4">
|
||||||
|
<Button size="lg" @click="goToApplication" class="font-medium">
|
||||||
|
Begin Application
|
||||||
|
</Button>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="text-xs uppercase tracking-tighter text-muted-foreground">Age
|
||||||
|
Requirement</span>
|
||||||
|
<span class="text-sm font-medium">18+</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lg:col-span-5 space-y-8">
|
||||||
|
<section class="space-y-3">
|
||||||
|
<h3 class="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
|
||||||
|
Operational Schedule</h3>
|
||||||
|
<div class="rounded-lg border bg-card p-4 shadow-sm">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<span class="text-sm font-medium">Main Operation</span>
|
||||||
|
<span class="text-sm font-mono text-primary">Sat 19:00 CST</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="space-y-4">
|
||||||
|
<h3 class="text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground">
|
||||||
|
Force Structure
|
||||||
|
</h3>
|
||||||
|
<ul class="space-y-3">
|
||||||
|
<li class="flex items-start gap-4">
|
||||||
|
<span class="h-1.5 w-1.5 rounded-full bg-primary mt-2 shrink-0"></span>
|
||||||
|
<div class="space-y-1">
|
||||||
|
<p class="text-sm font-medium leading-none">Alpha Company</p>
|
||||||
|
<p class="text-[13px] text-muted-foreground leading-relaxed">
|
||||||
|
Rifleman, Medic, CLS, Anti-Tank, RTO, Leadership
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="flex items-start gap-4">
|
||||||
|
<span class="h-1.5 w-1.5 rounded-full bg-primary mt-2 shrink-0"></span>
|
||||||
|
<div class="space-y-1">
|
||||||
|
<p class="text-sm font-medium leading-none">Echo Company</p>
|
||||||
|
<p class="text-[13px] text-muted-foreground leading-relaxed">
|
||||||
|
Logistics, CAS Pilot, Armor, Artillery, JTAC, Forward Observer
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p class="text-[12px] text-muted-foreground/70 border-t pt-2 border-border">
|
||||||
|
Roles are fluid; specialization or weekly rotation is supported.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="space-y-4">
|
||||||
|
<div class="relative rounded-xl border bg-card shadow-sm overflow-hidden">
|
||||||
|
<div class="aspect-video">
|
||||||
|
<iframe class="w-full h-full"
|
||||||
|
src="https://www.youtube.com/embed/61L397HwmrU?si=oY9qf6vFv6hXo6Fk&controls=1&mute=1&start=102&end=152"
|
||||||
|
title="YouTube video player" frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||||
|
allowfullscreen>
|
||||||
|
</iframe>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import { restartApplication } from '@/api/application';
|
|||||||
|
|
||||||
function goToLogin() {
|
function goToLogin() {
|
||||||
const redirectUrl = encodeURIComponent(window.location.origin + '/join')
|
const redirectUrl = encodeURIComponent(window.location.origin + '/join')
|
||||||
window.location.href = `https://aj17thdevapi.nexuszone.net/login?redirect=${redirectUrl}`;
|
//@ts-ignore
|
||||||
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
window.location.href = `${addr}/login?redirect=${redirectUrl}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let userStore = useUserStore();
|
let userStore = useUserStore();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from '@/components/ui/table'
|
} from '@/components/ui/table'
|
||||||
import Button from '@/components/ui/button/Button.vue';
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { CheckIcon, XIcon } from 'lucide-vue-next';
|
import { CheckIcon, XIcon } from 'lucide-vue-next';
|
||||||
import Application from './Application.vue';
|
import Application from './Application.vue';
|
||||||
@@ -52,36 +52,26 @@ function formatExact(iso) {
|
|||||||
return isNaN(d) ? '' : exactFmt.format(d)
|
return isNaN(d) ? '' : exactFmt.format(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleApprove(id) {
|
|
||||||
await approveApplication(id);
|
|
||||||
appList.value = await getAllApplications();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleDeny(id) {
|
|
||||||
await denyApplication(id);
|
|
||||||
appList.value = await getAllApplications();
|
|
||||||
}
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
function openApplication(id) {
|
function openApplication(id) {
|
||||||
|
if (!id) return;
|
||||||
router.push(`/administration/applications/${id}`)
|
router.push(`/administration/applications/${id}`)
|
||||||
openPanel.value = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeApplication() {
|
function closeApplication() {
|
||||||
router.push('/administration/applications')
|
router.push('/administration/applications')
|
||||||
openPanel.value = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
watch(() => route.params.id, (newId) => {
|
watch(() => route.params.id, (newId) => {
|
||||||
if (newId === undefined) {
|
if (newId === undefined) {
|
||||||
openPanel.value = false;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const openPanel = ref(false);
|
// const openPanel = ref(false);
|
||||||
|
const openPanel = computed(() => route.params.id !== undefined)
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
appList.value = await getAllApplications();
|
appList.value = await getAllApplications();
|
||||||
@@ -102,7 +92,7 @@ onMounted(async () => {
|
|||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead>User</TableHead>
|
<TableHead>User</TableHead>
|
||||||
<TableHead>Date Submitted</TableHead>
|
<TableHead class="text-right">Date Submitted</TableHead>
|
||||||
<TableHead class="text-right">Status</TableHead>
|
<TableHead class="text-right">Status</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
@@ -117,20 +107,10 @@ onMounted(async () => {
|
|||||||
<TableCell class="font-medium">
|
<TableCell class="font-medium">
|
||||||
<MemberCard :memberId="app.member_id"></MemberCard>
|
<MemberCard :memberId="app.member_id"></MemberCard>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell :title="formatExact(app.submitted_at)">
|
<TableCell class="text-right" :title="formatExact(app.submitted_at)">
|
||||||
{{ formatAgo(app.submitted_at) }}
|
{{ formatAgo(app.submitted_at) }}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell v-if="app.app_status === ApplicationStatus.Pending"
|
|
||||||
class="inline-flex items-end gap-2">
|
|
||||||
<Button variant="success" @click.stop="handleApprove(app.id)">
|
|
||||||
<CheckIcon />
|
|
||||||
</Button>
|
|
||||||
<Button variant="destructive" @click.stop="handleDeny(app.id)">
|
|
||||||
<XIcon />
|
|
||||||
</Button>
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell class="text-right font-semibold" :class="[
|
<TableCell class="text-right font-semibold" :class="[
|
||||||
app.app_status === ApplicationStatus.Pending && 'text-yellow-500',
|
app.app_status === ApplicationStatus.Pending && 'text-yellow-500',
|
||||||
app.app_status === ApplicationStatus.Accepted && 'text-green-500',
|
app.app_status === ApplicationStatus.Accepted && 'text-green-500',
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ const showLOADialog = ref(false);
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class="max-w-5xl mx-auto pt-10">
|
<div class="max-w-5xl mx-auto pt-10">
|
||||||
<div class="flex justify-end mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<Button @click="showLOADialog = true">Post LOA</Button>
|
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Log</h1>
|
||||||
|
<div>
|
||||||
|
<Button @click="showLOADialog = true">Post LOA</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1>LOA Log</h1>
|
|
||||||
<LoaList :admin-mode="true"></LoaList>
|
<LoaList :admin-mode="true"></LoaList>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,20 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import LoaForm from '@/components/loa/loaForm.vue';
|
import LoaForm from '@/components/loa/loaForm.vue';
|
||||||
import { useUserStore } from '@/stores/user';
|
import { useUserStore } from '@/stores/user';
|
||||||
import { Member } from '@/api/member';
|
import { Member } from '@shared/types/member';
|
||||||
import LoaList from '@/components/loa/loaList.vue';
|
import LoaList from '@/components/loa/loaList.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const user = userStore.user;
|
|
||||||
const memberFull: Member = {
|
|
||||||
member_id: user.id,
|
|
||||||
member_name: user.name,
|
|
||||||
rank: null,
|
|
||||||
rank_date: null,
|
|
||||||
status: null,
|
|
||||||
status_date: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
const mode = ref<'submit' | 'view'>('submit')
|
const mode = ref<'submit' | 'view'>('submit')
|
||||||
</script>
|
</script>
|
||||||
@@ -32,7 +23,7 @@ const mode = ref<'submit' | 'view'>('submit')
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<LoaForm v-if="mode === 'submit'" :member="memberFull"></LoaForm>
|
<LoaForm v-if="mode === 'submit'" :member="userStore.user.member"></LoaForm>
|
||||||
<LoaList v-if="mode === 'view'" :admin-mode="false"></LoaList>
|
<LoaList v-if="mode === 'view'" :admin-mode="false"></LoaList>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -22,6 +22,16 @@ import SelectContent from '@/components/ui/select/SelectContent.vue';
|
|||||||
import SelectItem from '@/components/ui/select/SelectItem.vue';
|
import SelectItem from '@/components/ui/select/SelectItem.vue';
|
||||||
import Input from '@/components/ui/input/Input.vue';
|
import Input from '@/components/ui/input/Input.vue';
|
||||||
import MemberCard from '@/components/members/MemberCard.vue';
|
import MemberCard from '@/components/members/MemberCard.vue';
|
||||||
|
import Spinner from '@/components/ui/spinner/Spinner.vue';
|
||||||
|
import { pagination } from '@shared/types/pagination';
|
||||||
|
import {
|
||||||
|
Pagination,
|
||||||
|
PaginationContent,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationItem,
|
||||||
|
PaginationNext,
|
||||||
|
PaginationPrevious,
|
||||||
|
} from '@/components/ui/pagination'
|
||||||
|
|
||||||
enum sidePanelState { view, create, closed };
|
enum sidePanelState { view, create, closed };
|
||||||
|
|
||||||
@@ -42,6 +52,7 @@ watch(() => route.params.id, async (newID) => {
|
|||||||
focusedTrainingReport.value = null;
|
focusedTrainingReport.value = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TRLoaded.value = false;
|
||||||
viewTrainingReport(Number(route.params.id));
|
viewTrainingReport(Number(route.params.id));
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -60,6 +71,7 @@ const focusedTrainingTrainers = computed<CourseAttendee[] | null>(() => {
|
|||||||
})
|
})
|
||||||
async function viewTrainingReport(id: number) {
|
async function viewTrainingReport(id: number) {
|
||||||
focusedTrainingReport.value = await getTrainingReport(id);
|
focusedTrainingReport.value = await getTrainingReport(id);
|
||||||
|
TRLoaded.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeTrainingReport() {
|
async function closeTrainingReport() {
|
||||||
@@ -84,15 +96,36 @@ watch(() => sortMode.value, async (newSortMode) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function loadTrainingReports() {
|
async function loadTrainingReports() {
|
||||||
trainingReports.value = await getTrainingReports(sortMode.value, searchString.value);
|
let data = await getTrainingReports(sortMode.value, searchString.value, pageNum.value, pageSize.value);
|
||||||
|
trainingReports.value = data.data;
|
||||||
|
pageData.value = data.pagination;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadTrainingReports();
|
await loadTrainingReports();
|
||||||
if (route.params.id)
|
if (route.params.id)
|
||||||
viewTrainingReport(Number(route.params.id))
|
viewTrainingReport(Number(route.params.id))
|
||||||
loaded.value = true;
|
loaded.value = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const TRLoaded = ref(false);
|
||||||
|
|
||||||
|
const pageNum = ref<number>(1);
|
||||||
|
const pageData = ref<pagination>();
|
||||||
|
|
||||||
|
const pageSize = ref<number>(15)
|
||||||
|
const pageSizeOptions = [10, 15, 30]
|
||||||
|
|
||||||
|
function setPageSize(size: number) {
|
||||||
|
pageSize.value = size
|
||||||
|
pageNum.value = 1;
|
||||||
|
loadTrainingReports();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPage(pagenum: number) {
|
||||||
|
pageNum.value = pagenum;
|
||||||
|
loadTrainingReports();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -113,7 +146,7 @@ onMounted(async () => {
|
|||||||
<div class="flex flex-row gap-5">
|
<div class="flex flex-row gap-5">
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted-foreground">Search</label>
|
<label class="text-muted-foreground">Search</label>
|
||||||
<Input v-model="searchString"></Input>
|
<Input v-model="searchString" placeholder="Search..."></Input>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label class="text-muted-foreground">Sort By</label>
|
<label class="text-muted-foreground">Sort By</label>
|
||||||
@@ -164,16 +197,46 @@ onMounted(async () => {
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-5 flex justify-between" :class="sidePanel !== sidePanelState.closed ? 'flex-col items-center' : 'items-center justify-between'"
|
||||||
|
>
|
||||||
|
<div></div>
|
||||||
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
|
<PaginationContent v-slot="{ items }">
|
||||||
|
<PaginationPrevious />
|
||||||
|
<template v-for="(item, index) in items" :key="index">
|
||||||
|
<PaginationItem v-if="item.type === 'page'" :value="item.value"
|
||||||
|
:is-active="item.value === page">
|
||||||
|
{{ item.value }}
|
||||||
|
</PaginationItem>
|
||||||
|
</template>
|
||||||
|
<PaginationEllipsis :index="4" />
|
||||||
|
<PaginationNext />
|
||||||
|
</PaginationContent>
|
||||||
|
</Pagination>
|
||||||
|
<div class="flex items-center gap-3 text-sm" :class="sidePanel !== sidePanelState.closed ? 'mt-3' : ''" >
|
||||||
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
|
|
||||||
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
|
class="px-2 py-1 rounded transition-colors" :class="{
|
||||||
|
'bg-muted font-semibold': pageSize === size,
|
||||||
|
'hover:bg-muted/50': pageSize !== size
|
||||||
|
}">
|
||||||
|
{{ size }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- view training report section -->
|
<!-- view training report section -->
|
||||||
<div v-if="focusedTrainingReport != null && sidePanel == sidePanelState.view" class="pl-9 my-3 border-l w-3/5">
|
<div v-if="focusedTrainingReport != null && sidePanel == sidePanelState.view" class="pl-9 my-3 border-l w-3/5">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between items-center">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p>
|
||||||
<button @click="closeTrainingReport" class="cursor-pointer">
|
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<X></X>
|
<X class="size-6"></X>
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="max-h-[70vh] overflow-auto scrollbar-themed my-5">
|
<div v-if="TRLoaded" class="max-h-[70vh] overflow-auto scrollbar-themed my-5">
|
||||||
<div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4">
|
<div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4">
|
||||||
<p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }}
|
<p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }}
|
||||||
</p>
|
</p>
|
||||||
@@ -284,15 +347,18 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="flex w-full items-center justify-center h-[80%]">
|
||||||
|
<Spinner class="size-8"></Spinner>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="sidePanel == sidePanelState.create" class="pl-7 border-l w-3/5 max-w-5xl">
|
<div v-if="sidePanel == sidePanelState.create" class="pl-7 border-l w-3/5 max-w-5xl">
|
||||||
<div class="flex justify-between my-3">
|
<div class="flex justify-between items-center my-3">
|
||||||
<div class="flex pl-2 gap-5">
|
<div class="flex pl-2 gap-5">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
||||||
</div>
|
</div>
|
||||||
<button @click="closeTrainingReport" class="cursor-pointer">
|
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<X></X>
|
<X class="size-6"></X>
|
||||||
</button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed">
|
<div class="overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed">
|
||||||
<TrainingReportForm class="w-full pl-2"
|
<TrainingReportForm class="w-full pl-2"
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import { ref, computed, watch } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { myData } from '@shared/types/member'
|
||||||
|
|
||||||
|
|
||||||
const POLL_INTERVAL = 10_000
|
const POLL_INTERVAL = 10_000
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
const user = ref(null)
|
const user = ref<myData>(null)
|
||||||
const roles = computed(() => new Set(user.value?.roleData?.map(r => r.name) ?? []));
|
const roles = computed(() => new Set(user.value?.roles?.map(r => r.name) ?? []));
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
const state = computed<string | undefined>(() => user.value?.state || undefined);
|
const state = computed<string | undefined>(() => user.value?.state || undefined);
|
||||||
const isLoggedIn = computed(() => user.value !== null)
|
const isLoggedIn = computed(() => user.value !== null)
|
||||||
|
const displayName = computed(() => user.value?.member.displayName || user.value?.member.member_name)
|
||||||
|
|
||||||
async function loadUser() {
|
async function loadUser() {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
@@ -19,7 +22,6 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
console.log(data);
|
|
||||||
user.value = data;
|
user.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +42,6 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
watch(user, (newUser) => {
|
watch(user, (newUser) => {
|
||||||
if (!newUser) return
|
if (!newUser) return
|
||||||
console.log(newUser);
|
|
||||||
|
|
||||||
const currentRoute = route.meta
|
const currentRoute = route.meta
|
||||||
|
|
||||||
@@ -88,5 +89,5 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return { user, isLoggedIn, roles, loadUser, loaded, hasAnyRole, hasRole, state }
|
return { user, displayName, isLoggedIn, roles, loadUser, loaded, hasAnyRole, hasRole, state }
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user