Compare commits
35 Commits
Training-R
...
#54-Applic
| Author | SHA1 | Date | |
|---|---|---|---|
| 5354fa85f1 | |||
| f5a0df7795 | |||
| e22f164097 | |||
| ae9c7c89b1 | |||
| dab0a7543c | |||
| 63267ac679 | |||
| 4a65596283 | |||
| e61bd1c5a1 | |||
| df89d9bf67 | |||
| 4ab803ec72 | |||
| 6a55846f19 | |||
| c04a2b06cb | |||
| 98138f51f4 | |||
| 5a7b3ba2ab | |||
| 2de6b18135 | |||
| aedcbd9492 | |||
| f985e0234c | |||
| 66ad8df0c1 | |||
| 9bc3098d58 | |||
| 5aef2f6b73 | |||
| 1faae36abc | |||
| cf98bba0cd | |||
| d31cb50d71 | |||
| 4e6745553b | |||
| faf183a23d | |||
| 3449dcec5c | |||
| 12d538dafc | |||
| b79e78c2a6 | |||
| b8f18c060e | |||
| c537ef9b60 | |||
| 26fd323f43 | |||
| 9fe18f6b1a | |||
| 9ac885da56 | |||
| 35cb149202 | |||
| 5a31d86969 |
@@ -20,8 +20,8 @@ const port = process.env.SERVER_PORT;
|
|||||||
|
|
||||||
//glitchtip setup
|
//glitchtip setup
|
||||||
const sentry = require('@sentry/node');
|
const sentry = require('@sentry/node');
|
||||||
if (!process.env.DISABLE_GLITCHTIP) {
|
if (process.env.DISABLE_GLITCHTIP) {
|
||||||
console.log("Glitchtip disabled AAAAAA")
|
console.log("Glitchtip disabled")
|
||||||
} else {
|
} else {
|
||||||
let dsn = process.env.GLITCHTIP_DSN;
|
let dsn = process.env.GLITCHTIP_DSN;
|
||||||
sentry.init({ dsn: dsn });
|
sentry.init({ dsn: dsn });
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
import pool from '../db';
|
import pool from '../db';
|
||||||
import { approveApplication, createApplication, getApplicationByID, getApplicationComments, getApplicationList, getMemberApplication } from '../services/applicationService';
|
import { approveApplication, createApplication, denyApplication, getAllMemberApplications, getApplicationByID, getApplicationComments, getApplicationList, getMemberApplication } from '../services/applicationService';
|
||||||
import { MemberState, setUserState } from '../services/memberService';
|
import { MemberState, setUserState } from '../services/memberService';
|
||||||
import { getRankByName, insertMemberRank } from '../services/rankService';
|
import { getRankByName, insertMemberRank } from '../services/rankService';
|
||||||
import { ApplicationFull, CommentRow } from "@app/shared/types/application"
|
import { ApplicationFull, CommentRow } from "@app/shared/types/application"
|
||||||
import { assignUserToStatus } from '../services/statusService';
|
import { assignUserToStatus } from '../services/statusService';
|
||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { getUserRoles } from '../services/rolesService';
|
||||||
|
|
||||||
// POST /application
|
// POST /application
|
||||||
router.post('/', async (req, res) => {
|
router.post('/', async (req, res) => {
|
||||||
@@ -16,13 +18,13 @@ router.post('/', async (req, res) => {
|
|||||||
|
|
||||||
const appVersion = 1;
|
const appVersion = 1;
|
||||||
|
|
||||||
createApplication(memberID, appVersion, JSON.stringify(App))
|
await createApplication(memberID, appVersion, JSON.stringify(App))
|
||||||
setUserState(memberID, MemberState.Applicant);
|
await setUserState(memberID, MemberState.Applicant);
|
||||||
|
|
||||||
res.sendStatus(201);
|
res.sendStatus(201);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Insert failed:', err);
|
console.error('Failed to create application: \n', err);
|
||||||
res.status(500).json({ error: 'Failed to save application' });
|
res.status(500).json({ error: 'Failed to create application' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -37,25 +39,94 @@ router.get('/all', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/me', async (req, res) => {
|
router.get('/meList', async (req, res) => {
|
||||||
|
|
||||||
let userID = req.user.id;
|
let userID = req.user.id;
|
||||||
|
|
||||||
console.log("application/me")
|
try {
|
||||||
|
let application = await getAllMemberApplications(userID);
|
||||||
|
|
||||||
let app = getMemberApplication(userID);
|
return res.status(200).json(application);
|
||||||
console.log(app);
|
} catch (error) {
|
||||||
|
console.error('Failed to load applications: \n', error);
|
||||||
|
return res.status(500).json(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get('/me', async (req, res) => {
|
||||||
|
|
||||||
|
let userID = req.user.id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let application = await getMemberApplication(userID);
|
||||||
|
|
||||||
|
if (application === undefined)
|
||||||
|
res.sendStatus(204);
|
||||||
|
|
||||||
|
const comments: CommentRow[] = await getApplicationComments(application.id);
|
||||||
|
|
||||||
|
const output: ApplicationFull = {
|
||||||
|
application,
|
||||||
|
comments,
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.status(200).json(output);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to load application:', error);
|
||||||
|
return res.status(500).json(error);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// GET /application/:id
|
// GET /application/:id
|
||||||
router.get('/:id', async (req, res) => {
|
router.get('/me/:id', async (req: Request, res: Response) => {
|
||||||
let appID = req.params.id;
|
let appID = Number(req.params.id);
|
||||||
console.log("HELLO")
|
let member = req.user.id;
|
||||||
|
try {
|
||||||
|
const application = await getApplicationByID(appID);
|
||||||
|
if (application === undefined)
|
||||||
|
return res.sendStatus(204);
|
||||||
|
console.log(application.member_id, member)
|
||||||
|
if (application.member_id != member) {
|
||||||
|
return res.sendStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
const comments: CommentRow[] = await getApplicationComments(appID);
|
||||||
|
|
||||||
|
const output: ApplicationFull = {
|
||||||
|
application,
|
||||||
|
comments,
|
||||||
|
}
|
||||||
|
return res.status(200).json(output);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.error('Query failed:', err);
|
||||||
|
return res.status(500).json({ error: 'Failed to load application' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET /application/:id
|
||||||
|
router.get('/:id', async (req: Request, res: Response) => {
|
||||||
|
let appID = Number(req.params.id);
|
||||||
|
let asAdmin = !!req.query.admin || false;
|
||||||
|
let user = req.user.id;
|
||||||
|
|
||||||
|
//TODO: Replace this with bigger authorization system eventually
|
||||||
|
if (asAdmin) {
|
||||||
|
let allowed = (await getUserRoles(user)).some((role) =>
|
||||||
|
role.name.toLowerCase() === 'dev' ||
|
||||||
|
role.name.toLowerCase() === 'recruiter' ||
|
||||||
|
role.name.toLowerCase() === 'administrator')
|
||||||
|
console.log(allowed)
|
||||||
|
if (!allowed) {
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const application = await getApplicationByID(appID);
|
const application = await getApplicationByID(appID);
|
||||||
if (application === undefined)
|
if (application === undefined)
|
||||||
return res.sendStatus(204);
|
return res.sendStatus(204);
|
||||||
|
|
||||||
const comments: CommentRow[] = await getApplicationComments(appID);
|
const comments: CommentRow[] = await getApplicationComments(appID, asAdmin);
|
||||||
|
|
||||||
const output: ApplicationFull = {
|
const output: ApplicationFull = {
|
||||||
application,
|
application,
|
||||||
@@ -77,9 +148,6 @@ router.post('/approve/:id', async (req, res) => {
|
|||||||
const app = await getApplicationByID(appID);
|
const app = await getApplicationByID(appID);
|
||||||
const result = await approveApplication(appID);
|
const result = await approveApplication(appID);
|
||||||
|
|
||||||
console.log("START");
|
|
||||||
console.log(app, result);
|
|
||||||
|
|
||||||
//guard against failures
|
//guard against failures
|
||||||
if (result.affectedRows != 1) {
|
if (result.affectedRows != 1) {
|
||||||
throw new Error("Something went wrong approving the application");
|
throw new Error("Something went wrong approving the application");
|
||||||
@@ -104,26 +172,11 @@ router.post('/approve/:id', async (req, res) => {
|
|||||||
router.post('/deny/:id', async (req, res) => {
|
router.post('/deny/:id', async (req, res) => {
|
||||||
const appID = req.params.id;
|
const appID = req.params.id;
|
||||||
|
|
||||||
const sql = `
|
|
||||||
UPDATE applications
|
|
||||||
SET denied_at = NOW()
|
|
||||||
WHERE id = ?
|
|
||||||
AND approved_at IS NULL
|
|
||||||
AND denied_at IS NULL
|
|
||||||
`;
|
|
||||||
try {
|
try {
|
||||||
const result = await pool.execute(sql, appID);
|
const app = await getApplicationByID(appID);
|
||||||
|
await denyApplication(appID);
|
||||||
console.log(result);
|
await setUserState(app.member_id, MemberState.Denied);
|
||||||
|
|
||||||
if (result.affectedRows === 0) {
|
|
||||||
res.status(400).json('Something went wrong denying the application');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.affectedRows == 1) {
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Approve failed:', err);
|
console.error('Approve failed:', err);
|
||||||
res.status(500).json({ error: 'Failed to deny application' });
|
res.status(500).json({ error: 'Failed to deny application' });
|
||||||
@@ -131,10 +184,12 @@ router.post('/deny/:id', async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// POST /application/:id/comment
|
// POST /application/:id/comment
|
||||||
router.post('/:id/comment', async (req, res) => {
|
router.post('/:id/comment', async (req: Request, res: Response) => {
|
||||||
const appID = req.params.id;
|
const appID = req.params.id;
|
||||||
const data = req.body.message;
|
const data = req.body.message;
|
||||||
const user = 1;
|
const user = req.user;
|
||||||
|
|
||||||
|
console.log(user)
|
||||||
|
|
||||||
const sql = `INSERT INTO application_comments(
|
const sql = `INSERT INTO application_comments(
|
||||||
application_id,
|
application_id,
|
||||||
@@ -146,7 +201,7 @@ VALUES(?, ?, ?);`
|
|||||||
try {
|
try {
|
||||||
const conn = await pool.getConnection();
|
const conn = await pool.getConnection();
|
||||||
|
|
||||||
const result = await conn.query(sql, [appID, user, data])
|
const result = await conn.query(sql, [appID, user.id, data])
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.affectedRows !== 1) {
|
if (result.affectedRows !== 1) {
|
||||||
conn.release();
|
conn.release();
|
||||||
@@ -171,4 +226,60 @@ VALUES(?, ?, ?);`
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// POST /application/:id/comment
|
||||||
|
router.post('/:id/adminComment', async (req: Request, res: Response) => {
|
||||||
|
const appID = req.params.id;
|
||||||
|
const data = req.body.message;
|
||||||
|
const user = req.user;
|
||||||
|
|
||||||
|
console.log(user)
|
||||||
|
|
||||||
|
const sql = `INSERT INTO application_comments(
|
||||||
|
application_id,
|
||||||
|
poster_id,
|
||||||
|
post_content,
|
||||||
|
admin_only
|
||||||
|
)
|
||||||
|
VALUES(?, ?, ?, 1);`
|
||||||
|
|
||||||
|
try {
|
||||||
|
const conn = await pool.getConnection();
|
||||||
|
|
||||||
|
const result = await conn.query(sql, [appID, user.id, data])
|
||||||
|
console.log(result)
|
||||||
|
if (result.affectedRows !== 1) {
|
||||||
|
conn.release();
|
||||||
|
throw new Error("Insert Failure")
|
||||||
|
}
|
||||||
|
|
||||||
|
const getSQL = `SELECT app.id AS comment_id,
|
||||||
|
app.post_content,
|
||||||
|
app.poster_id,
|
||||||
|
app.post_time,
|
||||||
|
app.last_modified,
|
||||||
|
app.admin_only,
|
||||||
|
member.name AS poster_name
|
||||||
|
FROM application_comments AS app
|
||||||
|
INNER JOIN members AS member ON member.id = app.poster_id
|
||||||
|
WHERE app.id = ?; `;
|
||||||
|
const comment = await conn.query(getSQL, [result.insertId])
|
||||||
|
res.status(201).json(comment[0]);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Comment failed:', err);
|
||||||
|
res.status(500).json({ error: 'Could not post comment' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/restart', async (req: Request, res: Response) => {
|
||||||
|
const user = req.user.id;
|
||||||
|
try {
|
||||||
|
await setUserState(user, MemberState.Guest);
|
||||||
|
res.sendStatus(200);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Comment failed:', error);
|
||||||
|
res.status(500).json({ error: 'Could not rester application' });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ApplicationListRow, ApplicationRow, CommentRow } from "@app/shared/types/application";
|
import { ApplicationListRow, ApplicationRow, CommentRow } from "@app/shared/types/application";
|
||||||
import pool from "../db";
|
import pool from "../db";
|
||||||
|
import { error } from "console";
|
||||||
|
|
||||||
export async function createApplication(memberID: number, appVersion: number, app: string) {
|
export async function createApplication(memberID: number, appVersion: number, app: string) {
|
||||||
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
||||||
@@ -12,12 +13,13 @@ export async function getMemberApplication(memberID: number): Promise<Applicatio
|
|||||||
member.name AS member_name
|
member.name AS member_name
|
||||||
FROM applications AS app
|
FROM applications AS app
|
||||||
INNER JOIN members AS member ON member.id = app.member_id
|
INNER JOIN members AS member ON member.id = app.member_id
|
||||||
WHERE app.member_id = ?;`;
|
WHERE app.member_id = ? ORDER BY submitted_at DESC LIMIT 1;`;
|
||||||
|
|
||||||
let app: ApplicationRow[] = await pool.query(sql, [memberID]);
|
let app: ApplicationRow[] = await pool.query(sql, [memberID]);
|
||||||
return app[0];
|
return app[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function getApplicationByID(appID: number): Promise<ApplicationRow> {
|
export async function getApplicationByID(appID: number): Promise<ApplicationRow> {
|
||||||
const sql =
|
const sql =
|
||||||
`SELECT app.*,
|
`SELECT app.*,
|
||||||
@@ -44,7 +46,20 @@ export async function getApplicationList(): Promise<ApplicationListRow[]> {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function approveApplication(id) {
|
export async function getAllMemberApplications(memberID: number): Promise<ApplicationListRow[]> {
|
||||||
|
const sql = `SELECT
|
||||||
|
app.id,
|
||||||
|
app.member_id,
|
||||||
|
app.submitted_at,
|
||||||
|
app.app_status
|
||||||
|
FROM applications AS app WHERE app.member_id = ? ORDER BY submitted_at DESC;`;
|
||||||
|
|
||||||
|
const rows: ApplicationListRow[] = await pool.query(sql, [memberID])
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function approveApplication(id: number) {
|
||||||
const sql = `
|
const sql = `
|
||||||
UPDATE applications
|
UPDATE applications
|
||||||
SET approved_at = NOW()
|
SET approved_at = NOW()
|
||||||
@@ -57,15 +72,38 @@ export async function approveApplication(id) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getApplicationComments(appID: number): Promise<CommentRow[]> {
|
export async function denyApplication(id: number) {
|
||||||
|
const sql = `
|
||||||
|
UPDATE applications
|
||||||
|
SET denied_at = NOW()
|
||||||
|
WHERE id = ?
|
||||||
|
AND approved_at IS NULL
|
||||||
|
AND denied_at IS NULL
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await pool.execute(sql, id);
|
||||||
|
|
||||||
|
if (result.affectedRows == 1) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
throw new Error(`"Something went wrong denying application with ID ${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getApplicationComments(appID: number, admin: boolean = false): Promise<CommentRow[]> {
|
||||||
|
const excludeAdmin = ' AND app.admin_only = false';
|
||||||
|
|
||||||
|
const whereClause = `WHERE app.application_id = ?${!admin ? excludeAdmin : ''}`;
|
||||||
|
|
||||||
return await pool.query(`SELECT app.id AS comment_id,
|
return await pool.query(`SELECT app.id AS comment_id,
|
||||||
app.post_content,
|
app.post_content,
|
||||||
app.poster_id,
|
app.poster_id,
|
||||||
app.post_time,
|
app.post_time,
|
||||||
app.last_modified,
|
app.last_modified,
|
||||||
|
app.admin_only,
|
||||||
member.name AS poster_name
|
member.name AS poster_name
|
||||||
FROM application_comments AS app
|
FROM application_comments AS app
|
||||||
INNER JOIN members AS member ON member.id = app.poster_id
|
INNER JOIN members AS member ON member.id = app.poster_id
|
||||||
WHERE app.application_id = ?;`,
|
${whereClause}`,
|
||||||
[appID]);
|
[appID]);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import pool from '../db';
|
import pool from '../db';
|
||||||
|
import { Role } from '@app/shared/types/roles'
|
||||||
|
|
||||||
export async function assignUserGroup(userID: number, roleID: number) {
|
export async function assignUserGroup(userID: number, roleID: number) {
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ export async function createGroup(name: string, color: string, description: stri
|
|||||||
return { id: result.insertId, name, color, description };
|
return { id: result.insertId, name, color, description };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserRoles(userID: number) {
|
export async function getUserRoles(userID: number): Promise<Role[]> {
|
||||||
const sql = `SELECT r.id, r.name
|
const sql = `SELECT r.id, r.name
|
||||||
FROM members_roles mr
|
FROM members_roles mr
|
||||||
INNER JOIN roles r ON mr.role_id = r.id
|
INNER JOIN roles r ON mr.role_id = r.id
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export interface CommentRow {
|
|||||||
post_time: string;
|
post_time: string;
|
||||||
last_modified: string | null;
|
last_modified: string | null;
|
||||||
poster_name: string;
|
poster_name: string;
|
||||||
|
admin_only: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApplicationFull {
|
export interface ApplicationFull {
|
||||||
|
|||||||
6
shared/types/roles.ts
Normal file
6
shared/types/roles.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface Role {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
color?: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
8
ui/package-lock.json
generated
8
ui/package-lock.json
generated
@@ -22,7 +22,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-vue-next": "^0.539.0",
|
"lucide-vue-next": "^0.539.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"reka-ui": "^2.6.0",
|
"reka-ui": "^2.6.1",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"tw-animate-css": "^1.3.6",
|
"tw-animate-css": "^1.3.6",
|
||||||
@@ -3333,9 +3333,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/reka-ui": {
|
"node_modules/reka-ui": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/reka-ui/-/reka-ui-2.6.1.tgz",
|
||||||
"integrity": "sha512-NrGMKrABD97l890mFS3TNUzB0BLUfbL3hh0NjcJRIUSUljb288bx3Mzo31nOyUcdiiW0HqFGXJwyCBh9cWgb0w==",
|
"integrity": "sha512-XK7cJDQoNuGXfCNzBBo/81Yg/OgjPwvbabnlzXG2VsdSgNsT6iIkuPBPr+C0Shs+3bb0x0lbPvgQAhMSCKm5Ww==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/dom": "^1.6.13",
|
"@floating-ui/dom": "^1.6.13",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"lucide-vue-next": "^0.539.0",
|
"lucide-vue-next": "^0.539.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"reka-ui": "^2.6.0",
|
"reka-ui": "^2.6.1",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tailwindcss": "^4.1.11",
|
"tailwindcss": "^4.1.11",
|
||||||
"tw-animate-css": "^1.3.6",
|
"tw-animate-css": "^1.3.6",
|
||||||
|
|||||||
BIN
ui/public/17RBN_Logo.png
Normal file
BIN
ui/public/17RBN_Logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
109
ui/src/App.vue
109
ui/src/App.vue
@@ -1,41 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RouterLink, RouterView } from 'vue-router';
|
import { RouterView } from 'vue-router';
|
||||||
import Separator from './components/ui/separator/Separator.vue';
|
|
||||||
import Button from './components/ui/button/Button.vue';
|
import Button from './components/ui/button/Button.vue';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover';
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from './components/ui/dropdown-menu';
|
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import { useUserStore } from './stores/user';
|
import { useUserStore } from './stores/user';
|
||||||
import Alert from './components/ui/alert/Alert.vue';
|
import Alert from './components/ui/alert/Alert.vue';
|
||||||
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
||||||
|
import Navbar from './components/Navigation/Navbar.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// onMounted(async () => {
|
|
||||||
// const res = await fetch(`${import.meta.env.VITE_APIHOST}/members/me`, {
|
|
||||||
// credentials: 'include',
|
|
||||||
// });
|
|
||||||
// const data = await res.json();
|
|
||||||
// console.log(data);
|
|
||||||
// userStore.user = data;
|
|
||||||
// });
|
|
||||||
const APIHOST = import.meta.env.VITE_APIHOST;
|
|
||||||
|
|
||||||
async function logout() {
|
|
||||||
// await fetch(`${APIHOST}/logout`, {
|
|
||||||
// method: 'GET',
|
|
||||||
// credentials: 'include',
|
|
||||||
// });
|
|
||||||
|
|
||||||
userStore.user = null;
|
|
||||||
window.location.href = APIHOST + "/logout";
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
if (!dateStr) return "";
|
if (!dateStr) return "";
|
||||||
return new Date(dateStr).toLocaleDateString("en-US", {
|
return new Date(dateStr).toLocaleDateString("en-US", {
|
||||||
@@ -49,77 +21,9 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="flex flex-col min-h-screen">
|
||||||
<div class="flex items-center justify-between px-10">
|
<div class="sticky top-0 bg-background z-50">
|
||||||
<div></div>
|
<Navbar class="flex"></Navbar>
|
||||||
<div class="h-15 flex items-center justify-center gap-20">
|
|
||||||
<RouterLink to="/">
|
|
||||||
<Button variant="link">Home</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/calendar">
|
|
||||||
<Button variant="link">Calendar</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/members">
|
|
||||||
<Button variant="link">Members</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger as-child>
|
|
||||||
<Button variant="link">Forms</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="flex flex-col gap-4 items-center w-min">
|
|
||||||
<RouterLink to="/transfer">
|
|
||||||
<Button variant="link">Transfer Request</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/trainingReport">
|
|
||||||
<Button variant="link">Training Report</Button>
|
|
||||||
</RouterLink>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger as-child>
|
|
||||||
<Button variant="link">Administration</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="flex flex-col gap-4 items-center w-min">
|
|
||||||
<RouterLink to="/administration/rankChange">
|
|
||||||
<Button variant="link">Promotions</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/loa">
|
|
||||||
<Button variant="link">Leave of Absence</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/transfer">
|
|
||||||
<Button variant="link">Transfer Requests</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/applications">
|
|
||||||
<Button variant="link">Recruitment</Button>
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink to="/administration/roles">
|
|
||||||
<Button variant="link">Role Management</Button>
|
|
||||||
</RouterLink>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<DropdownMenu v-if="userStore.isLoggedIn">
|
|
||||||
<DropdownMenuTrigger class="cursor-pointer">
|
|
||||||
<p>{{ userStore.user.name }}</p>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
|
||||||
<DropdownMenuItem>My Profile</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem>Settings</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem>
|
|
||||||
<RouterLink to="/loa">
|
|
||||||
Submit LOA
|
|
||||||
</RouterLink>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem :variant="'destructive'" @click="logout()">Logout</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
<a v-else :href="APIHOST + '/login'">Login</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Separator></Separator>
|
|
||||||
<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">
|
||||||
<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>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>
|
||||||
@@ -131,8 +35,9 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
|||||||
<Button variant="secondary">End LOA</Button>
|
<Button variant="secondary">End LOA</Button>
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
</div>
|
||||||
|
|
||||||
<RouterView class=""></RouterView>
|
<RouterView class="flex-1 min-h-0"></RouterView>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,80 +1,11 @@
|
|||||||
export type ApplicationDto = Partial<{
|
import { ApplicationFull } from "@shared/types/application";
|
||||||
age: number | string
|
|
||||||
name: string
|
|
||||||
playtime: number | string
|
|
||||||
hobbies: string
|
|
||||||
military: boolean
|
|
||||||
communities: string
|
|
||||||
joinReason: string
|
|
||||||
milsimAttraction: string
|
|
||||||
referral: string
|
|
||||||
steamProfile: string
|
|
||||||
timezone: string
|
|
||||||
canAttendSaturday: boolean
|
|
||||||
interests: string
|
|
||||||
aknowledgeRules: boolean
|
|
||||||
}>
|
|
||||||
|
|
||||||
export interface ApplicationData {
|
|
||||||
dob: string;
|
|
||||||
name: string;
|
|
||||||
playtime: number;
|
|
||||||
hobbies: string;
|
|
||||||
military: boolean;
|
|
||||||
communities: string;
|
|
||||||
joinReason: string;
|
|
||||||
milsimAttraction: string;
|
|
||||||
referral: string;
|
|
||||||
steamProfile: string;
|
|
||||||
timezone: string;
|
|
||||||
canAttendSaturday: boolean;
|
|
||||||
interests: string;
|
|
||||||
aknowledgeRules: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
//reflects how applications are stored in the database
|
|
||||||
export interface ApplicationRow {
|
|
||||||
id: number;
|
|
||||||
member_id: number;
|
|
||||||
app_version: number;
|
|
||||||
app_data: ApplicationData;
|
|
||||||
|
|
||||||
submitted_at: string; // ISO datetime from DB (e.g., "2025-08-25T18:04:29.000Z")
|
|
||||||
updated_at: string | null;
|
|
||||||
approved_at: string | null;
|
|
||||||
denied_at: string | null;
|
|
||||||
|
|
||||||
app_status: ApplicationStatus; // generated column
|
|
||||||
decision_at: string | null; // generated column
|
|
||||||
|
|
||||||
// present when you join members (e.g., SELECT a.*, m.name AS member_name)
|
|
||||||
member_name: string;
|
|
||||||
}
|
|
||||||
export interface CommentRow {
|
|
||||||
comment_id: number;
|
|
||||||
post_content: string;
|
|
||||||
poster_id: number;
|
|
||||||
post_time: string;
|
|
||||||
last_modified: string | null;
|
|
||||||
poster_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApplicationFull {
|
|
||||||
application: ApplicationRow;
|
|
||||||
comments: CommentRow[];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export enum ApplicationStatus {
|
|
||||||
Pending = "Pending",
|
|
||||||
Accepted = "Accepted",
|
|
||||||
Denied = "Denied",
|
|
||||||
}
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const addr = import.meta.env.VITE_APIHOST;
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
export async function loadApplication(id: number | string): Promise<ApplicationFull | null> {
|
export async function loadApplication(id: number | string, asAdmin: boolean = false): Promise<ApplicationFull | null> {
|
||||||
const res = await fetch(`${addr}/application/${id}`)
|
const res = await fetch(`${addr}/application/${id}?admin=${asAdmin}`, { credentials: 'include' })
|
||||||
if (res.status === 204) return null
|
if (res.status === 204) return null
|
||||||
if (!res.ok) throw new Error('Failed to load application')
|
if (!res.ok) throw new Error('Failed to load application')
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
@@ -104,6 +35,22 @@ export async function postChatMessage(message: any, post_id: number) {
|
|||||||
|
|
||||||
const response = await fetch(`${addr}/application/${post_id}/comment`, {
|
const response = await fetch(`${addr}/application/${post_id}/comment`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(out),
|
||||||
|
})
|
||||||
|
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function postAdminChatMessage(message: any, post_id: number) {
|
||||||
|
const out = {
|
||||||
|
message: message
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`${addr}/application/${post_id}/adminComment`, {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(out),
|
body: JSON.stringify(out),
|
||||||
})
|
})
|
||||||
@@ -121,6 +68,26 @@ export async function getAllApplications(): Promise<ApplicationFull> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loadMyApplications(): Promise<ApplicationFull> {
|
||||||
|
const res = await fetch(`${addr}/application/meList`, { credentials: 'include' })
|
||||||
|
|
||||||
|
if (res.ok) {
|
||||||
|
return res.json()
|
||||||
|
} else {
|
||||||
|
console.error("Something went wrong approving the application")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMyApplication(id: number): Promise<ApplicationFull> {
|
||||||
|
const res = await fetch(`${addr}/application/me/${id}`, { credentials: 'include' })
|
||||||
|
if (res.status === 204) return null
|
||||||
|
if (res.status === 403) throw new Error("Unauthorized");
|
||||||
|
if (!res.ok) throw new Error('Failed to load application')
|
||||||
|
const json = await res.json()
|
||||||
|
// Accept either the object at root or under `application`
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
export async function approveApplication(id: Number) {
|
export async function approveApplication(id: Number) {
|
||||||
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST' })
|
const res = await fetch(`${addr}/application/approve/${id}`, { method: 'POST' })
|
||||||
|
|
||||||
@@ -136,3 +103,14 @@ export async function denyApplication(id: Number) {
|
|||||||
console.error("Something went wrong denying the application")
|
console.error("Something went wrong denying the application")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function restartApplication() {
|
||||||
|
const res = await fetch(`${addr}/application/restart`, {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include'
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
console.error("Something went wrong restarting your application")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
--secondary-foreground: oklch(0.9219 0 0);
|
--secondary-foreground: oklch(0.9219 0 0);
|
||||||
--muted: oklch(0.2686 0 0);
|
--muted: oklch(0.2686 0 0);
|
||||||
--muted-foreground: oklch(0.7155 0 0);
|
--muted-foreground: oklch(0.7155 0 0);
|
||||||
--accent: oklch(0.4732 0.1247 46.2007);
|
--accent: oklch(100% 0.00011 271.152 / 0.253);
|
||||||
--accent-foreground: oklch(0.9243 0.1151 95.7459);
|
--accent-foreground: oklch(100% 0.00011 271.152);
|
||||||
--destructive: oklch(0.6368 0.2078 25.3313);
|
--destructive: oklch(0.6368 0.2078 25.3313);
|
||||||
--destructive-foreground: oklch(1.0000 0 0);
|
--destructive-foreground: oklch(1.0000 0 0);
|
||||||
--success: oklch(66.104% 0.16937 144.153);
|
--success: oklch(66.104% 0.16937 144.153);
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
/* .dark {
|
||||||
--background: oklch(0.2046 0 0);
|
--background: oklch(0.2046 0 0);
|
||||||
--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);
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 4px 6px -2px hsl(0 0% 0% / 0.14);
|
--shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 4px 6px -2px hsl(0 0% 0% / 0.14);
|
||||||
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 8px 10px -2px hsl(0 0% 0% / 0.14);
|
--shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.14), 0px 8px 10px -2px hsl(0 0% 0% / 0.14);
|
||||||
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
--shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.35);
|
||||||
}
|
} */
|
||||||
|
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
|
|||||||
182
ui/src/components/Navigation/Navbar.vue
Normal file
182
ui/src/components/Navigation/Navbar.vue
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { RouterLink } from 'vue-router';
|
||||||
|
import Separator from '../ui/separator/Separator.vue';
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '../ui/dropdown-menu';
|
||||||
|
import { useUserStore } from '@/stores/user';
|
||||||
|
import Button from '../ui/button/Button.vue';
|
||||||
|
import NavigationMenu from '../ui/navigation-menu/NavigationMenu.vue';
|
||||||
|
import NavigationMenuList from '../ui/navigation-menu/NavigationMenuList.vue';
|
||||||
|
import NavigationMenuItem from '../ui/navigation-menu/NavigationMenuItem.vue';
|
||||||
|
import NavigationMenuLink from '../ui/navigation-menu/NavigationMenuLink.vue';
|
||||||
|
import NavigationMenuTrigger from '../ui/navigation-menu/NavigationMenuTrigger.vue';
|
||||||
|
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
||||||
|
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
||||||
|
import { useAuth } from '@/composables/useAuth';
|
||||||
|
import { CircleArrowOutUpRight } from 'lucide-vue-next';
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const auth = useAuth();
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
const APIHOST = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
userStore.user = null;
|
||||||
|
window.location.href = APIHOST + "/logout";
|
||||||
|
}
|
||||||
|
|
||||||
|
function blurAfter() {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
(document.activeElement as HTMLElement)?.blur();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="w-full border-b">
|
||||||
|
<div class="max-w-screen-3xl w-full mx-auto flex items-center justify-between pr-10 pl-7">
|
||||||
|
<!-- left side -->
|
||||||
|
<div class="flex items-center gap-7">
|
||||||
|
<RouterLink to="/">
|
||||||
|
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
||||||
|
</RouterLink>
|
||||||
|
<!-- Member navigation -->
|
||||||
|
<div v-if="auth.accountStatus.value == 'member'" class="h-15 flex items-center justify-center">
|
||||||
|
<NavigationMenu>
|
||||||
|
<NavigationMenuList class="gap-3">
|
||||||
|
|
||||||
|
<!-- Calendar -->
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/calendar" @click="blurAfter">Calendar</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Members -->
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/" @click="blurAfter">Documents</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Forms (Dropdown) -->
|
||||||
|
<NavigationMenuItem class="bg-none !focus:bg-none !active:bg-none">
|
||||||
|
<NavigationMenuTrigger>Forms</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent
|
||||||
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/loa" @click="blurAfter">
|
||||||
|
Leave of Absence
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/transfer" @click="blurAfter">
|
||||||
|
Transfer Request
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/trainingReport" @click="blurAfter">
|
||||||
|
Training Report
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Administration (Dropdown) -->
|
||||||
|
<NavigationMenuItem
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command', 'Recruiter'])">
|
||||||
|
<NavigationMenuTrigger>Administration</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent
|
||||||
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/rankChange" @click="blurAfter">
|
||||||
|
Promotions
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/loa" @click="blurAfter">
|
||||||
|
Leave of Absence
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink
|
||||||
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command'])"
|
||||||
|
as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/transfer" @click="blurAfter">
|
||||||
|
Transfer Requests
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink v-if="auth.hasRole('Recruiter')" as-child
|
||||||
|
:class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/applications" @click="blurAfter">
|
||||||
|
Recruitment
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
|
||||||
|
<NavigationMenuLink v-if="auth.hasRole('17th Administrator')" as-child
|
||||||
|
:class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/administration/roles" @click="blurAfter">
|
||||||
|
Role Management
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<NavigationMenuItem as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/members" @click="blurAfter">
|
||||||
|
Members (debug)
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
</NavigationMenuList>
|
||||||
|
</NavigationMenu>
|
||||||
|
</div>
|
||||||
|
<!-- Guest navigation -->
|
||||||
|
<div v-else class="h-15 flex items-center justify-center">
|
||||||
|
<NavigationMenu>
|
||||||
|
<NavigationMenuList>
|
||||||
|
<NavigationMenuItem>
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/join" @click="blurAfter">Join</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
</NavigationMenuList>
|
||||||
|
</NavigationMenu>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- right side -->
|
||||||
|
<div>
|
||||||
|
<DropdownMenu v-if="userStore.isLoggedIn">
|
||||||
|
<DropdownMenuTrigger class="cursor-pointer">
|
||||||
|
<p>{{ userStore.user.name }}</p>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
<!-- <DropdownMenuItem>My Profile</DropdownMenuItem> -->
|
||||||
|
<!-- <DropdownMenuItem>Settings</DropdownMenuItem> -->
|
||||||
|
<DropdownMenuItem @click="$router.push('/join')">My Application</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem @click="$router.push('/applications')">Application History</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem :variant="'destructive'" @click="logout()">Logout</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
<a v-else :href="APIHOST + '/login'">Login</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <Separator></Separator> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -11,13 +11,18 @@ import {
|
|||||||
import Textarea from '@/components/ui/textarea/Textarea.vue'
|
import Textarea from '@/components/ui/textarea/Textarea.vue'
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import * as z from 'zod'
|
import * as z from 'zod'
|
||||||
|
import { useAuth } from '@/composables/useAuth'
|
||||||
|
import { CommentRow } from '@shared/types/application'
|
||||||
|
import { Dot } from 'lucide-vue-next'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
messages: Array<Record<string, any>>
|
messages: CommentRow[]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'post', text: string): void
|
(e: 'post', text: string): void
|
||||||
|
(e: 'postInternal', text: string): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const commentSchema = toTypedSchema(
|
const commentSchema = toTypedSchema(
|
||||||
@@ -26,8 +31,13 @@ const commentSchema = toTypedSchema(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const submitMode = ref("public");
|
||||||
|
|
||||||
// vee-validate passes (values, actions) to @submit
|
// vee-validate passes (values, actions) to @submit
|
||||||
function onSubmit(values: { text: string }, { resetForm }: { resetForm: () => void }) {
|
function onSubmit(values: { text: string }, { resetForm }: { resetForm: () => void }) {
|
||||||
|
if (submitMode.value === "internal")
|
||||||
|
emit('postInternal', values.text.trim())
|
||||||
|
else
|
||||||
emit('post', values.text.trim())
|
emit('post', values.text.trim())
|
||||||
resetForm()
|
resetForm()
|
||||||
}
|
}
|
||||||
@@ -38,7 +48,7 @@ function onSubmit(values: { text: string }, { resetForm }: { resetForm: () => vo
|
|||||||
<Form :validation-schema="commentSchema" @submit="onSubmit">
|
<Form :validation-schema="commentSchema" @submit="onSubmit">
|
||||||
<FormField name="text" v-slot="{ componentField }">
|
<FormField name="text" v-slot="{ componentField }">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel class="sr-only">Comment</FormLabel>
|
<FormLabel>Comment</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea v-bind="componentField" rows="3" placeholder="Write a comment…"
|
<Textarea v-bind="componentField" rows="3" placeholder="Write a comment…"
|
||||||
class="bg-neutral-800 resize-none w-full" />
|
class="bg-neutral-800 resize-none w-full" />
|
||||||
@@ -48,18 +58,24 @@ function onSubmit(values: { text: string }, { resetForm }: { resetForm: () => vo
|
|||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<!-- Button below, right-aligned -->
|
<!-- Button below, right-aligned -->
|
||||||
<div class="mt-2 flex justify-end">
|
<div class="mt-2 flex justify-end gap-2">
|
||||||
<Button type="submit">Post</Button>
|
<Button type="submit" @click="submitMode = 'internal'" variant="outline">Post (Internal)</Button>
|
||||||
|
<Button type="submit" @click="submitMode = 'public'">Post (Public)</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<!-- Existing posts -->
|
<!-- Existing posts -->
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<div v-for="(message, i) in props.messages" :key="message.id ?? i"
|
<div v-for="(message, i) in props.messages" :key="message.comment_id ?? i" class="rounded-md border p-3 space-y-5"
|
||||||
class="rounded-md border border-neutral-800 p-3 space-y-5">
|
:class="message.admin_only ? 'border-amber-300/70' : 'border-neutral-800'">
|
||||||
<!-- Comment header -->
|
<!-- Comment header -->
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
|
<div class="flex">
|
||||||
<p>{{ message.poster_name }}</p>
|
<p>{{ message.poster_name }}</p>
|
||||||
|
<p v-if="message.admin_only" class="flex">
|
||||||
|
<Dot /><span class="text-amber-300">Internal</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<p class="text-muted-foreground">{{ new Date(message.post_time).toLocaleString("EN-us", {
|
<p class="text-muted-foreground">{{ new Date(message.post_time).toLocaleString("EN-us", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
|
|||||||
@@ -16,23 +16,27 @@ import { Form } from 'vee-validate';
|
|||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
import DateInput from '../form/DateInput.vue';
|
import DateInput from '../form/DateInput.vue';
|
||||||
import { ApplicationData } from '@/api/application';
|
import { ApplicationData } from '@shared/types/application';
|
||||||
|
|
||||||
|
const regexA = /^https?:\/\/steamcommunity\.com\/id\/[A-Za-z0-9_]+\/?$/;
|
||||||
|
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(),
|
name: z.string().nonempty(),
|
||||||
playtime: z.coerce.number({ invalid_type_error: "Must be a number", }).min(0, "Cannot be less than 0"),
|
playtime: z.coerce.number({ invalid_type_error: "Must be a number", }).min(0, "Cannot be less than 0"),
|
||||||
hobbies: z.string(),
|
hobbies: z.string().nonempty(),
|
||||||
military: z.boolean(),
|
military: z.boolean(),
|
||||||
communities: z.string(),
|
communities: z.string().nonempty(),
|
||||||
joinReason: z.string(),
|
joinReason: z.string().nonempty(),
|
||||||
milsimAttraction: z.string(),
|
milsimAttraction: z.string().nonempty(),
|
||||||
referral: z.string(),
|
referral: z.string().nonempty(),
|
||||||
steamProfile: z.string(),
|
steamProfile: z.string().nonempty().refine((val) => regexA.test(val) || regexB.test(val), { message: "Invalid Steam profile URL." }),
|
||||||
timezone: z.string(),
|
timezone: z.string().nonempty(),
|
||||||
canAttendSaturday: z.boolean(),
|
canAttendSaturday: z.boolean(),
|
||||||
interests: z.string(),
|
interests: z.string().nonempty(),
|
||||||
aknowledgeRules: z.literal(true, {
|
acknowledgeRules: z.literal(true, {
|
||||||
errorMap: () => ({ message: "Required" })
|
errorMap: () => ({ message: "Required" })
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
@@ -41,7 +45,7 @@ const formSchema = toTypedSchema(z.object({
|
|||||||
const fallbackInitials = {
|
const fallbackInitials = {
|
||||||
military: false,
|
military: false,
|
||||||
canAttendSaturday: false,
|
canAttendSaturday: false,
|
||||||
aknowledgeRules: false,
|
acknowledgeRules: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -82,7 +86,9 @@ onMounted(() => {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
|
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -94,7 +100,9 @@ onMounted(() => {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -105,7 +113,9 @@ onMounted(() => {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="number" :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
<Input type="number" :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -117,7 +127,9 @@ onMounted(() => {
|
|||||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -131,7 +143,9 @@ onMounted(() => {
|
|||||||
<span>Yes (checked) / No (unchecked)</span>
|
<span>Yes (checked) / No (unchecked)</span>
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -142,7 +156,9 @@ onMounted(() => {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
<Input :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -154,7 +170,9 @@ onMounted(() => {
|
|||||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -166,7 +184,9 @@ onMounted(() => {
|
|||||||
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
<Textarea rows="4" class="resize-none" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -178,7 +198,9 @@ onMounted(() => {
|
|||||||
<Input placeholder="e.g., Reddit / Member: Alice" :model-value="value" @update:model-value="handleChange"
|
<Input placeholder="e.g., Reddit / Member: Alice" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -194,7 +216,9 @@ onMounted(() => {
|
|||||||
<Input type="url" placeholder="https://steamcommunity.com/profiles/7656119..." :model-value="value"
|
<Input type="url" placeholder="https://steamcommunity.com/profiles/7656119..." :model-value="value"
|
||||||
@update:model-value="handleChange" :disabled="readOnly" />
|
@update:model-value="handleChange" :disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -206,7 +230,9 @@ onMounted(() => {
|
|||||||
<Input placeholder="e.g., AEST, EST, UTC+10" :model-value="value" @update:model-value="handleChange"
|
<Input placeholder="e.g., AEST, EST, UTC+10" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -220,7 +246,9 @@ onMounted(() => {
|
|||||||
<span>Yes (checked) / No (unchecked)</span>
|
<span>Yes (checked) / No (unchecked)</span>
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
@@ -232,22 +260,26 @@ onMounted(() => {
|
|||||||
<Input placeholder="e.g., Rifleman; Medic; Pilot" :model-value="value" @update:model-value="handleChange"
|
<Input placeholder="e.g., Rifleman; Medic; Pilot" :model-value="value" @update:model-value="handleChange"
|
||||||
:disabled="readOnly" />
|
:disabled="readOnly" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<!-- Code of Conduct (boolean, field name kept as-is) -->
|
<!-- Code of Conduct (boolean, field name kept as-is) -->
|
||||||
<FormField name="aknowledgeRules" v-slot="{ value, handleChange }">
|
<FormField name="acknowledgeRules" v-slot="{ value, handleChange }">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Community Code of Conduct</FormLabel>
|
<FormLabel>Community Code of Conduct</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
<Checkbox :model-value="value" @update:model-value="handleChange" :disabled="readOnly" />
|
||||||
<span>By checking this box, you accept the <Button variant="link" class="p-0">Code of
|
<span>By checking this box, you accept the <Button variant="link" class="p-0 h-min">Code of
|
||||||
Conduct</Button>.</span>
|
Conduct</Button>.</span>
|
||||||
</div>
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<div class="h-4">
|
||||||
|
<FormMessage class="text-destructive" />
|
||||||
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ function toMariaDBDatetime(date: Date): string {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-row-reverse gap-6 mx-auto " :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
<div class="flex flex-row-reverse gap-6 mx-auto w-full" :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
||||||
<div v-if="!adminMode" class="flex-1 flex space-x-4 rounded-md border p-4">
|
<div v-if="!adminMode" class="flex-1 flex space-x-4 rounded-md border p-4">
|
||||||
<div class="flex-2 space-y-1">
|
<div class="flex-2 space-y-1">
|
||||||
<p class="text-sm font-medium leading-none">
|
<p class="text-sm font-medium leading-none">
|
||||||
|
|||||||
45
ui/src/components/ui/navigation-menu/NavigationMenu.vue
Normal file
45
ui/src/components/ui/navigation-menu/NavigationMenu.vue
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuRoot, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import NavigationMenuViewport from "./NavigationMenuViewport.vue";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: { type: String, required: false },
|
||||||
|
defaultValue: { type: String, required: false },
|
||||||
|
dir: { type: String, required: false },
|
||||||
|
orientation: { type: String, required: false },
|
||||||
|
delayDuration: { type: Number, required: false },
|
||||||
|
skipDelayDuration: { type: Number, required: false },
|
||||||
|
disableClickTrigger: { type: Boolean, required: false },
|
||||||
|
disableHoverTrigger: { type: Boolean, required: false },
|
||||||
|
disablePointerLeaveClose: { type: Boolean, required: false },
|
||||||
|
unmountOnHide: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
viewport: { type: Boolean, required: false, default: true },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class", "viewport");
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuRoot
|
||||||
|
v-slot="slotProps"
|
||||||
|
data-slot="navigation-menu"
|
||||||
|
:data-viewport="viewport"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
<NavigationMenuViewport v-if="viewport" />
|
||||||
|
</NavigationMenuRoot>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuContent, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
disableOutsidePointerEvents: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits([
|
||||||
|
"escapeKeyDown",
|
||||||
|
"pointerDownOutside",
|
||||||
|
"focusOutside",
|
||||||
|
"interactOutside",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuContent
|
||||||
|
data-slot="navigation-menu-content"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto',
|
||||||
|
'group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuIndicator, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuIndicator
|
||||||
|
data-slot="navigation-menu-indicator"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md"
|
||||||
|
/>
|
||||||
|
</NavigationMenuIndicator>
|
||||||
|
</template>
|
||||||
24
ui/src/components/ui/navigation-menu/NavigationMenuItem.vue
Normal file
24
ui/src/components/ui/navigation-menu/NavigationMenuItem.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuItem } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
value: { type: String, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuItem
|
||||||
|
data-slot="navigation-menu-item"
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="cn('relative', props.class)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuItem>
|
||||||
|
</template>
|
||||||
31
ui/src/components/ui/navigation-menu/NavigationMenuLink.vue
Normal file
31
ui/src/components/ui/navigation-menu/NavigationMenuLink.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuLink, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
active: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["select"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuLink
|
||||||
|
data-slot="navigation-menu-link"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'data-active:focus:bg-accent data-active:hover:bg-accent data-active:bg-accent/50 data-active:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 [&_svg:not([class*=\'text-\'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*=\'size-\'])]:size-4',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</template>
|
||||||
30
ui/src/components/ui/navigation-menu/NavigationMenuList.vue
Normal file
30
ui/src/components/ui/navigation-menu/NavigationMenuList.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuList, useForwardProps } 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");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuList
|
||||||
|
data-slot="navigation-menu-list"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'group flex flex-1 list-none items-center justify-center gap-1',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</NavigationMenuList>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { ChevronDown } from "lucide-vue-next";
|
||||||
|
import { NavigationMenuTrigger, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { navigationMenuTriggerStyle } from ".";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
disabled: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NavigationMenuTrigger
|
||||||
|
data-slot="navigation-menu-trigger"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="cn(navigationMenuTriggerStyle(), 'group', props.class)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
<ChevronDown
|
||||||
|
class="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</NavigationMenuTrigger>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { NavigationMenuViewport, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
forceMount: { type: Boolean, required: false },
|
||||||
|
align: { type: String, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwardedProps = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="absolute top-full left-0 isolate z-50 flex justify-center">
|
||||||
|
<NavigationMenuViewport
|
||||||
|
data-slot="navigation-menu-viewport"
|
||||||
|
v-bind="forwardedProps"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--reka-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--reka-navigation-menu-viewport-width)] left-[var(--reka-navigation-menu-viewport-left)]',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
14
ui/src/components/ui/navigation-menu/index.js
Normal file
14
ui/src/components/ui/navigation-menu/index.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { cva } from "class-variance-authority";
|
||||||
|
|
||||||
|
export { default as NavigationMenu } from "./NavigationMenu.vue";
|
||||||
|
export { default as NavigationMenuContent } from "./NavigationMenuContent.vue";
|
||||||
|
export { default as NavigationMenuIndicator } from "./NavigationMenuIndicator.vue";
|
||||||
|
export { default as NavigationMenuItem } from "./NavigationMenuItem.vue";
|
||||||
|
export { default as NavigationMenuLink } from "./NavigationMenuLink.vue";
|
||||||
|
export { default as NavigationMenuList } from "./NavigationMenuList.vue";
|
||||||
|
export { default as NavigationMenuTrigger } from "./NavigationMenuTrigger.vue";
|
||||||
|
export { default as NavigationMenuViewport } from "./NavigationMenuViewport.vue";
|
||||||
|
|
||||||
|
export const navigationMenuTriggerStyle = cva(
|
||||||
|
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1",
|
||||||
|
);
|
||||||
31
ui/src/components/ui/stepper/Stepper.vue
Normal file
31
ui/src/components/ui/stepper/Stepper.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperRoot, useForwardPropsEmits } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
defaultValue: { type: Number, required: false },
|
||||||
|
orientation: { type: String, required: false },
|
||||||
|
dir: { type: String, required: false },
|
||||||
|
modelValue: { type: Number, required: false },
|
||||||
|
linear: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
const emits = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperRoot
|
||||||
|
v-slot="slotProps"
|
||||||
|
:class="cn('flex gap-2', props.class)"
|
||||||
|
v-bind="forwarded"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</StepperRoot>
|
||||||
|
</template>
|
||||||
25
ui/src/components/ui/stepper/StepperDescription.vue
Normal file
25
ui/src/components/ui/stepper/StepperDescription.vue
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperDescription, useForwardProps } 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");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperDescription
|
||||||
|
v-slot="slotProps"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="cn('text-xs text-muted-foreground', props.class)"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</StepperDescription>
|
||||||
|
</template>
|
||||||
36
ui/src/components/ui/stepper/StepperIndicator.vue
Normal file
36
ui/src/components/ui/stepper/StepperIndicator.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperIndicator, useForwardProps } 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");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperIndicator
|
||||||
|
v-slot="slotProps"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'inline-flex items-center justify-center rounded-full text-muted-foreground/50 w-8 h-8',
|
||||||
|
// Disabled
|
||||||
|
'group-data-[disabled]:text-muted-foreground group-data-[disabled]:opacity-50',
|
||||||
|
// Active
|
||||||
|
'group-data-[state=active]:bg-primary group-data-[state=active]:text-primary-foreground',
|
||||||
|
// Completed
|
||||||
|
'group-data-[state=completed]:bg-accent group-data-[state=completed]:text-accent-foreground',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</StepperIndicator>
|
||||||
|
</template>
|
||||||
33
ui/src/components/ui/stepper/StepperItem.vue
Normal file
33
ui/src/components/ui/stepper/StepperItem.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperItem, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
step: { type: Number, required: true },
|
||||||
|
disabled: { type: Boolean, required: false },
|
||||||
|
completed: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperItem
|
||||||
|
v-slot="slotProps"
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'flex items-center gap-2 group data-[disabled]:pointer-events-none',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot v-bind="slotProps" />
|
||||||
|
</StepperItem>
|
||||||
|
</template>
|
||||||
33
ui/src/components/ui/stepper/StepperSeparator.vue
Normal file
33
ui/src/components/ui/stepper/StepperSeparator.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperSeparator, useForwardProps } from "reka-ui";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
orientation: { type: String, required: false },
|
||||||
|
decorative: { type: Boolean, required: false },
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperSeparator
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'bg-muted',
|
||||||
|
// Disabled
|
||||||
|
'group-data-[disabled]:bg-muted group-data-[disabled]:opacity-50',
|
||||||
|
// Completed
|
||||||
|
'group-data-[state=completed]:bg-accent',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
24
ui/src/components/ui/stepper/StepperTitle.vue
Normal file
24
ui/src/components/ui/stepper/StepperTitle.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperTitle, useForwardProps } 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");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperTitle
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="cn('text-md font-semibold whitespace-nowrap', props.class)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</StepperTitle>
|
||||||
|
</template>
|
||||||
29
ui/src/components/ui/stepper/StepperTrigger.vue
Normal file
29
ui/src/components/ui/stepper/StepperTrigger.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
|
import { StepperTrigger, useForwardProps } 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");
|
||||||
|
|
||||||
|
const forwarded = useForwardProps(delegatedProps);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<StepperTrigger
|
||||||
|
v-bind="forwarded"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'p-1 flex flex-col items-center text-center gap-1 rounded-md',
|
||||||
|
props.class,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</StepperTrigger>
|
||||||
|
</template>
|
||||||
7
ui/src/components/ui/stepper/index.js
Normal file
7
ui/src/components/ui/stepper/index.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export { default as Stepper } from "./Stepper.vue";
|
||||||
|
export { default as StepperDescription } from "./StepperDescription.vue";
|
||||||
|
export { default as StepperIndicator } from "./StepperIndicator.vue";
|
||||||
|
export { default as StepperItem } from "./StepperItem.vue";
|
||||||
|
export { default as StepperSeparator } from "./StepperSeparator.vue";
|
||||||
|
export { default as StepperTitle } from "./StepperTitle.vue";
|
||||||
|
export { default as StepperTrigger } from "./StepperTrigger.vue";
|
||||||
36
ui/src/composables/useAuth.ts
Normal file
36
ui/src/composables/useAuth.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { useUserStore } from "@/stores/user"
|
||||||
|
import { computed } from "vue";
|
||||||
|
import { Role } from "@shared/types/roles"
|
||||||
|
|
||||||
|
export function useAuth() {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// Account status control
|
||||||
|
const accountStatus = computed(() => userStore.state);
|
||||||
|
|
||||||
|
// RBAC
|
||||||
|
const roles = computed<string[]>(() => {
|
||||||
|
return userStore.user?.roleData?.map((r: Role) => r.name) ?? [];
|
||||||
|
});
|
||||||
|
|
||||||
|
function isDev() {
|
||||||
|
return roles.value.includes('Dev');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasRole(roleName: string): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.includes(roleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAnyRole(roleNames: string[]): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.some(name => roleNames.includes(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasAllRoles(roleNames: string[]): boolean {
|
||||||
|
if (isDev()) return true;
|
||||||
|
return roles.value.every(name => roleNames.includes(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
return { hasRole, hasAnyRole, hasAllRoles, accountStatus }
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ const app = createApp(App)
|
|||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
||||||
if (!!import.meta.env.VITE_DISABLE_GLITCHTIP) {
|
if (!import.meta.env.VITE_DISABLE_GLITCHTIP) {
|
||||||
let dsn = import.meta.env.VITE_GLITCHTIP_DSN;
|
let dsn = import.meta.env.VITE_GLITCHTIP_DSN;
|
||||||
let environment = import.meta.env.VITE_ENVIRONMENT;
|
let environment = import.meta.env.VITE_ENVIRONMENT;
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
import ApplicationChat from '@/components/application/ApplicationChat.vue';
|
import ApplicationChat from '@/components/application/ApplicationChat.vue';
|
||||||
import ApplicationForm from '@/components/application/ApplicationForm.vue';
|
import ApplicationForm from '@/components/application/ApplicationForm.vue';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { ApplicationData, approveApplication, denyApplication, loadApplication, postApplication, postChatMessage, ApplicationStatus } from '@/api/application';
|
import { approveApplication, denyApplication, loadApplication, postApplication, postChatMessage, getMyApplication, postAdminChatMessage } from '@/api/application';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import Button from '@/components/ui/button/Button.vue';
|
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 { ApplicationData, ApplicationFull, ApplicationStatus, CommentRow } from '@shared/types/application';
|
||||||
|
|
||||||
const appData = ref<ApplicationData>(null);
|
const appData = ref<ApplicationData>(null);
|
||||||
const appID = ref<number | null>(null);
|
const appID = ref<number | null>(null);
|
||||||
const chatData = ref<object[]>([])
|
const chatData = ref<CommentRow[]>([])
|
||||||
const readOnly = ref<boolean>(false);
|
const readOnly = ref<boolean>(false);
|
||||||
const newApp = ref<boolean>(null);
|
const newApp = ref<boolean>(null);
|
||||||
const status = ref<ApplicationStatus>(null);
|
const status = ref<ApplicationStatus>(null);
|
||||||
@@ -17,19 +19,14 @@ const decisionDate = ref<Date | null>(null);
|
|||||||
const submitDate = ref<Date | null>(null);
|
const submitDate = ref<Date | null>(null);
|
||||||
const loading = ref<boolean>(true);
|
const loading = ref<boolean>(true);
|
||||||
const member_name = ref<string>();
|
const member_name = ref<string>();
|
||||||
onMounted(async () => {
|
|
||||||
try {
|
const props = defineProps<{
|
||||||
//get app ID from URL param
|
mode?: "create" | "view-self" | "view-recruiter" | "view-self-id"
|
||||||
const router = useRoute();
|
}>()
|
||||||
const appIDRaw = router.params.id;
|
|
||||||
if (appIDRaw === undefined) {
|
const finalMode = ref<"create" | "view-self" | "view-recruiter" | "view-self-id">("create");
|
||||||
//new app
|
|
||||||
appData.value = null
|
function loadData(raw: ApplicationFull) {
|
||||||
readOnly.value = false;
|
|
||||||
newApp.value = true;
|
|
||||||
} else {
|
|
||||||
//load app
|
|
||||||
const raw = await loadApplication(appIDRaw.toString());
|
|
||||||
|
|
||||||
const data = raw.application;
|
const data = raw.application;
|
||||||
|
|
||||||
@@ -43,9 +40,47 @@ onMounted(async () => {
|
|||||||
newApp.value = false;
|
newApp.value = false;
|
||||||
readOnly.value = true;
|
readOnly.value = true;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
const route = useRoute();
|
||||||
|
const unauthorized = ref(false);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
//recruiter mode
|
||||||
|
if (props.mode === 'view-recruiter') {
|
||||||
|
finalMode.value = 'view-recruiter';
|
||||||
|
loadData(await loadApplication(Number(route.params.id), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//viewer mode
|
||||||
|
if (props.mode === 'view-self') {
|
||||||
|
finalMode.value = 'view-self';
|
||||||
|
loadData(await loadApplication("me"))
|
||||||
|
}
|
||||||
|
|
||||||
|
//creator mode
|
||||||
|
if (props.mode === 'create') {
|
||||||
|
finalMode.value = 'create';
|
||||||
|
appData.value = null
|
||||||
|
readOnly.value = false;
|
||||||
|
newApp.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.mode === 'view-self-id') {
|
||||||
|
finalMode.value = 'view-self-id';
|
||||||
|
try {
|
||||||
|
let raw = await getMyApplication(Number(route.params.id))
|
||||||
|
loadData(raw);
|
||||||
|
unauthorized.value = false;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message === "Unauthorized") {
|
||||||
|
unauthorized.value = true;
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -53,12 +88,18 @@ async function postComment(comment) {
|
|||||||
chatData.value.push(await postChatMessage(comment, appID.value));
|
chatData.value.push(await postChatMessage(comment, appID.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function postCommentInternal(comment) {
|
||||||
|
chatData.value.push(await postAdminChatMessage(comment, appID.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['submit']);
|
||||||
|
|
||||||
async function postApp(appData) {
|
async function postApp(appData) {
|
||||||
console.log("test")
|
|
||||||
const res = await postApplication(appData);
|
const res = await postApplication(appData);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
readOnly.value = true;
|
readOnly.value = true;
|
||||||
newApp.value = false;
|
newApp.value = false;
|
||||||
|
emit('submit');
|
||||||
}
|
}
|
||||||
// TODO: Handle fail to post
|
// TODO: Handle fail to post
|
||||||
}
|
}
|
||||||
@@ -74,7 +115,11 @@ async function handleDeny(id) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="!loading" class="max-w-3xl mx-auto my-20">
|
<div v-if="!loading" class="w-full h-20">
|
||||||
|
<div v-if="unauthorized" class="flex justify-center w-full my-10">
|
||||||
|
You do not have permission to view this application.
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
<div v-if="!newApp" class="flex flex-row justify-between items-center py-2 mb-8">
|
<div v-if="!newApp" class="flex flex-row justify-between items-center py-2 mb-8">
|
||||||
<!-- Application header -->
|
<!-- Application header -->
|
||||||
<div>
|
<div>
|
||||||
@@ -102,7 +147,7 @@ async function handleDeny(id) {
|
|||||||
hour: "2-digit",
|
hour: "2-digit",
|
||||||
minute: "2-digit"
|
minute: "2-digit"
|
||||||
}) }}</p>
|
}) }}</p>
|
||||||
<div class="mt-2" v-else>
|
<div class="mt-2" v-else-if="finalMode === 'view-recruiter'">
|
||||||
<Button variant="success" class="mr-2" :onclick="() => { handleApprove(appID) }">
|
<Button variant="success" class="mr-2" :onclick="() => { handleApprove(appID) }">
|
||||||
<CheckIcon></CheckIcon>
|
<CheckIcon></CheckIcon>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -117,11 +162,14 @@ async function handleDeny(id) {
|
|||||||
</div>
|
</div>
|
||||||
<ApplicationForm :read-only="readOnly" :data="appData" @submit="(e) => { postApp(e) }" class="mb-7">
|
<ApplicationForm :read-only="readOnly" :data="appData" @submit="(e) => { postApp(e) }" class="mb-7">
|
||||||
</ApplicationForm>
|
</ApplicationForm>
|
||||||
<div v-if="!newApp">
|
<div v-if="!newApp" class="pb-15">
|
||||||
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
|
<h3 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-4">Discussion</h3>
|
||||||
<ApplicationChat :messages="chatData" @post="postComment"></ApplicationChat>
|
<ApplicationChat :messages="chatData" @post="postComment" @post-internal="postCommentInternal">
|
||||||
|
</ApplicationChat>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
<!-- TODO: Implement some kinda loading screen -->
|
<!-- TODO: Implement some kinda loading screen -->
|
||||||
<div v-else>Loading</div>
|
<div v-else class="flex items-center justify-center h-full">Loading</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -13,8 +13,8 @@ function goToApplication() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="user.state == 'guest'"
|
<div>
|
||||||
class="min-h-screen flex flex-col items-center justify-center text-center bg-neutral-950 text-white px-4">
|
<div v-if="user.state == 'guest'" class="flex flex-col items-center justify-center">
|
||||||
<h1 class="text-4xl font-bold mb-4">Welcome to the 17th</h1>
|
<h1 class="text-4xl font-bold mb-4">Welcome to the 17th</h1>
|
||||||
<p class="text-neutral-400 mb-8 max-w-md">
|
<p class="text-neutral-400 mb-8 max-w-md">
|
||||||
To join our unit, please fill out an application to continue.
|
To join our unit, please fill out an application to continue.
|
||||||
@@ -26,4 +26,5 @@ function goToApplication() {
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
HOMEPAGEEEEEEEEEEEEEEEEEEE
|
HOMEPAGEEEEEEEEEEEEEEEEEEE
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,24 +1,303 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import ApplicationForm from '@/components/application/ApplicationForm.vue';
|
||||||
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
|
import {
|
||||||
|
Stepper,
|
||||||
|
StepperDescription,
|
||||||
|
StepperIndicator,
|
||||||
|
StepperItem,
|
||||||
|
StepperSeparator,
|
||||||
|
StepperTitle,
|
||||||
|
StepperTrigger,
|
||||||
|
} from '@/components/ui/stepper'
|
||||||
|
import { useUserStore } from '@/stores/user';
|
||||||
|
import { Check, Circle, Dot, Users, X } from 'lucide-vue-next'
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import Application from './Application.vue';
|
||||||
|
import { restartApplication } from '@/api/application';
|
||||||
|
|
||||||
|
function goToLogin() {
|
||||||
|
const redirectUrl = encodeURIComponent(window.location.origin + '/join')
|
||||||
|
window.location.href = `https://aj17thdevapi.nexuszone.net/login?redirect=${redirectUrl}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
let userStore = useUserStore();
|
||||||
|
|
||||||
|
const steps = computed(() => {
|
||||||
|
const isDenied = userStore.state === 'denied'
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
step: 1,
|
||||||
|
title: 'Create account',
|
||||||
|
description: 'Begin by setting up your account',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
step: 2,
|
||||||
|
title: 'Submit application',
|
||||||
|
description: 'Provide a few details about yourself',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
step: 3,
|
||||||
|
title: 'Application review',
|
||||||
|
description: 'Our team will review your submission',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
step: 4,
|
||||||
|
title: isDenied ? 'Application denied' : 'Acceptance',
|
||||||
|
description: isDenied
|
||||||
|
? 'Your application was not approved'
|
||||||
|
: 'Get started with the 17th Rangers',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const currentStep = computed<number>(() => {
|
||||||
|
if (!userStore.isLoggedIn)
|
||||||
|
return 1;
|
||||||
|
switch (userStore.state) {
|
||||||
|
case "guest":
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case "applicant":
|
||||||
|
return 3;
|
||||||
|
break;
|
||||||
|
case "member":
|
||||||
|
return 5;
|
||||||
|
break;
|
||||||
|
case "denied":
|
||||||
|
return 5;
|
||||||
|
break;
|
||||||
|
case "retired":
|
||||||
|
return 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const finalPanel = ref<'app' | 'message'>('message');
|
||||||
|
|
||||||
|
const reloadKey = ref(0);
|
||||||
|
|
||||||
|
async function restartApp() {
|
||||||
|
await restartApplication();
|
||||||
|
await userStore.loadUser();
|
||||||
|
reloadKey.value++;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-screen flex items-center justify-center ">
|
<div class="flex flex-col items-center mt-10 w-full" :key="reloadKey">
|
||||||
<div class="w-full max-w-2xl mx-auto p-8 text-center">
|
|
||||||
<h1 class="text-4xl sm:text-5xl font-extrabold mb-4">
|
<!-- Stepper Container -->
|
||||||
welcome to the 17th
|
<div class="w-full flex justify-center">
|
||||||
|
<div class="w-full max-w-7xl">
|
||||||
|
<Stepper class="flex w-full items-start gap-2" v-model="currentStep">
|
||||||
|
<StepperItem v-for="step in steps" :key="step.step" v-slot="{ state }"
|
||||||
|
class="relative flex w-full flex-col items-center" :step="step.step">
|
||||||
|
<StepperSeparator v-if="step.step !== steps[steps.length - 1]?.step"
|
||||||
|
class="absolute left-[calc(50%+20px)] right-[calc(-50%+10px)] top-5 block h-0.5 rounded-full bg-muted group-data-[state=completed]:bg-primary" />
|
||||||
|
|
||||||
|
<StepperTrigger as-child>
|
||||||
|
<Button :variant="state === 'completed' || state === 'active' ? 'default' : 'outline'"
|
||||||
|
size="icon" class="z-10 rounded-full shrink-0"
|
||||||
|
:class="[state === 'active' && 'ring-2 ring-ring ring-offset-2 ring-offset-background']">
|
||||||
|
<template v-if="state === 'completed'">
|
||||||
|
<X v-if="step.step === 4 && userStore.state === 'denied'" class="size-5" />
|
||||||
|
<Check v-else class="size-5" />
|
||||||
|
</template>
|
||||||
|
<Circle v-if="state === 'active'" />
|
||||||
|
<Dot v-if="state === 'inactive'" />
|
||||||
|
</Button>
|
||||||
|
</StepperTrigger>
|
||||||
|
|
||||||
|
<div class="mt-2 flex flex-col items-center text-center">
|
||||||
|
<StepperTitle class="text-sm font-semibold transition lg:text-base"
|
||||||
|
:class="[state === 'active' && 'text-primary']">
|
||||||
|
{{ step.title }}
|
||||||
|
</StepperTitle>
|
||||||
|
|
||||||
|
<StepperDescription
|
||||||
|
class="sr-only text-xs text-muted-foreground transition md:not-sr-only lg:text-sm"
|
||||||
|
:class="[state === 'active' && 'text-primary']">
|
||||||
|
{{ step.description }}
|
||||||
|
</StepperDescription>
|
||||||
|
</div>
|
||||||
|
</StepperItem>
|
||||||
|
</Stepper>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div class="mt-12 mb-20 flex w-full max-w-6xl justify-center">
|
||||||
|
<div v-if="currentStep === 1" class="w-full max-w-2xl p-8">
|
||||||
|
<h1 class="text-3xl sm:text-4xl font-bold mb-4 text-left">
|
||||||
|
Create your account
|
||||||
</h1>
|
</h1>
|
||||||
<p class=" mb-8">
|
|
||||||
Welcome — click below to get started.
|
<p class="text-left text-muted-foreground mb-6">
|
||||||
|
You'll be redirected to our secure sign-in system to set up your account
|
||||||
|
and begin your application.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Button class="w-44" @click="goToLogin">Get started</Button>
|
<Button class="px-6 py-3" @click="goToLogin">
|
||||||
|
Continue to account creation
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<Application v-else-if="currentStep === 2" @submit="userStore.loadUser()" :mode="'create'"></Application>
|
||||||
|
<Application v-else-if="currentStep === 3" :mode="'view-self'"></Application>
|
||||||
|
<div v-if="currentStep === 5" class="w-full p-8 pt-0">
|
||||||
|
<div class="mb-5">
|
||||||
|
<div class="flex w-min *:px-10 pt-2 border-b *:w-full *:text-center *:pb-1 *:cursor-pointer">
|
||||||
|
<label :class="finalPanel === 'message' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||||
|
@click="finalPanel = 'message'">Message
|
||||||
|
</label>
|
||||||
|
<label :class="finalPanel === 'app' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||||
|
@click="finalPanel = 'app'">Application
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="finalPanel === 'message'">
|
||||||
|
<!-- Accepted message -->
|
||||||
|
<div v-if="userStore.state === 'member'">
|
||||||
|
<h1 class="text-3xl sm:text-4xl font-bold mb-4 text-left">
|
||||||
|
Welcome to the 17th Ranger Battalion
|
||||||
|
</h1>
|
||||||
|
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
|
||||||
|
<p>
|
||||||
|
Your application to the 17th Ranger Battalion has been <strong>accepted</strong>!
|
||||||
|
We’re excited to welcome you to the community.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
There are just a couple of steps to complete before joining us on the battlefield:
|
||||||
|
</p>
|
||||||
|
<!-- MODPACK SECTION -->
|
||||||
|
<h2 class="text-xl font-semibold text-foreground mt-6">1. Download the Modpack</h2>
|
||||||
|
<p>
|
||||||
|
You’ll need to download our private server modpack. This can take some time, so we
|
||||||
|
recommend
|
||||||
|
starting as soon as possible. The link below leads to our
|
||||||
|
<strong>Shadow Mod</strong>, which automatically pulls all required dependencies.
|
||||||
|
</p>
|
||||||
|
<ul class="list-disc pl-6 space-y-1">
|
||||||
|
<li>Subscribe to the Shadow Mod.</li>
|
||||||
|
<li>When prompted, choose <em>“Yes”</em> to download all associated mods.</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<a href="https://www.guilded.gg/Iceberg-gaming/groups/v3j2vAP3/channels/6979335e-60f7-4ab9-9590-66df69367d1e/docs/2013948655"
|
||||||
|
class="text-primary underline" target="_blank">
|
||||||
|
Click here for the full installation guide
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<!-- CONTACT SECTION -->
|
||||||
|
<h2 class="text-xl font-semibold text-foreground mt-6">2. Contact a Corporal or Higher</h2>
|
||||||
|
<p>
|
||||||
|
Once you have the modpack installed, connect on TeamSpeak or post in Discord. Anyone
|
||||||
|
with
|
||||||
|
the
|
||||||
|
rank of <strong>Corporal or above</strong> can help get you set up.
|
||||||
|
</p>
|
||||||
|
<ul class="list-none pl-0 space-y-1">
|
||||||
|
<li><strong>TeamSpeak:</strong><a href="ts3server://ts.iceberg-gaming.com"
|
||||||
|
class="text-primary underline"
|
||||||
|
target="_blank">ts3server://ts.iceberg-gaming.com</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<strong>Discord:</strong>
|
||||||
|
<a href="https://discord.gg/7hDQCEb" class="text-primary underline"
|
||||||
|
target="_blank">https://discord.gg/7hDQCEb</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
They will assist you with your initial assessments and training. Basic trainings run on
|
||||||
|
a
|
||||||
|
rotating schedule or can be requested through our Battalion Forms. Don’t hesitate to hop
|
||||||
|
in
|
||||||
|
during weeknights or Saturday operations to start playing with us!
|
||||||
|
</p>
|
||||||
|
<!-- FINAL NOTES -->
|
||||||
|
<h2 class="text-xl font-semibold text-foreground mt-6">3. Get Familiar with the Unit</h2>
|
||||||
|
<p>
|
||||||
|
Please take a moment to read through our <strong>Code of Conduct</strong>,
|
||||||
|
<strong>Ranks</strong>, and <strong>Structure</strong> pages. We also encourage you to
|
||||||
|
browse
|
||||||
|
our forums and introduce yourself.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you have any questions, feel free to reach out on TeamSpeak, Discord, or Guilded,
|
||||||
|
someone
|
||||||
|
will always be around to help.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Denied message -->
|
||||||
|
<div v-else-if="userStore.state === 'denied'">
|
||||||
|
<div class="w-full max-w-2xl flex flex-col gap-8">
|
||||||
|
<h1 class="text-3xl sm:text-4xl font-bold text-left">
|
||||||
|
Application Not Approved
|
||||||
|
</h1>
|
||||||
|
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
|
||||||
|
<p>
|
||||||
|
Thank you for your interest in joining the <strong>17th Ranger Battalion</strong>.
|
||||||
|
After reviewing your application, we regret to inform you that we are not able to
|
||||||
|
approve it at this time.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you would like more information, you are encouraged to
|
||||||
|
<strong>reach out and inquire</strong> about the reason your application was not
|
||||||
|
approved.
|
||||||
|
We are always happy to provide clarification where possible.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
You are welcome to <strong>resubmit your application in the future</strong> should
|
||||||
|
your
|
||||||
|
circumstances change or when we may be better able to incorporate you into the unit.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
All the best,<br />
|
||||||
|
<span class="text-foreground font-medium">The 17th Ranger Battalion Recruitment
|
||||||
|
Team</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button class="w-min" @click="restartApp">New Application</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="userStore.state === 'retired'">
|
||||||
|
<div class="w-full max-w-2xl flex flex-col gap-8">
|
||||||
|
<h1 class="text-3xl sm:text-4xl font-bold text-left">
|
||||||
|
You have retired from the 17th Ranger Battalion
|
||||||
|
</h1>
|
||||||
|
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
|
||||||
|
<p>
|
||||||
|
Thank you for your service and participation in the <strong>17th Ranger
|
||||||
|
Battalion</strong>.
|
||||||
|
Your time with us has been sincerely appreciated.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Should you ever wish to return, you are welcome to <strong>reach out to our
|
||||||
|
leadership
|
||||||
|
team</strong>
|
||||||
|
for guidance on the reinstatement process or to stay connected with the community.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
We recognize that circumstances change, and you will always have a place to
|
||||||
|
reconnect with
|
||||||
|
us
|
||||||
|
should the opportunity arise in the future.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
All the best,<br />
|
||||||
|
<span class="text-foreground font-medium">The 17th Ranger Battalion Leadership
|
||||||
|
Team</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button class="w-min" @click="restartApp">New Application</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="finalPanel === 'app'">
|
||||||
|
<Application :mode="'view-self'"></Application>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import Button from '@/components/ui/button/Button.vue';
|
|
||||||
|
|
||||||
|
|
||||||
function goToLogin() {
|
|
||||||
window.location.href = 'https://aj17thdevapi.nexuszone.net/login';
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { getAllApplications, approveApplication, denyApplication, ApplicationStatus } from '@/api/application';
|
import { getAllApplications, approveApplication, denyApplication } from '@/api/application';
|
||||||
|
import { ApplicationStatus } from '@shared/types/application'
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -10,9 +11,10 @@ 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 } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import { 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';
|
||||||
|
|
||||||
const appList = ref([]);
|
const appList = ref([]);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -61,18 +63,40 @@ async function handleDeny(id) {
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
function openApplication(id) {
|
function openApplication(id) {
|
||||||
router.push(`./application/${id}`)
|
router.push(`/administration/applications/${id}`)
|
||||||
|
openPanel.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeApplication() {
|
||||||
|
router.push('/administration/applications')
|
||||||
|
openPanel.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
watch(() => route.params.id, (newId) => {
|
||||||
|
if (newId === undefined) {
|
||||||
|
openPanel.value = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const openPanel = ref(false);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
appList.value = await getAllApplications();
|
appList.value = await getAllApplications();
|
||||||
|
|
||||||
|
//preload application
|
||||||
|
if (route.params.id != undefined) {
|
||||||
|
openApplication(route.params.id)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto max-w-5xl">
|
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5 h-52 min-h-0 overflow-hidden">
|
||||||
<h1 class="my-4">Manage Applications</h1>
|
<!-- application list -->
|
||||||
|
<div :class="openPanel == false ? 'w-full' : 'w-2/5'" class="pr-9">
|
||||||
|
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">Manage Applications</h1>
|
||||||
<Table>
|
<Table>
|
||||||
<!-- <TableCaption>A list of your recent invoices.</TableCaption> -->
|
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead>User</TableHead>
|
<TableHead>User</TableHead>
|
||||||
@@ -80,14 +104,15 @@ onMounted(async () => {
|
|||||||
<TableHead class="text-right">Status</TableHead>
|
<TableHead class="text-right">Status</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody class="overflow-y-auto scrollbar-themed">
|
||||||
<TableRow v-for="app in appList" :key="app.id" class="cursor-pointer"
|
<TableRow v-for="app in appList" :key="app.id" class="cursor-pointer"
|
||||||
:onClick="() => { openApplication(app.id) }">
|
:onClick="() => { openApplication(app.id) }">
|
||||||
<TableCell class="font-medium">{{ app.member_name }}</TableCell>
|
<TableCell class="font-medium">{{ app.member_name }}</TableCell>
|
||||||
<TableCell :title="formatExact(app.submitted_at)">
|
<TableCell :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">
|
<TableCell v-if="app.app_status === ApplicationStatus.Pending"
|
||||||
|
class="inline-flex items-end gap-2">
|
||||||
<Button variant="success" @click.stop="() => { handleApprove(app.id) }">
|
<Button variant="success" @click.stop="() => { handleApprove(app.id) }">
|
||||||
<CheckIcon></CheckIcon>
|
<CheckIcon></CheckIcon>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -105,4 +130,46 @@ onMounted(async () => {
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="openPanel" class="pl-9 border-l w-3/5" :key="$route.params.id">
|
||||||
|
<div class="mb-5 flex justify-between">
|
||||||
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight"> Application</p>
|
||||||
|
<button @click="closeApplication()" class="cursor-pointer">
|
||||||
|
<XIcon></XIcon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="overflow-y-auto max-h-[80vh] h-full mt-5 scrollbar-themed">
|
||||||
|
<Application :mode="'view-recruiter'"></Application>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* Firefox */
|
||||||
|
.scrollbar-themed {
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: #555 #1f1f1f;
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chrome, Edge, Safari */
|
||||||
|
.scrollbar-themed::-webkit-scrollbar {
|
||||||
|
width: 10px;
|
||||||
|
/* slightly wider to allow padding look */
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-track {
|
||||||
|
background: #1f1f1f;
|
||||||
|
margin-left: 6px;
|
||||||
|
/* ❗ adds space between content + scrollbar */
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-thumb {
|
||||||
|
background: #555;
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #777;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -68,7 +68,7 @@ onMounted(async () => {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
<div class="max-w-5xl mx-auto">
|
<div class="max-w-5xl w-full mx-auto">
|
||||||
Active
|
Active
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
148
ui/src/pages/MyApplications.vue
Normal file
148
ui/src/pages/MyApplications.vue
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<script setup>
|
||||||
|
import { loadMyApplications } from '@/api/application';
|
||||||
|
import { ApplicationStatus } from '@shared/types/application';
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCaption,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from '@/components/ui/table'
|
||||||
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
|
import { onMounted, ref, watch } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import { CheckIcon, XIcon } from 'lucide-vue-next';
|
||||||
|
import Application from './Application.vue';
|
||||||
|
|
||||||
|
const appList = ref([]);
|
||||||
|
const now = Date.now();
|
||||||
|
// relative time formatter (uses user locale)
|
||||||
|
const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto' })
|
||||||
|
// exact date/time for tooltip
|
||||||
|
const exactFmt = new Intl.DateTimeFormat(undefined, {
|
||||||
|
dateStyle: 'medium', timeStyle: 'short', timeZone: 'America/Toronto'
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatAgo(iso) {
|
||||||
|
const d = new Date(iso)
|
||||||
|
if (isNaN(d)) return ''
|
||||||
|
let diff = (d.getTime() - now) / 1000 // seconds relative to page load
|
||||||
|
const divisions = [
|
||||||
|
{ amount: 60, name: 'second' },
|
||||||
|
{ amount: 60, name: 'minute' },
|
||||||
|
{ amount: 24, name: 'hour' },
|
||||||
|
{ amount: 7, name: 'day' },
|
||||||
|
{ amount: 4.34524, name: 'week' }, // avg weeks per month
|
||||||
|
{ amount: 12, name: 'month' },
|
||||||
|
{ amount: Infinity, name: 'year' },
|
||||||
|
]
|
||||||
|
for (const div of divisions) {
|
||||||
|
if (Math.abs(diff) < div.amount) {
|
||||||
|
return rtf.format(Math.round(diff), div.name)
|
||||||
|
}
|
||||||
|
diff /= div.amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatExact(iso) {
|
||||||
|
const d = new Date(iso)
|
||||||
|
return isNaN(d) ? '' : exactFmt.format(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
function openApplication(id) {
|
||||||
|
router.push(`/applications/${id}`)
|
||||||
|
openPanel.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
watch(() => route.params.id, (newId) => {
|
||||||
|
if (newId === undefined) {
|
||||||
|
openPanel.value = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const openPanel = ref(false);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
appList.value = await loadMyApplications();
|
||||||
|
|
||||||
|
//preload application
|
||||||
|
if (route.params.id != undefined) {
|
||||||
|
openApplication(route.params.id)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5 h-52 min-h-0 overflow-hidden">
|
||||||
|
<!-- application list -->
|
||||||
|
<div :class="openPanel == false ? 'w-full' : 'w-2/5'" class="pr-9">
|
||||||
|
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight mb-5">My Applications</h1>
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>Date Submitted</TableHead>
|
||||||
|
<TableHead class="text-right">Status</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody class="overflow-y-auto scrollbar-themed">
|
||||||
|
<TableRow v-for="app in appList" :key="app.id" class="cursor-pointer"
|
||||||
|
:onClick="() => { openApplication(app.id) }">
|
||||||
|
<TableCell :title="formatExact(app.submitted_at)">
|
||||||
|
{{ formatAgo(app.submitted_at) }}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell class="text-right font-semibold" :class="[
|
||||||
|
,
|
||||||
|
app.app_status === ApplicationStatus.Pending && 'text-yellow-500',
|
||||||
|
app.app_status === ApplicationStatus.Accepted && 'text-green-500',
|
||||||
|
app.app_status === ApplicationStatus.Denied && 'text-destructive'
|
||||||
|
]">{{ app.app_status }}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
<div v-if="openPanel" class="pl-9 border-l w-3/5" :key="$route.params.id">
|
||||||
|
<div class="mb-5 flex justify-between">
|
||||||
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight"> Application</p>
|
||||||
|
</div>
|
||||||
|
<div class="overflow-y-auto max-h-[80vh] h-full mt-5 scrollbar-themed">
|
||||||
|
<Application :mode="'view-self-id'"></Application>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* Firefox */
|
||||||
|
.scrollbar-themed {
|
||||||
|
scrollbar-width: thin;
|
||||||
|
scrollbar-color: #555 #1f1f1f;
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chrome, Edge, Safari */
|
||||||
|
.scrollbar-themed::-webkit-scrollbar {
|
||||||
|
width: 10px;
|
||||||
|
/* slightly wider to allow padding look */
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-track {
|
||||||
|
background: #1f1f1f;
|
||||||
|
margin-left: 6px;
|
||||||
|
/* ❗ adds space between content + scrollbar */
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-thumb {
|
||||||
|
background: #555;
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-themed::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #777;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -95,7 +95,7 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="px-20 mx-auto max-w-[100rem] flex mt-5">
|
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5">
|
||||||
<!-- training report list -->
|
<!-- training report list -->
|
||||||
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="min-h-screen flex flex-col items-center justify-center text-center px-6">
|
<div class="flex flex-col items-center justify-center text-center px-6">
|
||||||
<h1 class="text-5xl font-bold mb-4">Unauthorized</h1>
|
<h1 class="text-5xl font-bold mb-4">Unauthorized</h1>
|
||||||
<p class="text-lg text-muted-foreground max-w-md mb-6">
|
<p class="text-lg text-muted-foreground max-w-md mb-6">
|
||||||
You don't have permission to access this page.
|
You don't have permission to access this page.
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ const router = createRouter({
|
|||||||
routes: [
|
routes: [
|
||||||
// PUBLIC
|
// PUBLIC
|
||||||
{ path: '/join', component: () => import('@/pages/Join.vue') },
|
{ path: '/join', component: () => import('@/pages/Join.vue') },
|
||||||
|
{ path: '/applications', component: () => import('@/pages/MyApplications.vue'), meta: { requiresAuth: true } },
|
||||||
|
{ path: '/applications/:id', component: () => import('@/pages/MyApplications.vue'), meta: { requiresAuth: true } },
|
||||||
|
|
||||||
// AUTH REQUIRED
|
// AUTH REQUIRED
|
||||||
{ path: '/apply', component: () => import('@/pages/Application.vue'), meta: { requiresAuth: true } },
|
{ path: '/', component: () => import('@/pages/Homepage.vue') },
|
||||||
{ path: '/', component: () => import('@/pages/Homepage.vue'), meta: { requiresAuth: true } },
|
|
||||||
|
|
||||||
// MEMBER ROUTES
|
// MEMBER ROUTES
|
||||||
{ path: '/members', component: () => import('@/pages/memberList.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
{ path: '/members', component: () => import('@/pages/memberList.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||||
@@ -29,7 +30,7 @@ const router = createRouter({
|
|||||||
meta: { requiresAuth: true, memberOnly: true, roles: ['staff', 'admin'] },
|
meta: { requiresAuth: true, memberOnly: true, roles: ['staff', 'admin'] },
|
||||||
children: [
|
children: [
|
||||||
{ path: 'applications', component: () => import('@/pages/ManageApplications.vue') },
|
{ path: 'applications', component: () => import('@/pages/ManageApplications.vue') },
|
||||||
{ path: 'application/:id', component: () => import('@/pages/Application.vue') },
|
{ path: 'applications/:id', component: () => import('@/pages/ManageApplications.vue') },
|
||||||
{ path: 'rankChange', component: () => import('@/pages/RankChange.vue') },
|
{ path: 'rankChange', component: () => import('@/pages/RankChange.vue') },
|
||||||
{ path: 'applications/:id', component: () => import('@/pages/Application.vue') },
|
{ path: 'applications/:id', component: () => import('@/pages/Application.vue') },
|
||||||
{ path: 'transfer', component: () => import('@/pages/ManageTransfers.vue') },
|
{ path: 'transfer', component: () => import('@/pages/ManageTransfers.vue') },
|
||||||
@@ -63,15 +64,15 @@ router.beforeEach(async (to) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Must be a member
|
// Must be a member
|
||||||
// if (to.meta.memberOnly && user.state !== 'member') {
|
if (to.meta.memberOnly && user.state !== 'member') {
|
||||||
// return '/unauthorized'
|
return '/unauthorized'
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Must have specific role
|
// Must have specific role
|
||||||
// if (to.meta.roles && !user.hasRole('Dev') && !user.hasAnyRole(to.meta.roles)) {
|
if (to.meta.roles && !user.hasRole('Dev') && !user.hasAnyRole(to.meta.roles)) {
|
||||||
// return '/unauthorized'
|
return '/unauthorized'
|
||||||
// }
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
@@ -5,7 +5,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
const user = ref(null)
|
const user = ref(null)
|
||||||
const roles = computed(() => new Set(user.value?.roleData?.map(r => r.name) ?? []));
|
const roles = computed(() => new Set(user.value?.roleData?.map(r => r.name) ?? []));
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
const state = computed(() => user.value.state);
|
const state = computed<string | undefined>(() => user.value?.state || undefined);
|
||||||
const isLoggedIn = computed(() => user.value !== null)
|
const isLoggedIn = computed(() => user.value !== null)
|
||||||
|
|
||||||
async function loadUser() {
|
async function loadUser() {
|
||||||
@@ -16,6 +16,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user